Skip to content

Commit 56b60e3

Browse files
committed
Don't begin defining a function when codegening a naked function
While LLVM is rather permissive in this regards, some other codegen backends demand that once you declare a function for definition you actually define contents of the function, which doesn't happen for naked functions as we actually generate assembly for them.
1 parent 86e330d commit 56b60e3

File tree

1 file changed

+5
-5
lines changed
  • compiler/rustc_codegen_ssa/src/mir

1 file changed

+5
-5
lines changed

compiler/rustc_codegen_ssa/src/mir/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,18 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
170170
) {
171171
assert!(!instance.args.has_infer());
172172

173-
let llfn = cx.get_fn(instance);
174-
175173
let mir = cx.tcx().instance_mir(instance.def);
176174

177-
let fn_abi = cx.fn_abi_of_instance(instance, ty::List::empty());
178-
debug!("fn_abi: {:?}", fn_abi);
179-
180175
if cx.tcx().codegen_fn_attrs(instance.def_id()).flags.contains(CodegenFnAttrFlags::NAKED) {
181176
crate::mir::naked_asm::codegen_naked_asm::<Bx>(cx, &mir, instance);
182177
return;
183178
}
184179

180+
let llfn = cx.get_fn(instance);
181+
182+
let fn_abi = cx.fn_abi_of_instance(instance, ty::List::empty());
183+
debug!("fn_abi: {:?}", fn_abi);
184+
185185
let debug_context = cx.create_function_debug_context(instance, fn_abi, llfn, mir);
186186

187187
let start_llbb = Bx::append_block(cx, llfn, "start");

0 commit comments

Comments
 (0)