File: invoke-combine-clauses.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (118 lines) | stat: -rw-r--r-- 3,316 bytes parent folder | download | duplicates (4)
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
109
110
111
112
113
114
115
116
117
118
; RUN: opt %s -passes='cgscc(inline)' -S | FileCheck %s
; RUN: opt %s -passes='module-inline' -S | FileCheck %s

declare void @external_func()
declare void @abort()

@exception_inner = external global i8
@exception_outer = external global i8
@condition = external global i1


; Check for a bug in which multiple "resume" instructions in the
; inlined function caused "catch i8* @exception_outer" to appear
; multiple times in the resulting landingpad.

define internal void @inner_multiple_resume() personality i8* null {
  invoke void @external_func()
      to label %cont unwind label %lpad
cont:
  ret void
lpad:
  %lp = landingpad i32
      catch i8* @exception_inner
  %cond = load i1, i1* @condition
  br i1 %cond, label %resume1, label %resume2
resume1:
  resume i32 1
resume2:
  resume i32 2
}

define void @outer_multiple_resume() personality i8* null {
  invoke void @inner_multiple_resume()
      to label %cont unwind label %lpad
cont:
  ret void
lpad:
  %lp = landingpad i32
      catch i8* @exception_outer
  resume i32 %lp
}
; CHECK: define void @outer_multiple_resume()
; CHECK: %lp.i = landingpad
; CHECK-NEXT: catch i8* @exception_inner
; CHECK-NEXT: catch i8* @exception_outer
; Check that there isn't another "catch" clause:
; CHECK-NEXT: load


; Check for a bug in which having a "resume" and a "call" in the
; inlined function caused "catch i8* @exception_outer" to appear
; multiple times in the resulting landingpad.

define internal void @inner_resume_and_call() personality i8* null {
  call void @external_func()
  invoke void @external_func()
      to label %cont unwind label %lpad
cont:
  ret void
lpad:
  %lp = landingpad i32
      catch i8* @exception_inner
  resume i32 %lp
}

define void @outer_resume_and_call() personality i8* null {
  invoke void @inner_resume_and_call()
      to label %cont unwind label %lpad
cont:
  ret void
lpad:
  %lp = landingpad i32
      catch i8* @exception_outer
  resume i32 %lp
}
; CHECK: define void @outer_resume_and_call()
; CHECK: %lp.i = landingpad
; CHECK-NEXT: catch i8* @exception_inner
; CHECK-NEXT: catch i8* @exception_outer
; Check that there isn't another "catch" clause:
; CHECK-NEXT: br


; Check what happens if the inlined function contains an "invoke" but
; no "resume".  In this case, the inlined landingpad does not need to
; include the "catch i8* @exception_outer" clause from the outer
; function (since the outer function's landingpad will not be
; reachable), but it's OK to include this clause.

define internal void @inner_no_resume_or_call() personality i8* null {
  invoke void @external_func()
      to label %cont unwind label %lpad
cont:
  ret void
lpad:
  %lp = landingpad i32
      catch i8* @exception_inner
  ; A landingpad might have no "resume" if a C++ destructor aborts.
  call void @abort() noreturn nounwind
  unreachable
}

define void @outer_no_resume_or_call() personality i8* null {
  invoke void @inner_no_resume_or_call()
      to label %cont unwind label %lpad
cont:
  ret void
lpad:
  %lp = landingpad i32
      catch i8* @exception_outer
  resume i32 %lp
}
; CHECK: define void @outer_no_resume_or_call()
; CHECK: %lp.i = landingpad
; CHECK-NEXT: catch i8* @exception_inner
; CHECK-NEXT: catch i8* @exception_outer
; Check that there isn't another "catch" clause:
; CHECK-NEXT: call void @abort()