summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/PredicateSimplifier.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2007-01-13 02:05:28 +0000
committerNick Lewycky <nicholas@mxc.ca>2007-01-13 02:05:28 +0000
commit0be7f47735c15818493db1e11b63c6baad575cfa (patch)
treeb2c7f8228c90e7683ff13adf0e88bb36756d2170 /lib/Transforms/Scalar/PredicateSimplifier.cpp
parenta1fed2d1c0494e4fe460582c62213facfbaaf78a (diff)
downloadllvm-0be7f47735c15818493db1e11b63c6baad575cfa.tar.gz
llvm-0be7f47735c15818493db1e11b63c6baad575cfa.tar.bz2
llvm-0be7f47735c15818493db1e11b63c6baad575cfa.tar.xz
"Default context" blocks can occur after a non-default one. This meant
that properties were being applied where they didn't belong. Fixes crash in new MiBench testcase. Also mark debugging code as such in #ifdef. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33177 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/PredicateSimplifier.cpp')
-rw-r--r--lib/Transforms/Scalar/PredicateSimplifier.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/Transforms/Scalar/PredicateSimplifier.cpp b/lib/Transforms/Scalar/PredicateSimplifier.cpp
index 33dee09098..0191fe3391 100644
--- a/lib/Transforms/Scalar/PredicateSimplifier.cpp
+++ b/lib/Transforms/Scalar/PredicateSimplifier.cpp
@@ -721,7 +721,8 @@ namespace {
Value *LHS, *RHS;
ICmpInst::Predicate Op;
- Instruction *Context;
+ BasicBlock *ContextBB;
+ Instruction *ContextInst;
};
std::deque<Operation> WorkList;
@@ -1075,7 +1076,8 @@ namespace {
WorkList.push_back(Operation());
Operation &O = WorkList.back();
- O.LHS = V1, O.RHS = V2, O.Op = Pred, O.Context = I;
+ O.LHS = V1, O.RHS = V2, O.Op = Pred, O.ContextInst = I;
+ O.ContextBB = I ? I->getParent() : TopBB;
}
/// defToOps - Given an instruction definition that we've learned something
@@ -1306,10 +1308,10 @@ namespace {
//DOUT << "WorkList size: " << WorkList.size() << "\n";
Operation &O = WorkList.front();
- if (O.Context) {
- TopInst = O.Context;
- Top = Forest->getNodeForBlock(TopInst->getParent());
- }
+ TopInst = O.ContextInst;
+ TopBB = O.ContextBB;
+ Top = Forest->getNodeForBlock(TopBB);
+
O.LHS = IG.canonicalize(O.LHS, Top);
O.RHS = IG.canonicalize(O.RHS, Top);
@@ -1317,8 +1319,8 @@ namespace {
assert(O.RHS == IG.canonicalize(O.RHS, Top) && "Canonicalize isn't.");
DOUT << "solving " << *O.LHS << " " << O.Op << " " << *O.RHS;
- if (O.Context) DOUT << " context: " << *O.Context;
- else DOUT << " default context";
+ if (O.ContextInst) DOUT << " context inst: " << *O.ContextInst;
+ else DOUT << " context block: " << O.ContextBB->getName();
DOUT << "\n";
DEBUG(IG.dump());
@@ -1485,6 +1487,7 @@ namespace {
return;
}
+#ifndef NDEBUG
// Try to replace the whole instruction.
Value *V = IG->canonicalize(I, ET);
assert(V == I && "Late instruction canonicalization.");
@@ -1511,6 +1514,7 @@ namespace {
DOUT << " into " << *I;
}
}
+#endif
DOUT << "push (%" << I->getParent()->getName() << ")\n";
Forwards visit(this, DT);