[llvm-commits] CVS: llvm/lib/Transforms/Scalar/GVNPRE.cpp
Owen Anderson
resistor at mac.com
Fri Jun 15 17:27:16 PDT 2007
Changes in directory llvm/lib/Transforms/Scalar:
GVNPRE.cpp updated: 1.33 -> 1.34
---
Log message:
Fix test/Transforms/GVNPRE/2007-06-15-InvokeInst.ll by ignoring all instructions that depend on invokes.
---
Diffs of the changes: (+36 -3)
GVNPRE.cpp | 39 ++++++++++++++++++++++++++++++++++++---
1 files changed, 36 insertions(+), 3 deletions(-)
Index: llvm/lib/Transforms/Scalar/GVNPRE.cpp
diff -u llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.33 llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.34
--- llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.33 Fri Jun 15 12:55:15 2007
+++ llvm/lib/Transforms/Scalar/GVNPRE.cpp Fri Jun 15 19:26:54 2007
@@ -285,6 +285,33 @@
}
}
+bool dependsOnInvoke(Value* V) {
+ if (!isa<User>(V))
+ return false;
+
+ User* U = cast<User>(V);
+ std::vector<Value*> worklist(U->op_begin(), U->op_end());
+ std::set<Value*> visited;
+
+ while (!worklist.empty()) {
+ Value* current = worklist.back();
+ worklist.pop_back();
+ visited.insert(current);
+
+ if (!isa<User>(current))
+ continue;
+ else if (isa<InvokeInst>(current))
+ return true;
+
+ User* curr = cast<User>(current);
+ for (unsigned i = 0; i < curr->getNumOperands(); ++i)
+ if (visited.find(curr->getOperand(i)) == visited.end())
+ worklist.push_back(curr->getOperand(i));
+ }
+
+ return false;
+}
+
// Remove all expressions whose operands are not themselves in the set
void GVNPRE::clean(std::set<Value*, ExprLT>& set) {
std::vector<Value*> worklist;
@@ -302,6 +329,7 @@
lhsValid = true;
break;
}
+ lhsValid &= !dependsOnInvoke(BO->getOperand(0));
bool rhsValid = !isa<Instruction>(BO->getOperand(1));
if (!rhsValid)
@@ -311,6 +339,7 @@
rhsValid = true;
break;
}
+ rhsValid &= !dependsOnInvoke(BO->getOperand(1));
if (!lhsValid || !rhsValid)
set.erase(BO);
@@ -323,7 +352,8 @@
lhsValid = true;
break;
}
-
+ lhsValid &= !dependsOnInvoke(C->getOperand(0));
+
bool rhsValid = !isa<Instruction>(C->getOperand(1));
if (!rhsValid)
for (std::set<Value*, ExprLT>::iterator I = set.begin(), E = set.end();
@@ -332,6 +362,7 @@
rhsValid = true;
break;
}
+ rhsValid &= !dependsOnInvoke(C->getOperand(1));
if (!lhsValid || !rhsValid)
set.erase(C);
@@ -800,13 +831,15 @@
User* U = cast<User>(e2);
Value* s1 = 0;
- if (isa<Instruction>(U->getOperand(0)))
+ if (isa<BinaryOperator>(U->getOperand(0)) ||
+ isa<CmpInst>(U->getOperand(0)))
s1 = find_leader(availableOut[*PI], U->getOperand(0));
else
s1 = U->getOperand(0);
Value* s2 = 0;
- if (isa<Instruction>(U->getOperand(1)))
+ if (isa<BinaryOperator>(U->getOperand(1)) ||
+ isa<CmpInst>(U->getOperand(1)))
s2 = find_leader(availableOut[*PI], U->getOperand(1));
else
s2 = U->getOperand(1);
More information about the llvm-commits
mailing list