Skip to content

Commit 0356bb9

Browse files
committed
Revert "Suppress debuginfo on naked function arguments"
This reverts commit 2567074. 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.
1 parent cbe7c5c commit 0356bb9

File tree

3 files changed

+3
-55
lines changed

3 files changed

+3
-55
lines changed

src/librustc_mir_build/build/mod.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use rustc_hir::lang_items;
1010
use rustc_hir::{GeneratorKind, HirIdMap, Node};
1111
use rustc_index::vec::{Idx, IndexVec};
1212
use rustc_infer::infer::TyCtxtInferExt;
13-
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
1413
use rustc_middle::middle::region;
1514
use rustc_middle::mir::*;
1615
use rustc_middle::ty::subst::Subst;
@@ -798,22 +797,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
798797
argument_scope: region::Scope,
799798
ast_body: &'tcx hir::Expr<'tcx>,
800799
) -> BlockAnd<()> {
801-
let tcx = self.hir.tcx();
802-
let attrs = tcx.codegen_fn_attrs(fn_def_id);
803-
let naked = attrs.flags.contains(CodegenFnAttrFlags::NAKED);
804-
805800
// Allocate locals for the function arguments
806801
for &ArgInfo(ty, _, arg_opt, _) in arguments.iter() {
807802
let source_info =
808803
SourceInfo::outermost(arg_opt.map_or(self.fn_span, |arg| arg.pat.span));
809804
let arg_local = self.local_decls.push(LocalDecl::with_source_info(ty, source_info));
810805

811-
// Emit function argument debuginfo only for non-naked functions.
812-
// See: https://github.com/rust-lang/rust/issues/42779
813-
if naked {
814-
continue;
815-
}
816-
817806
// If this is a simple binding pattern, give debuginfo a nice name.
818807
if let Some(arg) = arg_opt {
819808
if let Some(ident) = arg.pat.simple_ident() {
@@ -826,6 +815,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
826815
}
827816
}
828817

818+
let tcx = self.hir.tcx();
829819
let tcx_hir = tcx.hir();
830820
let hir_typeck_results = self.hir.typeck_results();
831821

src/test/codegen/naked-functions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub fn naked_empty() {
1818
// CHECK-NEXT: define void @naked_with_args(i{{[0-9]+( %0)?}})
1919
pub fn naked_with_args(a: isize) {
2020
// CHECK-NEXT: {{.+}}:
21-
// CHECK-NEXT: %_1 = alloca i{{[0-9]+}}
21+
// CHECK-NEXT: %a = alloca i{{[0-9]+}}
2222
&a; // keep variable in an alloca
2323
// CHECK: ret void
2424
}
@@ -39,7 +39,7 @@ pub fn naked_with_return() -> isize {
3939
#[naked]
4040
pub fn naked_with_args_and_return(a: isize) -> isize {
4141
// CHECK-NEXT: {{.+}}:
42-
// CHECK-NEXT: %_1 = alloca i{{[0-9]+}}
42+
// CHECK-NEXT: %a = alloca i{{[0-9]+}}
4343
&a; // keep variable in an alloca
4444
// CHECK: ret i{{[0-9]+}} %{{[0-9]+}}
4545
a

src/test/debuginfo/function-arguments-naked.rs

-42
This file was deleted.

0 commit comments

Comments
 (0)