mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-03 14:31:10 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103425 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
da24b34c9a
commit
e89f1c4ee7
@ -60,6 +60,9 @@ public:
|
|||||||
bool run(Module &M);
|
bool run(Module &M);
|
||||||
|
|
||||||
private:
|
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
|
/// PassManagerImpl_New is the actual class. PassManager is just the
|
||||||
/// wraper to publish simple pass manager interface
|
/// wraper to publish simple pass manager interface
|
||||||
@ -96,6 +99,10 @@ public:
|
|||||||
bool doFinalization();
|
bool doFinalization();
|
||||||
|
|
||||||
private:
|
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;
|
FunctionPassManagerImpl *FPM;
|
||||||
Module *M;
|
Module *M;
|
||||||
};
|
};
|
||||||
|
@ -275,7 +275,7 @@ public:
|
|||||||
addImmutablePass(IP);
|
addImmutablePass(IP);
|
||||||
recordAvailableAnalysis(IP);
|
recordAvailableAnalysis(IP);
|
||||||
} else {
|
} else {
|
||||||
P->assignPassManager(activeStack);
|
P->assignPassManager(activeStack, PMT_FunctionPassManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -418,7 +418,7 @@ public:
|
|||||||
addImmutablePass(IP);
|
addImmutablePass(IP);
|
||||||
recordAvailableAnalysis(IP);
|
recordAvailableAnalysis(IP);
|
||||||
} else {
|
} else {
|
||||||
P->assignPassManager(activeStack);
|
P->assignPassManager(activeStack, PMT_ModulePassManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1270,19 +1270,29 @@ FunctionPassManager::~FunctionPassManager() {
|
|||||||
delete FPM;
|
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
|
/// add - Add a pass to the queue of passes to run. This passes
|
||||||
/// ownership of the Pass to the PassManager. When the
|
/// ownership of the Pass to the PassManager. When the
|
||||||
/// PassManager_X is destroyed, the pass will be destroyed as well, so
|
/// PassManager_X is destroyed, the pass will be destroyed as well, so
|
||||||
/// there is no need to delete the pass. (TODO delete passes.)
|
/// there is no need to delete the pass. (TODO delete passes.)
|
||||||
/// This implies that all passes MUST be allocated with 'new'.
|
/// This implies that all passes MUST be allocated with 'new'.
|
||||||
void FunctionPassManager::add(Pass *P) {
|
void FunctionPassManager::add(Pass *P) {
|
||||||
|
// If this is a not a function pass, don't add a printer for it.
|
||||||
|
if (P->getPassKind() == PT_Function)
|
||||||
if (ShouldPrintBeforePass(P))
|
if (ShouldPrintBeforePass(P))
|
||||||
add(P->createPrinterPass(dbgs(), std::string("*** IR Dump Before ")
|
addImpl(P->createPrinterPass(dbgs(), std::string("*** IR Dump Before ")
|
||||||
+ P->getPassName() + " ***"));
|
+ P->getPassName() + " ***"));
|
||||||
FPM->add(P);
|
|
||||||
|
|
||||||
|
addImpl(P);
|
||||||
|
|
||||||
|
if (P->getPassKind() == PT_Function)
|
||||||
if (ShouldPrintAfterPass(P))
|
if (ShouldPrintAfterPass(P))
|
||||||
add(P->createPrinterPass(dbgs(), std::string("*** IR Dump After ")
|
addImpl(P->createPrinterPass(dbgs(), std::string("*** IR Dump After ")
|
||||||
+ P->getPassName() + " ***"));
|
+ P->getPassName() + " ***"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1588,19 +1598,25 @@ PassManager::~PassManager() {
|
|||||||
delete PM;
|
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
|
/// 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
|
/// 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
|
/// will be destroyed as well, so there is no need to delete the pass. This
|
||||||
/// implies that all passes MUST be allocated with 'new'.
|
/// implies that all passes MUST be allocated with 'new'.
|
||||||
void PassManager::add(Pass *P) {
|
void PassManager::add(Pass *P) {
|
||||||
if (ShouldPrintBeforePass(P))
|
if (ShouldPrintBeforePass(P))
|
||||||
add(P->createPrinterPass(dbgs(), std::string("*** IR Dump Before ")
|
addImpl(P->createPrinterPass(dbgs(), std::string("*** IR Dump Before ")
|
||||||
+ P->getPassName() + " ***"));
|
+ P->getPassName() + " ***"));
|
||||||
|
|
||||||
PM->add(P);
|
addImpl(P);
|
||||||
|
|
||||||
if (ShouldPrintAfterPass(P))
|
if (ShouldPrintAfterPass(P))
|
||||||
add(P->createPrinterPass(dbgs(), std::string("*** IR Dump After ")
|
addImpl(P->createPrinterPass(dbgs(), std::string("*** IR Dump After ")
|
||||||
+ P->getPassName() + " ***"));
|
+ P->getPassName() + " ***"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1764,7 +1780,7 @@ void BasicBlockPass::assignPassManager(PMStack &PMS,
|
|||||||
|
|
||||||
// [3] Assign manager to manage this new manager. This may create
|
// [3] Assign manager to manage this new manager. This may create
|
||||||
// and push new managers into PMS
|
// and push new managers into PMS
|
||||||
BBP->assignPassManager(PMS);
|
BBP->assignPassManager(PMS, PreferredType);
|
||||||
|
|
||||||
// [4] Push new manager into PMS
|
// [4] Push new manager into PMS
|
||||||
PMS.push(BBP);
|
PMS.push(BBP);
|
||||||
|
6
test/Other/2010-05-60-Printer.ll
Normal file
6
test/Other/2010-05-60-Printer.ll
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
; RUN: llc -O2 -print-after-all < %s 2>@1
|
||||||
|
|
||||||
|
define void @tester(){
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user