summaryrefslogtreecommitdiff
path: root/lib/Analysis/LoopPass.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-22 05:37:10 +0000
committerChris Lattner <sabre@nondot.org>2010-01-22 05:37:10 +0000
commit77c95ed74a4d5f122b3c9810209a0190dbf17504 (patch)
treea6a71c265f8949172f5fad906174135524b02f31 /lib/Analysis/LoopPass.cpp
parent3660ecabbb85b31308f38938ce3f56f0a330a84b (diff)
downloadllvm-77c95ed74a4d5f122b3c9810209a0190dbf17504.tar.gz
llvm-77c95ed74a4d5f122b3c9810209a0190dbf17504.tar.bz2
llvm-77c95ed74a4d5f122b3c9810209a0190dbf17504.tar.xz
eliminate a bunch more unneeded dynamic_cast's.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94156 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/LoopPass.cpp')
-rw-r--r--lib/Analysis/LoopPass.cpp45
1 files changed, 18 insertions, 27 deletions
diff --git a/lib/Analysis/LoopPass.cpp b/lib/Analysis/LoopPass.cpp
index 43463cd8ef..2d613f6de7 100644
--- a/lib/Analysis/LoopPass.cpp
+++ b/lib/Analysis/LoopPass.cpp
@@ -147,8 +147,7 @@ void LPPassManager::redoLoop(Loop *L) {
void LPPassManager::cloneBasicBlockSimpleAnalysis(BasicBlock *From,
BasicBlock *To, Loop *L) {
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
- Pass *P = getContainedPass(Index);
- LoopPass *LP = dynamic_cast<LoopPass *>(P);
+ LoopPass *LP = (LoopPass *)getContainedPass(Index);
LP->cloneBasicBlockAnalysis(From, To, L);
}
}
@@ -163,8 +162,7 @@ void LPPassManager::deleteSimpleAnalysisValue(Value *V, Loop *L) {
}
}
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
- Pass *P = getContainedPass(Index);
- LoopPass *LP = dynamic_cast<LoopPass *>(P);
+ LoopPass *LP = (LoopPass *)getContainedPass(Index);
LP->deleteAnalysisValue(V, L);
}
}
@@ -206,10 +204,8 @@ bool LPPassManager::runOnFunction(Function &F) {
I != E; ++I) {
Loop *L = *I;
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
- Pass *P = getContainedPass(Index);
- LoopPass *LP = dynamic_cast<LoopPass *>(P);
- if (LP)
- Changed |= LP->doInitialization(L, *this);
+ LoopPass *P = (LoopPass*)getContainedPass(Index);
+ Changed |= P->doInitialization(L, *this);
}
}
@@ -222,7 +218,7 @@ bool LPPassManager::runOnFunction(Function &F) {
// Run all passes on the current Loop.
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
- Pass *P = getContainedPass(Index);
+ LoopPass *P = (LoopPass*)getContainedPass(Index);
dumpPassInfo(P, EXECUTION_MSG, ON_LOOP_MSG,
CurrentLoop->getHeader()->getNameStr());
@@ -230,12 +226,10 @@ bool LPPassManager::runOnFunction(Function &F) {
initializeAnalysisImpl(P);
- LoopPass *LP = dynamic_cast<LoopPass *>(P);
- assert(LP && "Invalid LPPassManager member");
{
- PassManagerPrettyStackEntry X(LP, *CurrentLoop->getHeader());
+ PassManagerPrettyStackEntry X(P, *CurrentLoop->getHeader());
Timer *T = StartPassTimer(P);
- Changed |= LP->runOnLoop(CurrentLoop, *this);
+ Changed |= P->runOnLoop(CurrentLoop, *this);
StopPassTimer(P, T);
}
@@ -256,7 +250,7 @@ bool LPPassManager::runOnFunction(Function &F) {
StopPassTimer(LI, T);
// Then call the regular verifyAnalysis functions.
- verifyPreservedAnalysis(LP);
+ verifyPreservedAnalysis(P);
}
removeNotPreservedAnalysis(P);
@@ -289,10 +283,8 @@ bool LPPassManager::runOnFunction(Function &F) {
// Finalization
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
- Pass *P = getContainedPass(Index);
- LoopPass *LP = dynamic_cast <LoopPass *>(P);
- if (LP)
- Changed |= LP->doFinalization();
+ LoopPass *P = (LoopPass *)getContainedPass(Index);
+ Changed |= P->doFinalization();
}
return Changed;
@@ -325,12 +317,11 @@ void LoopPass::preparePassManager(PMStack &PMS) {
PMS.top()->getPassManagerType() > PMT_LoopPassManager)
PMS.pop();
- LPPassManager *LPPM = dynamic_cast<LPPassManager *>(PMS.top());
-
// If this pass is destroying high level information that is used
// by other passes that are managed by LPM then do not insert
// this pass in current LPM. Use new LPPassManager.
- if (LPPM && !LPPM->preserveHigherLevelAnalysis(this))
+ if (PMS.top()->getPassManagerType() == PMT_LoopPassManager &&
+ !PMS.top()->preserveHigherLevelAnalysis(this))
PMS.pop();
}
@@ -342,11 +333,11 @@ void LoopPass::assignPassManager(PMStack &PMS,
PMS.top()->getPassManagerType() > PMT_LoopPassManager)
PMS.pop();
- LPPassManager *LPPM = dynamic_cast<LPPassManager *>(PMS.top());
-
- // Create new Loop Pass Manager if it does not exist.
- if (!LPPM) {
-
+ LPPassManager *LPPM;
+ if (PMS.top()->getPassManagerType() == PMT_LoopPassManager)
+ LPPM = (LPPassManager*)PMS.top();
+ else {
+ // Create new Loop Pass Manager if it does not exist.
assert (!PMS.empty() && "Unable to create Loop Pass Manager");
PMDataManager *PMD = PMS.top();
@@ -360,7 +351,7 @@ void LoopPass::assignPassManager(PMStack &PMS,
// [3] Assign manager to manage this new manager. This may create
// and push new managers into PMS
- Pass *P = dynamic_cast<Pass *>(LPPM);
+ Pass *P = LPPM->getAsPass();
TPM->schedulePass(P);
// [4] Push new manager into PMS