blob: 73faa952fba930adf1c5dfb91d9ce860539442f4 [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( )
Chris Lattnerbc9e6d92010-12-13 05:10:30 +000012 to label %1 unwind label %Rethrow
Tanya Lattnerbaa370b2008-03-18 03:45:45 +000013 ret i32 0
Chris Lattnerbc9e6d92010-12-13 05:10:30 +000014Rethrow:
Tanya Lattnerbaa370b2008-03-18 03:45:45 +000015 unwind
Chris Lattner94be3002003-08-24 17:58:24 +000016}
Chris Lattner19788ca2009-10-13 18:13:05 +000017
18
19; Verify that simplifycfg isn't duplicating 'unwind' instructions. Doing this
20; is bad because it discourages commoning.
21define i32 @test2(i1 %c) {
22; CHECK: @test2
23; CHECK: T:
24; CHECK-NEXT: call void @bar()
25; CHECK-NEXT: br label %F
26 br i1 %c, label %T, label %F
27T:
28 call void @bar()
29 br label %F
30F:
31 unwind
32}