[LoopStrengthReduce] Don't bother fixing up PHIs from EH Pad preds

We cannot really insert fixup code into a PHI's predecessor.

This fixes PR25445.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252416 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer 2015-11-08 05:04:07 +00:00
parent d9aac4c473
commit 08a70b0f2b
2 changed files with 56 additions and 0 deletions

View File

@ -3132,6 +3132,9 @@ LSRInstance::CollectLoopInvariantFixupsAndFormulae() {
PHINode::getIncomingValueNumForOperand(U.getOperandNo()));
if (!DT.dominates(L->getHeader(), UseBB))
continue;
// Don't bother if the instruction is in a BB which ends in an EHPad.
if (UseBB->getTerminator()->isEHPad())
continue;
// Ignore uses which are part of other SCEV expressions, to avoid
// analyzing them multiple times.
if (SE.isSCEVable(UserInst->getType())) {

View File

@ -4,7 +4,9 @@ target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
target triple = "i686-pc-windows-msvc"
declare i32 @_except_handler3(...)
declare i32 @__CxxFrameHandler3(...)
declare void @external(i32*)
declare void @reserve()
define void @f() personality i32 (...)* @_except_handler3 {
@ -188,3 +190,54 @@ unwind_out: ; preds = %iter, %loop_body
; CHECK-LABEL: define void @i(
; CHECK: ptrtoint i8* %phi2 to i32
define void @test1(i32* %b, i32* %c) personality i32 (...)* @__CxxFrameHandler3 {
entry:
br label %for.cond
for.cond: ; preds = %for.inc, %entry
%d.0 = phi i32* [ %b, %entry ], [ %incdec.ptr, %for.inc ]
invoke void @external(i32* %d.0)
to label %for.inc unwind label %catch.dispatch
for.inc: ; preds = %for.cond
%incdec.ptr = getelementptr inbounds i32, i32* %d.0, i32 1
br label %for.cond
catch.dispatch: ; preds = %for.cond
%0 = catchpad [i8* null, i32 64, i8* null]
to label %catch unwind label %catchendblock
catchendblock: ; preds = %catch.dispatch
catchendpad unwind label %catch.dispatch.2
catch: ; preds = %catch.dispatch
catchret %0 to label %try.cont
try.cont: ; preds = %catch
invoke void @external(i32* %c)
to label %try.cont.7 unwind label %catch.dispatch.2
catch.dispatch.2: ; preds = %try.cont, %catchendblock
%e.0 = phi i32* [ %c, %try.cont ], [ %b, %catchendblock ]
%1 = catchpad [i8* null, i32 64, i8* null]
to label %catch.4 unwind label %catchendblock.3
catch.4: ; preds = %catch.dispatch.2
unreachable
try.cont.7: ; preds = %try.cont
ret void
catchendblock.3: ; preds = %catch.dispatch.2
catchendpad unwind to caller
}
; CHECK-LABEL: define void @test1(
; CHECK: for.cond:
; CHECK: %d.0 = phi i32* [ %b, %entry ], [ %incdec.ptr, %for.inc ]
; CHECK: catchendpad unwind label %catch.dispatch.2
; CHECK: catch.dispatch.2:
; CHECK: %e.0 = phi i32* [ %c, %try.cont ], [ %b, %catchendblock ]