summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/SimplifyCFG/wineh-unreachable.ll
blob: 31d567f649208adf4e212218168617e53b0010db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
; RUN: opt -S -simplifycfg < %s | FileCheck %s

declare void @Personality()
declare void @f()

; CHECK-LABEL: define void @test1()
define void @test1() personality i8* bitcast (void ()* @Personality to i8*) {
entry:
  ; CHECK: call void @f()
  invoke void @f()
    to label %exit unwind label %unreachable.unwind
exit:
  ret void
unreachable.unwind:
  cleanuppad []
  unreachable  
}

; CHECK-LABEL: define void @test2()
define void @test2() personality i8* bitcast (void ()* @Personality to i8*) {
entry:
  invoke void @f()
    to label %exit unwind label %catch.pad
catch.pad:
  ; CHECK: catchpad []
  ; CHECK-NEXT: to label %catch.body unwind label %catch.end
  %catch = catchpad []
    to label %catch.body unwind label %catch.end
catch.body:
  ; CHECK:      catch.body:
  ; CHECK-NEXT:   call void @f()
  ; CHECK-NEXT:   unreachable
  call void @f()
  catchret %catch to label %unreachable
catch.end:
  ; CHECK: catch.end:
  ; CHECK-NEXT: catchendpad unwind to caller
  catchendpad unwind label %unreachable.unwind
exit:
  ret void
unreachable.unwind:
  cleanuppad []
  unreachable
unreachable:
  unreachable
}

; CHECK-LABEL: define void @test3()
define void @test3() personality i8* bitcast (void ()* @Personality to i8*) {
entry:
  invoke void @f()
    to label %exit unwind label %cleanup.pad
cleanup.pad:
  ; CHECK: %cleanup = cleanuppad []
  ; CHECK-NEXT: call void @f()
  ; CHECK-NEXT: unreachable
  %cleanup = cleanuppad []
  invoke void @f()
    to label %cleanup.ret unwind label %cleanup.end
cleanup.ret:
  ; This cleanupret should be rewritten to unreachable,
  ; and merged into the pred block.
  cleanupret %cleanup unwind label %unreachable.unwind
cleanup.end:
  ; This cleanupendpad should be rewritten to unreachable,
  ; causing the invoke to be rewritten to a call.
  cleanupendpad %cleanup unwind label %unreachable.unwind
exit:
  ret void
unreachable.unwind:
  cleanuppad []
  unreachable
}

; CHECK-LABEL: define void @test4()
define void @test4() personality i8* bitcast (void ()* @Personality to i8*) {
entry:
  invoke void @f()
    to label %exit unwind label %terminate.pad
terminate.pad:
  ; CHECK: terminatepad [] unwind to caller
  terminatepad [] unwind label %unreachable.unwind
exit:
  ret void
unreachable.unwind:
  cleanuppad []
  unreachable
}

; CHECK-LABEL: define void @test5()
define void @test5() personality i8* bitcast (void ()* @Personality to i8*) {
entry:
  invoke void @f()
          to label %exit unwind label %catch.pad

catch.pad:
  %catch = catchpad []
          to label %catch.body unwind label %catch.end

catch.body:
  catchret %catch to label %exit

catch.end:
  catchendpad unwind to caller

exit:
  unreachable
}
OpenPOWER on IntegriCloud