Skip to content

Commit

Permalink
Auto-upgrade intrinsics
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Jan 6, 2020
1 parent 1350854 commit d2959c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ pub(crate) unsafe fn optimize(
.map(|path_buf| CString::new(path_buf.to_string_lossy().as_bytes()).unwrap());

// FIXME: NewPM doesn't seem to have a facility to provide custom InlineParams.
// FIXME: Extra passes.
// FIXME: Support extra passes.
llvm::LLVMRustOptimizeWithNewPassManager(
llmod,
tm,
Expand Down
8 changes: 4 additions & 4 deletions src/rustllvm/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,12 +628,10 @@ LLVMRustOptimizeWithNewPassManager(
PTO.LoopVectorization = LoopVectorize;
PTO.SLPVectorization = SLPVectorize;

// FIXME: What's this?
PassInstrumentationCallbacks PIC;
StandardInstrumentations SI;
SI.registerCallbacks(PIC);

// FIXME: PGOOpt
Optional<PGOOptions> PGOOpt;
if (PGOGenPath) {
assert(!PGOUsePath);
Expand Down Expand Up @@ -736,14 +734,12 @@ LLVMRustOptimizeWithNewPassManager(
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));

MPM.addPass(AlwaysInlinerPass(/*InsertLifetimeIntrinsics=*/false));
// FIXME: PGO?
} else {
for (const auto &C : PipelineStartEPCallbacks)
PB.registerPipelineStartEPCallback(C);
for (const auto &C : OptimizerLastEPCallbacks)
PB.registerOptimizerLastEPCallback(C);

// FIXME: Sanitizers? PGO?
if (PrepareForThinLTO) {
MPM = PB.buildThinLTOPreLinkDefaultPipeline(OptLevel, DebugPassManager);
} else if (PrepareForLTO) {
Expand All @@ -759,6 +755,10 @@ LLVMRustOptimizeWithNewPassManager(
MPM.addPass(NameAnonGlobalPass());
}

// Upgrade all calls to old intrinsics first.
for (Module::iterator I = TheModule->begin(), E = TheModule->end(); I != E;)
UpgradeCallsToIntrinsic(&*I++); // must be post-increment, as we remove

MPM.run(*TheModule, MAM);
}

Expand Down

0 comments on commit d2959c3

Please sign in to comment.