Don't add extra passes into the function pass manager
Exception for specific cases like linting, additional passes should be going into the module pass manager (even if they are function passes). The separate function pass manager is only used for very early optimization passes. Rather than apparending passes to the MPM, use the OptimizerLast and EnabledOnOptLevel0 pass manager builder extension hooks, which allow adding passes directly before finalization (alias canonicalization and name-anon-globals). The main effect and purpose of this change is to add sanitizer passes at the end of the pipeline, which is where they belong. In LLVM 9 the address sanitizer can't be used as a pass in the early function pass manager, because it has a dependence on a module-level analysis pass.
This commit is contained in:
parent
2c102cb4ab
commit
a5c3956a75
3 changed files with 69 additions and 39 deletions
|
@ -99,6 +99,23 @@ void LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
|
|||
unwrap(PMBR)->populateThinLTOPassManager(*unwrap(PMR));
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void LLVMRustAddLastExtensionPasses(
|
||||
LLVMPassManagerBuilderRef PMBR, LLVMPassRef *Passes, size_t NumPasses) {
|
||||
auto AddExtensionPasses = [Passes, NumPasses](
|
||||
const PassManagerBuilder &Builder, PassManagerBase &PM) {
|
||||
for (size_t I = 0; I < NumPasses; I++) {
|
||||
PM.add(unwrap(Passes[I]));
|
||||
}
|
||||
};
|
||||
// Add the passes to both of the pre-finalization extension points,
|
||||
// so they are run for optimized and non-optimized builds.
|
||||
unwrap(PMBR)->addExtension(PassManagerBuilder::EP_OptimizerLast,
|
||||
AddExtensionPasses);
|
||||
unwrap(PMBR)->addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0,
|
||||
AddExtensionPasses);
|
||||
}
|
||||
|
||||
#ifdef LLVM_COMPONENT_X86
|
||||
#define SUBTARGET_X86 SUBTARGET(X86)
|
||||
#else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue