diff options
-rw-r--r-- | include/llvm/CodeGen/Passes.h | 6 | ||||
-rw-r--r-- | lib/CodeGen/LLVMTargetMachine.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/Passes.cpp | 11 | ||||
-rw-r--r-- | lib/Target/PTX/PTXTargetMachine.cpp | 2 |
4 files changed, 20 insertions, 1 deletions
diff --git a/include/llvm/CodeGen/Passes.h b/include/llvm/CodeGen/Passes.h index 8849571..7bc9311 100644 --- a/include/llvm/CodeGen/Passes.h +++ b/include/llvm/CodeGen/Passes.h @@ -39,6 +39,7 @@ class TargetPassConfig : public ImmutablePass { protected: TargetMachine *TM; PassManagerBase ± + bool Initialized; // Flagged after all passes are configured. // Target Pass Options // @@ -62,6 +63,8 @@ public: return TM->getTargetLowering(); } + void setInitialized() { Initialized = true; } + CodeGenOpt::Level getOptLevel() const { return TM->getOptLevel(); } void setDisableVerify(bool disable) { DisableVerify = disable; } @@ -84,6 +87,9 @@ public: /// Fully developed targets will not generally override this. virtual void addMachinePasses(); protected: + // Helper to verify the analysis is really immutable. + void setOpt(bool &Opt, bool Val); + /// Methods with trivial inline returns are convenient points in the common /// codegen pass pipeline where targets may insert passes. Methods with /// out-of-line standard implementations are major CodeGen stages called by diff --git a/lib/CodeGen/LLVMTargetMachine.cpp b/lib/CodeGen/LLVMTargetMachine.cpp index f07a85f..d14fbb2 100644 --- a/lib/CodeGen/LLVMTargetMachine.cpp +++ b/lib/CodeGen/LLVMTargetMachine.cpp @@ -147,6 +147,8 @@ static MCContext *addPassesToGenerateCode(LLVMTargetMachine *TM, PassConfig->addMachinePasses(); + PassConfig->setInitialized(); + return Context; } diff --git a/lib/CodeGen/Passes.cpp b/lib/CodeGen/Passes.cpp index 2877cf1..6d12dd8 100644 --- a/lib/CodeGen/Passes.cpp +++ b/lib/CodeGen/Passes.cpp @@ -84,7 +84,10 @@ char TargetPassConfig::ID = 0; TargetPassConfig::~TargetPassConfig() {} TargetPassConfig::TargetPassConfig(TargetMachine *tm, PassManagerBase &pm) - : ImmutablePass(ID), TM(tm), PM(pm), DisableVerify(false) { + : ImmutablePass(ID), TM(tm), PM(pm), Initialized(false), + DisableVerify(false), + EnableTailMerge(true) { + // Register all target independent codegen passes to activate their PassIDs, // including this pass itself. initializeCodeGen(*PassRegistry::getPassRegistry()); @@ -103,6 +106,12 @@ TargetPassConfig::TargetPassConfig() llvm_unreachable("TargetPassConfig should not be constructed on-the-fly"); } +// Helper to verify the analysis is really immutable. +void TargetPassConfig::setOpt(bool &Opt, bool Val) { + assert(!Initialized && "PassConfig is immutable"); + Opt = Val; +} + void TargetPassConfig::addPass(char &ID) { // FIXME: check user overrides Pass *P = Pass::createPass(ID); diff --git a/lib/Target/PTX/PTXTargetMachine.cpp b/lib/Target/PTX/PTXTargetMachine.cpp index 8901fa0..41bcfd5 100644 --- a/lib/Target/PTX/PTXTargetMachine.cpp +++ b/lib/Target/PTX/PTXTargetMachine.cpp @@ -385,5 +385,7 @@ bool PTXPassConfig::addCodeGenPasses(MCContext *&OutContext) { PM.add(createPTXMFInfoExtract(getPTXTargetMachine(), getOptLevel())); PM.add(createPTXFPRoundingModePass(getPTXTargetMachine(), getOptLevel())); + setInitialized(); + return false; } |