summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2010-05-10 20:24:27 +0000
committerDavid Greene <greened@obbligato.org>2010-05-10 20:24:27 +0000
commit103d4b43e9c19baab8db0388f72aa86bf013ec9e (patch)
tree4a0c1c429772abffeb88e69f195245ec6599df52
parentfd9048b5107b4ba9a593db69919123481a27bb6c (diff)
downloadbcm5719-llvm-103d4b43e9c19baab8db0388f72aa86bf013ec9e.tar.gz
bcm5719-llvm-103d4b43e9c19baab8db0388f72aa86bf013ec9e.zip
Fix PR6875:
This includes a patch by Roman Divacky to fix the initial crash. Move the actual addition of passes from *PassManager::add to *PassManager::addImpl. That way, when adding printer passes we won't recurse infinitely. Finally, check to make sure that we are actually adding a FunctionPass to a FunctionPassManager before doing a print before or after it. Immutable passes are strange in this way because they aren't FunctionPasses yet they can be and are added to the FunctionPassManager. llvm-svn: 103425
-rw-r--r--llvm/include/llvm/PassManager.h7
-rw-r--r--llvm/lib/VMCore/PassManager.cpp46
-rw-r--r--llvm/test/Other/2010-05-60-Printer.ll6
3 files changed, 44 insertions, 15 deletions
diff --git a/llvm/include/llvm/PassManager.h b/llvm/include/llvm/PassManager.h
index 4d9116311a0..8de0f8342d7 100644
--- a/llvm/include/llvm/PassManager.h
+++ b/llvm/include/llvm/PassManager.h
@@ -60,6 +60,9 @@ public:
bool run(Module &M);
private:
+ /// addImpl - Add a pass to the queue of passes to run, without
+ /// checking whether to add a printer pass.
+ void addImpl(Pass *P);
/// PassManagerImpl_New is the actual class. PassManager is just the
/// wraper to publish simple pass manager interface
@@ -96,6 +99,10 @@ public:
bool doFinalization();
private:
+ /// addImpl - Add a pass to the queue of passes to run, without
+ /// checking whether to add a printer pass.
+ void addImpl(Pass *P);
+
FunctionPassManagerImpl *FPM;
Module *M;
};
diff --git a/llvm/lib/VMCore/PassManager.cpp b/llvm/lib/VMCore/PassManager.cpp
index b28fdebd523..a56938c1592 100644
--- a/llvm/lib/VMCore/PassManager.cpp
+++ b/llvm/lib/VMCore/PassManager.cpp
@@ -275,7 +275,7 @@ public:
addImmutablePass(IP);
recordAvailableAnalysis(IP);
} else {
- P->assignPassManager(activeStack);
+ P->assignPassManager(activeStack, PMT_FunctionPassManager);
}
}
@@ -418,7 +418,7 @@ public:
addImmutablePass(IP);
recordAvailableAnalysis(IP);
} else {
- P->assignPassManager(activeStack);
+ P->assignPassManager(activeStack, PMT_ModulePassManager);
}
}
@@ -1270,20 +1270,30 @@ FunctionPassManager::~FunctionPassManager() {
delete FPM;
}
+/// addImpl - Add a pass to the queue of passes to run, without
+/// checking whether to add a printer pass.
+void FunctionPassManager::addImpl(Pass *P) {
+ FPM->add(P);
+}
+
/// add - Add a pass to the queue of passes to run. This passes
/// ownership of the Pass to the PassManager. When the
/// PassManager_X is destroyed, the pass will be destroyed as well, so
/// there is no need to delete the pass. (TODO delete passes.)
/// This implies that all passes MUST be allocated with 'new'.
void FunctionPassManager::add(Pass *P) {
- if (ShouldPrintBeforePass(P))
- add(P->createPrinterPass(dbgs(), std::string("*** IR Dump Before ")
- + P->getPassName() + " ***"));
- FPM->add(P);
+ // If this is a not a function pass, don't add a printer for it.
+ if (P->getPassKind() == PT_Function)
+ if (ShouldPrintBeforePass(P))
+ addImpl(P->createPrinterPass(dbgs(), std::string("*** IR Dump Before ")
+ + P->getPassName() + " ***"));
- if (ShouldPrintAfterPass(P))
- add(P->createPrinterPass(dbgs(), std::string("*** IR Dump After ")
- + P->getPassName() + " ***"));
+ addImpl(P);
+
+ if (P->getPassKind() == PT_Function)
+ if (ShouldPrintAfterPass(P))
+ addImpl(P->createPrinterPass(dbgs(), std::string("*** IR Dump After ")
+ + P->getPassName() + " ***"));
}
/// run - Execute all of the passes scheduled for execution. Keep
@@ -1588,20 +1598,26 @@ PassManager::~PassManager() {
delete PM;
}
+/// addImpl - Add a pass to the queue of passes to run, without
+/// checking whether to add a printer pass.
+void PassManager::addImpl(Pass *P) {
+ PM->add(P);
+}
+
/// add - Add a pass to the queue of passes to run. This passes ownership of
/// the Pass to the PassManager. When the PassManager is destroyed, the pass
/// will be destroyed as well, so there is no need to delete the pass. This
/// implies that all passes MUST be allocated with 'new'.
void PassManager::add(Pass *P) {
if (ShouldPrintBeforePass(P))
- add(P->createPrinterPass(dbgs(), std::string("*** IR Dump Before ")
- + P->getPassName() + " ***"));
+ addImpl(P->createPrinterPass(dbgs(), std::string("*** IR Dump Before ")
+ + P->getPassName() + " ***"));
- PM->add(P);
+ addImpl(P);
if (ShouldPrintAfterPass(P))
- add(P->createPrinterPass(dbgs(), std::string("*** IR Dump After ")
- + P->getPassName() + " ***"));
+ addImpl(P->createPrinterPass(dbgs(), std::string("*** IR Dump After ")
+ + P->getPassName() + " ***"));
}
/// run - Execute all of the passes scheduled for execution. Keep track of
@@ -1764,7 +1780,7 @@ void BasicBlockPass::assignPassManager(PMStack &PMS,
// [3] Assign manager to manage this new manager. This may create
// and push new managers into PMS
- BBP->assignPassManager(PMS);
+ BBP->assignPassManager(PMS, PreferredType);
// [4] Push new manager into PMS
PMS.push(BBP);
diff --git a/llvm/test/Other/2010-05-60-Printer.ll b/llvm/test/Other/2010-05-60-Printer.ll
new file mode 100644
index 00000000000..9ead740a51f
--- /dev/null
+++ b/llvm/test/Other/2010-05-60-Printer.ll
@@ -0,0 +1,6 @@
+; RUN: llc -O2 -print-after-all < %s 2>@1
+
+define void @tester(){
+ ret void
+}
+
OpenPOWER on IntegriCloud