summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Transforms/Scalar/LICM.cpp12
-rw-r--r--llvm/test/Transforms/LICM/funclet.ll4
2 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index 2d6f6cecafe..e01e23f7173 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -1015,15 +1015,15 @@ bool llvm::promoteLoopAccessesToScalars(AliasSet &AS,
CurLoop->getUniqueExitBlocks(ExitBlocks);
InsertPts.clear();
InsertPts.reserve(ExitBlocks.size());
- for (BasicBlock *ExitBlock : ExitBlocks) {
- // Can't insert into a catchswitch.
- if (isa<CatchSwitchInst>(ExitBlock->getTerminator()))
- return Changed;
-
+ for (BasicBlock *ExitBlock : ExitBlocks)
InsertPts.push_back(&*ExitBlock->getFirstInsertionPt());
- }
}
+ // Can't insert into a catchswitch.
+ for (BasicBlock *ExitBlock : ExitBlocks)
+ if (isa<CatchSwitchInst>(ExitBlock->getTerminator()))
+ return Changed;
+
// Otherwise, this is safe to promote, lets do it!
DEBUG(dbgs() << "LICM: Promoting value stored to in loop: " <<*SomePtr<<'\n');
Changed = true;
diff --git a/llvm/test/Transforms/LICM/funclet.ll b/llvm/test/Transforms/LICM/funclet.ll
index 10001526ffc..ef4be296915 100644
--- a/llvm/test/Transforms/LICM/funclet.ll
+++ b/llvm/test/Transforms/LICM/funclet.ll
@@ -63,7 +63,9 @@ try.cont: ; preds = %catch, %while.cond
define void @test3(i1 %a, i1 %b, i1 %c) personality i32 (...)* @__CxxFrameHandler3 {
entry:
%.frame = alloca i8, align 4
+ %.frame2 = alloca i8, align 4
%bc = bitcast i8* %.frame to i32*
+ %bc2 = bitcast i8* %.frame2 to i32*
br i1 %a, label %try.success.or.caught, label %forbody
catch.object.Throwable: ; preds = %catch.dispatch
@@ -84,6 +86,7 @@ catch.dispatch: ; preds = %else, %forbody
forbody: ; preds = %forcond.backedge, %0
store i32 1, i32* %bc, align 4
+ store i32 2, i32* %bc2, align 4
invoke void @may_throw()
to label %postinvoke unwind label %catch.dispatch
@@ -95,6 +98,7 @@ else: ; preds = %postinvoke
; CHECK-LABEL: define void @test3(
; CHECK: catchswitch within none
; CHECK: store i32 1, i32* %bc, align 4
+; CHECK: store i32 2, i32* %bc2, align 4
declare void @may_throw()
OpenPOWER on IntegriCloud