[llvm-commits] [llvm] r85790 - /llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
Chris Lattner
sabre at nondot.org
Sun Nov 1 22:11:24 PST 2009
Author: lattner
Date: Mon Nov 2 00:11:23 2009
New Revision: 85790
URL: http://llvm.org/viewvc/llvm-project?rev=85790&view=rev
Log:
avoid redundant lookups in BBExecutable, and make it a SmallPtrSet.
Modified:
llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=85790&r1=85789&r2=85790&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Mon Nov 2 00:11:23 2009
@@ -37,6 +37,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/STLExtras.h"
@@ -156,7 +157,7 @@
///
class SCCPSolver : public InstVisitor<SCCPSolver> {
const TargetData *TD;
- DenseSet<BasicBlock*> BBExecutable;// The basic blocks that are executable
+ SmallPtrSet<BasicBlock*, 8> BBExecutable;// The BBs that are executable.
DenseMap<Value*, LatticeVal> ValueState; // The state each value is in.
/// GlobalValue - If we are tracking any values for the contents of a global
@@ -200,10 +201,13 @@
/// MarkBlockExecutable - This method can be used by clients to mark all of
/// the blocks that are known to be intrinsically live in the processed unit.
- void MarkBlockExecutable(BasicBlock *BB) {
+ ///
+ /// This returns true if the block was not considered live before.
+ bool MarkBlockExecutable(BasicBlock *BB) {
+ if (!BBExecutable.insert(BB)) return false;
DEBUG(errs() << "Marking Block Executable: " << BB->getName() << "\n");
- BBExecutable.insert(BB); // Basic block is executable!
BBWorkList.push_back(BB); // Add the block to the work list!
+ return true;
}
/// TrackValueOfGlobalVariable - Clients can use this method to
@@ -348,18 +352,17 @@
if (!KnownFeasibleEdges.insert(Edge(Source, Dest)).second)
return; // This edge is already known to be executable!
- if (BBExecutable.count(Dest)) {
- DEBUG(errs() << "Marking Edge Executable: " << Source->getName()
- << " -> " << Dest->getName() << "\n");
-
- // The destination is already executable, but we just made an edge
+ if (!MarkBlockExecutable(Dest)) {
+ // If the destination is already executable, we just made an *edge*
// feasible that wasn't before. Revisit the PHI nodes in the block
// because they have potentially new operands.
- for (BasicBlock::iterator I = Dest->begin(); isa<PHINode>(I); ++I)
- visitPHINode(*cast<PHINode>(I));
+ DEBUG(errs() << "Marking Edge Executable: " << Source->getName()
+ << " -> " << Dest->getName() << "\n");
- } else {
- MarkBlockExecutable(Dest);
+ PHINode *PN;
+ for (BasicBlock::iterator I = Dest->begin();
+ (PN = dyn_cast<PHINode>(I)); ++I)
+ visitPHINode(*PN);
}
}
@@ -1229,8 +1232,7 @@
// Finally, if this is the first call to the function hit, mark its entry
// block executable.
- if (!BBExecutable.count(F->begin()))
- MarkBlockExecutable(F->begin());
+ MarkBlockExecutable(F->begin());
// Propagate information from this call site into the callee.
CallSite::arg_iterator CAI = CS.arg_begin();
More information about the llvm-commits
mailing list