[llvm-commits] [llvm] r51295 - in /llvm/trunk: include/llvm/Analysis/SparsePropagation.h lib/Analysis/SparsePropagation.cpp
Chris Lattner
sabre at nondot.org
Mon May 19 20:39:39 PDT 2008
Author: lattner
Date: Mon May 19 22:39:39 2008
New Revision: 51295
URL: http://llvm.org/viewvc/llvm-project?rev=51295&view=rev
Log:
Add a bool to isEdgeFeasible that tells it whether to treat unknown
value as undef or untracked.
Modified:
llvm/trunk/include/llvm/Analysis/SparsePropagation.h
llvm/trunk/lib/Analysis/SparsePropagation.cpp
Modified: llvm/trunk/include/llvm/Analysis/SparsePropagation.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/SparsePropagation.h?rev=51295&r1=51294&r2=51295&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/SparsePropagation.h (original)
+++ llvm/trunk/include/llvm/Analysis/SparsePropagation.h Mon May 19 22:39:39 2008
@@ -147,8 +147,12 @@
LatticeVal getOrInitValueState(Value *V);
/// isEdgeFeasible - Return true if the control flow edge from the 'From'
- /// basic block to the 'To' basic block is currently feasible...
- bool isEdgeFeasible(BasicBlock *From, BasicBlock *To);
+ /// basic block to the 'To' basic block is currently feasible. If
+ /// AggressiveUndef is true, then this treats values with unknown lattice
+ /// values as undefined. This is generally only useful when solving the
+ /// lattice, not when querying it.
+ bool isEdgeFeasible(BasicBlock *From, BasicBlock *To,
+ bool AggressiveUndef = false);
private:
/// UpdateState - When the state for some instruction is potentially updated,
@@ -165,7 +169,8 @@
/// getFeasibleSuccessors - Return a vector of booleans to indicate which
/// successors are reachable from a given terminator instruction.
- void getFeasibleSuccessors(TerminatorInst &TI, SmallVectorImpl<bool> &Succs);
+ void getFeasibleSuccessors(TerminatorInst &TI, SmallVectorImpl<bool> &Succs,
+ bool AggressiveUndef);
void visitInst(Instruction &I);
void visitPHINode(PHINode &I);
Modified: llvm/trunk/lib/Analysis/SparsePropagation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/SparsePropagation.cpp?rev=51295&r1=51294&r2=51295&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/SparsePropagation.cpp (original)
+++ llvm/trunk/lib/Analysis/SparsePropagation.cpp Mon May 19 22:39:39 2008
@@ -115,7 +115,8 @@
/// getFeasibleSuccessors - Return a vector of booleans to indicate which
/// successors are reachable from a given terminator instruction.
void SparseSolver::getFeasibleSuccessors(TerminatorInst &TI,
- SmallVectorImpl<bool> &Succs) {
+ SmallVectorImpl<bool> &Succs,
+ bool AggressiveUndef) {
Succs.resize(TI.getNumSuccessors());
if (TI.getNumSuccessors() == 0) return;
@@ -125,7 +126,12 @@
return;
}
- LatticeVal BCValue = getOrInitValueState(BI->getCondition());
+ LatticeVal BCValue;
+ if (AggressiveUndef)
+ BCValue = getOrInitValueState(BI->getCondition());
+ else
+ BCValue = getLatticeState(BI->getCondition());
+
if (BCValue == LatticeFunc->getOverdefinedVal() ||
BCValue == LatticeFunc->getUntrackedVal()) {
// Overdefined condition variables can branch either way.
@@ -157,7 +163,12 @@
}
SwitchInst &SI = cast<SwitchInst>(TI);
- LatticeVal SCValue = getOrInitValueState(SI.getCondition());
+ LatticeVal SCValue;
+ if (AggressiveUndef)
+ SCValue = getOrInitValueState(SI.getCondition());
+ else
+ SCValue = getLatticeState(SI.getCondition());
+
if (SCValue == LatticeFunc->getOverdefinedVal() ||
SCValue == LatticeFunc->getUntrackedVal()) {
// All destinations are executable!
@@ -182,10 +193,11 @@
/// isEdgeFeasible - Return true if the control flow edge from the 'From'
/// basic block to the 'To' basic block is currently feasible...
-bool SparseSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To) {
+bool SparseSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To,
+ bool AggressiveUndef) {
SmallVector<bool, 16> SuccFeasible;
TerminatorInst *TI = From->getTerminator();
- getFeasibleSuccessors(*TI, SuccFeasible);
+ getFeasibleSuccessors(*TI, SuccFeasible, AggressiveUndef);
for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i)
if (TI->getSuccessor(i) == To && SuccFeasible[i])
@@ -196,7 +208,7 @@
void SparseSolver::visitTerminatorInst(TerminatorInst &TI) {
SmallVector<bool, 16> SuccFeasible;
- getFeasibleSuccessors(TI, SuccFeasible);
+ getFeasibleSuccessors(TI, SuccFeasible, true);
BasicBlock *BB = TI.getParent();
@@ -226,7 +238,7 @@
// transfer function to give us the merge of the incoming values.
for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) {
// If the edge is not yet known to be feasible, it doesn't impact the PHI.
- if (!isEdgeFeasible(PN.getIncomingBlock(i), PN.getParent()))
+ if (!isEdgeFeasible(PN.getIncomingBlock(i), PN.getParent(), true))
continue;
// Merge in this value.
More information about the llvm-commits
mailing list