forked from OSchip/llvm-project
Add a test case for LICM when promoting locals that may be read after the throw within the loop. NFCI.
Summary: Add a test case for LICM when promoting locals that may be read after the throw within the loop. Reviewers: eli.friedman, hfinkel, sanjoy Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D28822 llvm-svn: 292261
This commit is contained in:
parent
14715b3c2a
commit
0bc2977874
|
@ -69,4 +69,82 @@ for.cond.cleanup:
|
|||
ret void
|
||||
}
|
||||
|
||||
@_ZTIi = external constant i8*
|
||||
|
||||
; In this test, the loop is within a try block. There is an explicit unwind edge out of the loop.
|
||||
; Make sure this edge is treated as a loop exit, and that the loads and stores are promoted as
|
||||
; expected
|
||||
define void @loop_within_tryblock() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
|
||||
entry:
|
||||
%a = alloca i32, align 4
|
||||
store i32 0, i32* %a, align 4
|
||||
br label %for.cond
|
||||
|
||||
for.cond:
|
||||
%i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
|
||||
%cmp = icmp slt i32 %i.0, 1024
|
||||
br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
; CHECK: for.body:
|
||||
; CHECK-NOT: load
|
||||
; CHECK-NOT: store
|
||||
; CHECK: invoke
|
||||
for.body:
|
||||
%0 = load i32, i32* %a, align 4
|
||||
%add = add nsw i32 %0, 1
|
||||
store i32 %add, i32* %a, align 4
|
||||
invoke void @boo()
|
||||
to label %invoke.cont unwind label %lpad
|
||||
|
||||
invoke.cont:
|
||||
br label %for.inc
|
||||
|
||||
for.inc:
|
||||
%inc = add nsw i32 %i.0, 1
|
||||
br label %for.cond
|
||||
|
||||
; CHECK: lpad:
|
||||
; CHECK: store
|
||||
; CHECK: br
|
||||
lpad:
|
||||
%1 = landingpad { i8*, i32 }
|
||||
catch i8* bitcast (i8** @_ZTIi to i8*)
|
||||
%2 = extractvalue { i8*, i32 } %1, 0
|
||||
%3 = extractvalue { i8*, i32 } %1, 1
|
||||
br label %catch.dispatch
|
||||
|
||||
catch.dispatch:
|
||||
%4 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #3
|
||||
%matches = icmp eq i32 %3, %4
|
||||
br i1 %matches, label %catch, label %eh.resume
|
||||
|
||||
catch:
|
||||
%5 = call i8* @__cxa_begin_catch(i8* %2) #3
|
||||
%6 = bitcast i8* %5 to i32*
|
||||
%7 = load i32, i32* %6, align 4
|
||||
call void @__cxa_end_catch() #3
|
||||
br label %try.cont
|
||||
|
||||
try.cont:
|
||||
ret void
|
||||
|
||||
for.end:
|
||||
br label %try.cont
|
||||
|
||||
eh.resume:
|
||||
%lpad.val = insertvalue { i8*, i32 } undef, i8* %2, 0
|
||||
%lpad.val3 = insertvalue { i8*, i32 } %lpad.val, i32 %3, 1
|
||||
resume { i8*, i32 } %lpad.val3
|
||||
}
|
||||
|
||||
declare void @boo()
|
||||
|
||||
declare i32 @__gxx_personality_v0(...)
|
||||
|
||||
declare i32 @llvm.eh.typeid.for(i8*)
|
||||
|
||||
declare i8* @__cxa_begin_catch(i8*)
|
||||
|
||||
declare void @__cxa_end_catch()
|
||||
|
||||
declare void @f() uwtable
|
||||
|
|
Loading…
Reference in New Issue