summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2012-02-08 21:22:39 +0000
committerAndrew Trick <atrick@apple.com>2012-02-08 21:22:39 +0000
commitffea03f2165c5a4fda672495bf853aa2d8c7d1b5 (patch)
tree64ffa416f3803f75a86ee55727d19fb1419a6d6a
parentebe18ef5c286bb7c33f6c43f1963a7d22cd73f40 (diff)
downloadllvm-ffea03f2165c5a4fda672495bf853aa2d8c7d1b5.tar.gz
llvm-ffea03f2165c5a4fda672495bf853aa2d8c7d1b5.tar.bz2
llvm-ffea03f2165c5a4fda672495bf853aa2d8c7d1b5.tar.xz
Added TargetPassConfig::setOpt
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150093 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/CodeGen/Passes.h6
-rw-r--r--lib/CodeGen/LLVMTargetMachine.cpp2
-rw-r--r--lib/CodeGen/Passes.cpp11
-rw-r--r--lib/Target/PTX/PTXTargetMachine.cpp2
4 files changed, 20 insertions, 1 deletions
diff --git a/include/llvm/CodeGen/Passes.h b/include/llvm/CodeGen/Passes.h
index 8849571731..7bc93114d6 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 &PM;
+ 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 f07a85f39c..d14fbb2c33 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 2877cf165b..6d12dd839c 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 8901fa0b97..41bcfd564d 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;
}