[llvm-commits] [llvm] r100126 - in /llvm/trunk: include/llvm/Transforms/Utils/SSAUpdater.h lib/Transforms/Utils/SSAUpdater.cpp
Bob Wilson
bob.wilson at apple.com
Thu Apr 1 11:47:00 PDT 2010
Author: bwilson
Date: Thu Apr 1 13:46:59 2010
New Revision: 100126
URL: http://llvm.org/viewvc/llvm-project?rev=100126&view=rev
Log:
The SSAUpdater should avoid recursive traversals of the CFG, since that may
blow out the stack for really big functions. Start by fixing an easy case.
Modified:
llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h
llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp
Modified: llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h?rev=100126&r1=100125&r2=100126&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h Thu Apr 1 13:46:59 2010
@@ -111,7 +111,7 @@
void FindExistingPHI(BasicBlock *BB, BBInfo *Info);
bool CheckIfPHIMatches(BasicBlock *BB, BBInfo *Info, Value *Val);
void RecordMatchingPHI(BasicBlock *BB, BBInfo *Info, PHINode *PHI);
- void ClearPHITags(BasicBlock *BB, BBInfo *Info, PHINode *PHI);
+ void ClearPHITags(PHINode *PHI);
void operator=(const SSAUpdater&); // DO NOT IMPLEMENT
SSAUpdater(const SSAUpdater&); // DO NOT IMPLEMENT
Modified: llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp?rev=100126&r1=100125&r2=100126&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Thu Apr 1 13:46:59 2010
@@ -427,7 +427,7 @@
RecordMatchingPHI(BB, Info, SomePHI);
break;
}
- ClearPHITags(BB, Info, SomePHI);
+ ClearPHITags(SomePHI);
}
}
@@ -490,20 +490,28 @@
}
/// ClearPHITags - When one of the existing PHI nodes fails to match, clear
-/// the PHITag values stored in the BBMap while checking to see if it matched.
-void SSAUpdater::ClearPHITags(BasicBlock *BB, BBInfo *Info, PHINode *PHI) {
- if (!Info || Info->AvailableVal || !Info->PHITag)
- return;
-
- // Clear the tag.
- Info->PHITag = 0;
-
- // Iterate through the predecessors.
+/// the PHITag values that were stored in the BBMap when checking to see if
+/// it matched.
+void SSAUpdater::ClearPHITags(PHINode *PHI) {
BBMapTy *BBMap = getBBMap(BM);
- for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) {
- PHINode *PHIVal = dyn_cast<PHINode>(PHI->getIncomingValue(i));
- if (!PHIVal) continue;
- BasicBlock *Pred = PHIVal->getParent();
- ClearPHITags(Pred, (*BBMap)[Pred], PHIVal);
+ SmallVector<PHINode*, 20> WorkList;
+ WorkList.push_back(PHI);
+
+ while (!WorkList.empty()) {
+ PHI = WorkList.pop_back_val();
+ BasicBlock *BB = PHI->getParent();
+ BBInfo *Info = (*BBMap)[BB];
+ if (!Info || Info->AvailableVal || !Info->PHITag)
+ continue;
+
+ // Clear the tag.
+ Info->PHITag = 0;
+
+ // Iterate through the PHI's incoming values.
+ for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) {
+ PHINode *IncomingVal = dyn_cast<PHINode>(PHI->getIncomingValue(i));
+ if (!IncomingVal) continue;
+ WorkList.push_back(IncomingVal);
+ }
}
}
More information about the llvm-commits
mailing list