Skip to content

Commit 850d2f1

Browse files
committed
Run name-anon-globals after all other passes
name-anon-globals should always be run at the very end of the pass pipeline, as optimization passes (in particular mergefunc) may introduce new anonymous globals. I believe we did not run into this earlier because it requires the rather specific combination of a) mergefunc merging two weak functions b) compilation not using thinlto.
1 parent cbf7489 commit 850d2f1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/librustc_codegen_llvm/back/write.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -371,15 +371,16 @@ pub(crate) unsafe fn optimize(cgcx: &CodegenContext<LlvmCodegenBackend>,
371371
.unwrap_or(llvm::CodeGenOptLevel::None);
372372
let prepare_for_thin_lto = cgcx.lto == Lto::Thin || cgcx.lto == Lto::ThinLocal ||
373373
(cgcx.lto != Lto::Fat && cgcx.opts.debugging_opts.cross_lang_lto.enabled());
374+
with_llvm_pmb(llmod, &config, opt_level, prepare_for_thin_lto, &mut |b| {
375+
llvm::LLVMPassManagerBuilderPopulateFunctionPassManager(b, fpm);
376+
llvm::LLVMPassManagerBuilderPopulateModulePassManager(b, mpm);
377+
});
378+
374379
have_name_anon_globals_pass = have_name_anon_globals_pass || prepare_for_thin_lto;
375380
if using_thin_buffers && !prepare_for_thin_lto {
376381
assert!(addpass("name-anon-globals"));
377382
have_name_anon_globals_pass = true;
378383
}
379-
with_llvm_pmb(llmod, &config, opt_level, prepare_for_thin_lto, &mut |b| {
380-
llvm::LLVMPassManagerBuilderPopulateFunctionPassManager(b, fpm);
381-
llvm::LLVMPassManagerBuilderPopulateModulePassManager(b, mpm);
382-
})
383384
}
384385

385386
for pass in &config.passes {

0 commit comments

Comments
 (0)