Further refactor optimization pass handling

This refactors pass handling to use the argument names, so it can be used
in a similar manner to `opt`. This may be slightly less efficient than the
previous version, but it is much easier to maintain.

It also adds in the ability to specify a custom pipeline on the command
line, this overrides the normal passes, however. This should completely
close #2396.
This commit is contained in:
James Miller
2013-05-29 20:08:20 +12:00
parent 4ad0b8ac58
commit faf1afee16
8 changed files with 320 additions and 495 deletions

View File

@@ -30,10 +30,20 @@ inline T *unwrap(LLVMPassRef P) {
return Q;
}
#define WRAP_PASS(name) \
extern "C" LLVMPassRef LLVMCreate##name##Pass() { \
return wrap(llvm::create##name##Pass()); \
}
extern "C" void LLVMInitializePasses() {
PassRegistry &Registry = *PassRegistry::getPassRegistry();
initializeCore(Registry);
initializeCodeGen(Registry);
initializeScalarOpts(Registry);
initializeVectorization(Registry);
initializeIPO(Registry);
initializeAnalysis(Registry);
initializeIPA(Registry);
initializeTransformUtils(Registry);
initializeInstCombine(Registry);
initializeInstrumentation(Registry);
initializeTarget(Registry);
}
extern "C" void LLVMAddPass(LLVMPassManagerRef PM, LLVMPassRef P) {
PassManagerBase * pm = unwrap(PM);
@@ -42,119 +52,14 @@ extern "C" void LLVMAddPass(LLVMPassManagerRef PM, LLVMPassRef P) {
pm->add(p);
}
////////////////
// Transforms //
// /////////////
extern "C" LLVMPassRef LLVMCreatePass(const char * PassName) {
StringRef SR(PassName);
PassRegistry * PR = PassRegistry::getPassRegistry();
// IPO Passes
WRAP_PASS(StripSymbols)
WRAP_PASS(StripNonDebugSymbols)
WRAP_PASS(StripDebugDeclare)
WRAP_PASS(StripDeadDebugInfo)
WRAP_PASS(ConstantMerge)
WRAP_PASS(GlobalOptimizer)
WRAP_PASS(GlobalDCE)
WRAP_PASS(AlwaysInliner)
WRAP_PASS(PruneEH)
WRAP_PASS(Internalize)
WRAP_PASS(DeadArgElimination)
WRAP_PASS(DeadArgHacking)
WRAP_PASS(ArgumentPromotion)
WRAP_PASS(IPConstantPropagation)
WRAP_PASS(IPSCCP)
WRAP_PASS(LoopExtractor)
WRAP_PASS(SingleLoopExtractor)
WRAP_PASS(BlockExtractor)
WRAP_PASS(StripDeadPrototypes)
WRAP_PASS(FunctionAttrs)
WRAP_PASS(MergeFunctions)
WRAP_PASS(PartialInlining)
WRAP_PASS(MetaRenamer)
WRAP_PASS(BarrierNoop)
extern "C" LLVMPassRef LLVMCreateFunctionInliningPass(int Threshold) {
return wrap(llvm::createFunctionInliningPass(Threshold));
const PassInfo * PI = PR->getPassInfo(SR);
if (PI) {
return wrap(PI->createPass());
} else {
return (LLVMPassRef)0;
}
}
// Instrumentation Passes
WRAP_PASS(EdgeProfiler)
WRAP_PASS(OptimalEdgeProfiler)
WRAP_PASS(PathProfiler)
WRAP_PASS(GCOVProfiler)
WRAP_PASS(BoundsChecking)
// Scalar Passes
WRAP_PASS(ConstantPropagation)
WRAP_PASS(SCCP)
WRAP_PASS(DeadInstElimination)
WRAP_PASS(DeadCodeElimination)
WRAP_PASS(DeadStoreElimination)
WRAP_PASS(AggressiveDCE)
WRAP_PASS(SROA)
WRAP_PASS(ScalarReplAggregates)
WRAP_PASS(IndVarSimplify)
WRAP_PASS(InstructionCombining)
WRAP_PASS(LICM)
WRAP_PASS(LoopStrengthReduce)
WRAP_PASS(GlobalMerge)
WRAP_PASS(LoopUnswitch)
WRAP_PASS(LoopInstSimplify)
WRAP_PASS(LoopUnroll)
WRAP_PASS(LoopRotate)
WRAP_PASS(LoopIdiom)
WRAP_PASS(PromoteMemoryToRegister)
WRAP_PASS(DemoteRegisterToMemory)
WRAP_PASS(Reassociate)
WRAP_PASS(JumpThreading)
WRAP_PASS(CFGSimplification)
WRAP_PASS(BreakCriticalEdges)
WRAP_PASS(LoopSimplify)
WRAP_PASS(TailCallElimination)
WRAP_PASS(LowerSwitch)
WRAP_PASS(LowerInvoke)
WRAP_PASS(BlockPlacement)
WRAP_PASS(LCSSA)
WRAP_PASS(EarlyCSE)
WRAP_PASS(GVN)
WRAP_PASS(MemCpyOpt)
WRAP_PASS(LoopDeletion)
WRAP_PASS(SimplifyLibCalls)
WRAP_PASS(CodeGenPrepare)
WRAP_PASS(InstructionNamer)
WRAP_PASS(Sinking)
WRAP_PASS(LowerAtomic)
WRAP_PASS(CorrelatedValuePropagation)
WRAP_PASS(InstructionSimplifier)
WRAP_PASS(LowerExpectIntrinsic)
// Vectorize Passes
WRAP_PASS(BBVectorize)
WRAP_PASS(LoopVectorize)
//////////////
// Analyses //
//////////////
WRAP_PASS(GlobalsModRef)
WRAP_PASS(AliasAnalysisCounter)
WRAP_PASS(AAEval)
WRAP_PASS(NoAA)
WRAP_PASS(BasicAliasAnalysis)
WRAP_PASS(ScalarEvolutionAliasAnalysis)
WRAP_PASS(TypeBasedAliasAnalysis)
WRAP_PASS(ProfileLoader)
WRAP_PASS(ProfileMetadataLoader)
WRAP_PASS(NoProfileInfo)
WRAP_PASS(ProfileEstimator)
WRAP_PASS(ProfileVerifier)
WRAP_PASS(PathProfileLoader)
WRAP_PASS(NoPathProfileInfo)
WRAP_PASS(PathProfileVerifier)
WRAP_PASS(LazyValueInfo)
WRAP_PASS(DependenceAnalysis)
WRAP_PASS(CostModelAnalysis)
WRAP_PASS(InstCount)
WRAP_PASS(RegionInfo)
WRAP_PASS(ModuleDebugInfoPrinter)
WRAP_PASS(Lint)
WRAP_PASS(Verifier)