Stream: t-compiler/help

Topic: naked fn codegen


Nathaniel McCallum (Jul 06 2020 at 14:02, on Zulip):

I'm trying to take a stab at fixing https://github.com/rust-lang/rust/issues/42779 by suppressing debug output for the naked fn's parameters.

Nathaniel McCallum (Jul 06 2020 at 14:03, on Zulip):

I figure I could do it a couple of places.

Nathaniel McCallum (Jul 06 2020 at 14:03, on Zulip):

https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs#L16-L42

Nathaniel McCallum (Jul 06 2020 at 14:04, on Zulip):

https://github.com/rust-lang/rust/blob/master/src/librustc_mir_build/build/mod.rs#L793-L809

Nathaniel McCallum (Jul 06 2020 at 14:05, on Zulip):

I think the first one is probably the most reasonable since we don't know how other backends will behave.

Nathaniel McCallum (Jul 06 2020 at 14:06, on Zulip):

I can't figure out, however, how to get the function definition in that scope so that I can inspect its attributes.

Nathaniel McCallum (Jul 06 2020 at 14:06, on Zulip):

Help?

bjorn3 (Jul 06 2020 at 14:13, on Zulip):

tcx.codegen_fn_attrs

Nathaniel McCallum (Jul 06 2020 at 16:02, on Zulip):

@bjorn3 I'm not seeing that. What am I missing?

bjorn3 (Jul 06 2020 at 16:10, on Zulip):

@Nathaniel McCallum self.hir.tcx().codegen_fn_attrs(fn_def_id) returns a CodegenFnAttrs, which has a flags field which has a CodegenFnAttrFlags::NAKED flag.

Nathaniel McCallum (Jul 06 2020 at 16:10, on Zulip):

@bjorn3 Awesome, thanks!

Nathaniel McCallum (Jul 06 2020 at 19:25, on Zulip):

@bjorn3 Thanks for the help. It was exactly what I needed! https://github.com/rust-lang/rust/pull/74105

Amanieu (Jul 09 2020 at 12:44, on Zulip):

We shouldn't be emitting any alloca calls at all in naked functions. They cause incorrect codegen in debug builds.

Last update: Sep 28 2020 at 16:15UTC