Teach IndVarSimplify's FixUsesBeforeDefs to handle InvokeInsts by

assuming that the use of the value is in a block dominated by the
"normal" destination. LangRef.html and other documentation sources
don't explicitly guarantee this, but it seems to be assumed in
other places in LLVM at least.

This fixes an assertion failure on the included testcase, which
is derived from the Ada testsuite.

FixUsesBeforeDefs is a temporary measure which I'm looking to
replace with a more capable solution.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72266 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman
2009-05-22 16:47:11 +00:00
parent a57bc3ba02
commit d6d0294e35
2 changed files with 62 additions and 1 deletions

View File

@@ -662,7 +662,11 @@ void IndVarSimplify::FixUsesBeforeDefs(Loop *L, SCEVExpander &Rewriter) {
if (Z != NumPredsLeft.end() && Z->second != 0 && --Z->second == 0) {
SmallVector<Instruction *, 4> UseWorkList;
UseWorkList.push_back(Inst);
BasicBlock::iterator InsertPt = next(I);
BasicBlock::iterator InsertPt = I;
if (InvokeInst *II = dyn_cast<InvokeInst>(InsertPt))
InsertPt = II->getNormalDest()->begin();
else
++InsertPt;
while (isa<PHINode>(InsertPt)) ++InsertPt;
do {
Instruction *Use = UseWorkList.pop_back_val();