[llvm] r256788 - [LICM] Fix a small oversight introduced in r256763
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 4 15:16:23 PST 2016
Author: majnemer
Date: Mon Jan 4 17:16:22 2016
New Revision: 256788
URL: http://llvm.org/viewvc/llvm-project?rev=256788&view=rev
Log:
[LICM] Fix a small oversight introduced in r256763
r256763 had promoteLoopAccessesToScalars check for the existence of a
catchswitch when the exit blocks were populated but
promoteLoopAccessesToScalars may be called with a prepopulated set of
exit blocks which would also need to be checked.
This fixes PR26019.
Modified:
llvm/trunk/lib/Transforms/Scalar/LICM.cpp
llvm/trunk/test/Transforms/LICM/funclet.ll
Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=256788&r1=256787&r2=256788&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Mon Jan 4 17:16:22 2016
@@ -1015,15 +1015,15 @@ bool llvm::promoteLoopAccessesToScalars(
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;
Modified: llvm/trunk/test/Transforms/LICM/funclet.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LICM/funclet.ll?rev=256788&r1=256787&r2=256788&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LICM/funclet.ll (original)
+++ llvm/trunk/test/Transforms/LICM/funclet.ll Mon Jan 4 17:16:22 2016
@@ -63,7 +63,9 @@ try.cont:
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:
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:
; 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()
More information about the llvm-commits
mailing list