blob: bbd779beb489d3f55b0f052e29608a8ef4c6d61e [file] [log] [blame]
Chris Lattner8d6d0932009-10-13 18:10:05 +00001; RUN: opt < %s -simplifycfg -S | FileCheck %s
Chris Lattner94be3002003-08-24 17:58:24 +00002
Tanya Lattnerbaa370b2008-03-18 03:45:45 +00003declare void @bar()
Chris Lattner94be3002003-08-24 17:58:24 +00004
Chris Lattner19788ca2009-10-13 18:13:05 +00005; This testcase checks to see if the simplifycfg pass is converting invoke
6; instructions to call instructions if the handler just rethrows the exception.
Chris Lattner8d6d0932009-10-13 18:10:05 +00007define i32 @test1() {
8; CHECK: @test1
9; CHECK-NEXT: call void @bar()
10; CHECK-NEXT: ret i32 0
Tanya Lattnerbaa370b2008-03-18 03:45:45 +000011 invoke void @bar( )
12 to label %Ok unwind label %Rethrow
13Ok: ; preds = %0
14 ret i32 0
15Rethrow: ; preds = %0
16 unwind
Chris Lattner94be3002003-08-24 17:58:24 +000017}
Chris Lattner19788ca2009-10-13 18:13:05 +000018
19
20; Verify that simplifycfg isn't duplicating 'unwind' instructions. Doing this
21; is bad because it discourages commoning.
22define i32 @test2(i1 %c) {
23; CHECK: @test2
24; CHECK: T:
25; CHECK-NEXT: call void @bar()
26; CHECK-NEXT: br label %F
27 br i1 %c, label %T, label %F
28T:
29 call void @bar()
30 br label %F
31F:
32 unwind
33}