From 781b75a7dff9d810cab5f4da005c22622911ee0e Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 22 May 2009 16:47:11 +0000 Subject: 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. llvm-svn: 72266 --- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp index 26015cf0e94..89742c55d64 100644 --- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -662,7 +662,11 @@ void IndVarSimplify::FixUsesBeforeDefs(Loop *L, SCEVExpander &Rewriter) { if (Z != NumPredsLeft.end() && Z->second != 0 && --Z->second == 0) { SmallVector UseWorkList; UseWorkList.push_back(Inst); - BasicBlock::iterator InsertPt = next(I); + BasicBlock::iterator InsertPt = I; + if (InvokeInst *II = dyn_cast(InsertPt)) + InsertPt = II->getNormalDest()->begin(); + else + ++InsertPt; while (isa(InsertPt)) ++InsertPt; do { Instruction *Use = UseWorkList.pop_back_val(); -- cgit v1.2.3