[llvm] r252416 - [LoopStrengthReduce] Don't bother fixing up PHIs from EH Pad preds
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 7 21:04:07 PST 2015
Author: majnemer
Date: Sat Nov 7 23:04:07 2015
New Revision: 252416
URL: http://llvm.org/viewvc/llvm-project?rev=252416&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
llvm/trunk/test/Transforms/LoopStrengthReduce/funclet.ll
Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=252416&r1=252415&r2=252416&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Sat Nov 7 23:04:07 2015
@@ -3132,6 +3132,9 @@ LSRInstance::CollectLoopInvariantFixupsA
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())) {
Modified: llvm/trunk/test/Transforms/LoopStrengthReduce/funclet.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/funclet.ll?rev=252416&r1=252415&r2=252416&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopStrengthReduce/funclet.ll (original)
+++ llvm/trunk/test/Transforms/LoopStrengthReduce/funclet.ll Sat Nov 7 23:04:07 2015
@@ -4,7 +4,9 @@ target datalayout = "e-m:x-p:32:32-i64:6
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:
; 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 ]
More information about the llvm-commits
mailing list