Revert "Suppress debuginfo on naked function arguments"
This reverts commit 25670749b44a9c7a4cfd3fbf780bbe3344a9a6c5. This commit does not actually fix the problem. It merely removes the name of the argument from the LLVM output. Even without the name, Rust codegen still spills the (nameless) variable onto the stack which is the root cause. The root cause is solved in the next commit.
This commit is contained in:
parent
cbe7c5ce70
commit
0356bb9fbb
@ -10,7 +10,6 @@ use rustc_hir::lang_items;
|
|||||||
use rustc_hir::{GeneratorKind, HirIdMap, Node};
|
use rustc_hir::{GeneratorKind, HirIdMap, Node};
|
||||||
use rustc_index::vec::{Idx, IndexVec};
|
use rustc_index::vec::{Idx, IndexVec};
|
||||||
use rustc_infer::infer::TyCtxtInferExt;
|
use rustc_infer::infer::TyCtxtInferExt;
|
||||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
|
||||||
use rustc_middle::middle::region;
|
use rustc_middle::middle::region;
|
||||||
use rustc_middle::mir::*;
|
use rustc_middle::mir::*;
|
||||||
use rustc_middle::ty::subst::Subst;
|
use rustc_middle::ty::subst::Subst;
|
||||||
@ -798,22 +797,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
argument_scope: region::Scope,
|
argument_scope: region::Scope,
|
||||||
ast_body: &'tcx hir::Expr<'tcx>,
|
ast_body: &'tcx hir::Expr<'tcx>,
|
||||||
) -> BlockAnd<()> {
|
) -> BlockAnd<()> {
|
||||||
let tcx = self.hir.tcx();
|
|
||||||
let attrs = tcx.codegen_fn_attrs(fn_def_id);
|
|
||||||
let naked = attrs.flags.contains(CodegenFnAttrFlags::NAKED);
|
|
||||||
|
|
||||||
// Allocate locals for the function arguments
|
// Allocate locals for the function arguments
|
||||||
for &ArgInfo(ty, _, arg_opt, _) in arguments.iter() {
|
for &ArgInfo(ty, _, arg_opt, _) in arguments.iter() {
|
||||||
let source_info =
|
let source_info =
|
||||||
SourceInfo::outermost(arg_opt.map_or(self.fn_span, |arg| arg.pat.span));
|
SourceInfo::outermost(arg_opt.map_or(self.fn_span, |arg| arg.pat.span));
|
||||||
let arg_local = self.local_decls.push(LocalDecl::with_source_info(ty, source_info));
|
let arg_local = self.local_decls.push(LocalDecl::with_source_info(ty, source_info));
|
||||||
|
|
||||||
// Emit function argument debuginfo only for non-naked functions.
|
|
||||||
// See: https://github.com/rust-lang/rust/issues/42779
|
|
||||||
if naked {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If this is a simple binding pattern, give debuginfo a nice name.
|
// If this is a simple binding pattern, give debuginfo a nice name.
|
||||||
if let Some(arg) = arg_opt {
|
if let Some(arg) = arg_opt {
|
||||||
if let Some(ident) = arg.pat.simple_ident() {
|
if let Some(ident) = arg.pat.simple_ident() {
|
||||||
@ -826,6 +815,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let tcx = self.hir.tcx();
|
||||||
let tcx_hir = tcx.hir();
|
let tcx_hir = tcx.hir();
|
||||||
let hir_typeck_results = self.hir.typeck_results();
|
let hir_typeck_results = self.hir.typeck_results();
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ pub fn naked_empty() {
|
|||||||
// CHECK-NEXT: define void @naked_with_args(i{{[0-9]+( %0)?}})
|
// CHECK-NEXT: define void @naked_with_args(i{{[0-9]+( %0)?}})
|
||||||
pub fn naked_with_args(a: isize) {
|
pub fn naked_with_args(a: isize) {
|
||||||
// CHECK-NEXT: {{.+}}:
|
// CHECK-NEXT: {{.+}}:
|
||||||
// CHECK-NEXT: %_1 = alloca i{{[0-9]+}}
|
// CHECK-NEXT: %a = alloca i{{[0-9]+}}
|
||||||
&a; // keep variable in an alloca
|
&a; // keep variable in an alloca
|
||||||
// CHECK: ret void
|
// CHECK: ret void
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ pub fn naked_with_return() -> isize {
|
|||||||
#[naked]
|
#[naked]
|
||||||
pub fn naked_with_args_and_return(a: isize) -> isize {
|
pub fn naked_with_args_and_return(a: isize) -> isize {
|
||||||
// CHECK-NEXT: {{.+}}:
|
// CHECK-NEXT: {{.+}}:
|
||||||
// CHECK-NEXT: %_1 = alloca i{{[0-9]+}}
|
// CHECK-NEXT: %a = alloca i{{[0-9]+}}
|
||||||
&a; // keep variable in an alloca
|
&a; // keep variable in an alloca
|
||||||
// CHECK: ret i{{[0-9]+}} %{{[0-9]+}}
|
// CHECK: ret i{{[0-9]+}} %{{[0-9]+}}
|
||||||
a
|
a
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
// min-lldb-version: 310
|
|
||||||
|
|
||||||
// We have to ignore android because of this issue:
|
|
||||||
// https://github.com/rust-lang/rust/issues/74847
|
|
||||||
// ignore-android
|
|
||||||
//
|
|
||||||
// We need to use inline assembly, so just use one platform
|
|
||||||
// only-x86_64
|
|
||||||
|
|
||||||
// compile-flags:-g
|
|
||||||
|
|
||||||
// === GDB TESTS ===================================================================================
|
|
||||||
|
|
||||||
// gdb-command:run
|
|
||||||
|
|
||||||
// gdb-command:info args
|
|
||||||
// gdb-check:No arguments.
|
|
||||||
// gdb-command:continue
|
|
||||||
|
|
||||||
// === LLDB TESTS ==================================================================================
|
|
||||||
|
|
||||||
// lldb-command:run
|
|
||||||
|
|
||||||
// lldb-command:frame variable
|
|
||||||
// lldbg-check:(unsigned long) = 111 (unsigned long) = 222
|
|
||||||
// lldbr-check:(unsigned long) = 111 (unsigned long) = 222
|
|
||||||
// lldb-command:continue
|
|
||||||
|
|
||||||
|
|
||||||
#![feature(asm)]
|
|
||||||
#![feature(naked_functions)]
|
|
||||||
#![feature(omit_gdb_pretty_printer_section)]
|
|
||||||
#![omit_gdb_pretty_printer_section]
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
naked(111, 222);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[naked]
|
|
||||||
extern "C" fn naked(x: usize, y: usize) {
|
|
||||||
unsafe { asm!("ret"); } // #break
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user