File: noreturn-call-win64.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 (113 lines) | stat: -rw-r--r-- 3,676 bytes parent folder | download | duplicates (8)
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
; RUN: llc < %s -mtriple=x86_64-windows-msvc | FileCheck %s

%struct.MakeCleanup = type { i8 }
%eh.ThrowInfo = type { i32, i32, i32, i32 }

; Function Attrs: noinline nounwind optnone uwtable
define dso_local i32 @foo() {
entry:
  %call = call i32 @cond()
  %tobool = icmp ne i32 %call, 0
  br i1 %tobool, label %if.then, label %if.end

if.then:                                          ; preds = %entry
  call void @abort1()
  unreachable

if.end:                                           ; preds = %entry
  %call1 = call i32 @cond()
  %tobool2 = icmp ne i32 %call1, 0
  br i1 %tobool2, label %if.then3, label %if.end4

if.then3:                                         ; preds = %if.end
  call void @abort2()
  unreachable

if.end4:                                          ; preds = %if.end
  %call5 = call i32 @cond()
  %tobool6 = icmp ne i32 %call5, 0
  br i1 %tobool6, label %if.then7, label %if.end8

if.then7:                                         ; preds = %if.end4
  call void @abort3()
  unreachable

if.end8:                                          ; preds = %if.end4
  ret i32 0
}

; CHECK-LABEL: foo:
; CHECK: callq cond
; CHECK: callq cond
; CHECK: callq cond
;   We don't need int3's between these calls to abort, since they won't confuse
;   the unwinder.
; CHECK: callq abort1
; CHECK-NEXT:   # %if.then3
; CHECK: callq abort2
; CHECK-NEXT:   # %if.then7
; CHECK: callq abort3
; CHECK-NEXT: int3

declare dso_local i32 @cond()

declare dso_local void @abort1() noreturn
declare dso_local void @abort2() noreturn
declare dso_local void @abort3() noreturn

define dso_local void @throw_exception() uwtable personality i32 (...)* @__CxxFrameHandler3 {
entry:
  %o = alloca %struct.MakeCleanup, align 1
  %call = invoke i32 @cond()
          to label %invoke.cont unwind label %ehcleanup

invoke.cont:                                      ; preds = %entry
  %cmp1 = icmp eq i32 0, %call
  br i1 %cmp1, label %if.then, label %if.end

if.then:                                          ; preds = %invoke.cont
  invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null)
          to label %unreachable unwind label %ehcleanup

if.end:                                           ; preds = %invoke.cont
  %call2 = invoke i32 @cond()
          to label %invoke.cont1 unwind label %ehcleanup

invoke.cont1:                                     ; preds = %if.end
  %cmp2 = icmp eq i32 0, %call2
  br i1 %cmp2, label %if.then3, label %if.end4

if.then3:                                         ; preds = %invoke.cont1
  invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null)
          to label %unreachable unwind label %ehcleanup

if.end4:                                          ; preds = %invoke.cont1
  call void @"??1MakeCleanup@@QEAA@XZ"(%struct.MakeCleanup* nonnull %o)
  ret void

ehcleanup:                                        ; preds = %if.then3, %if.end, %if.then, %entry
  %cp = cleanuppad within none []
  call void @"??1MakeCleanup@@QEAA@XZ"(%struct.MakeCleanup* nonnull %o) [ "funclet"(token %cp) ]
  cleanupret from %cp unwind to caller

unreachable:                                      ; preds = %if.then3, %if.then
  unreachable
}

declare dso_local i32 @__CxxFrameHandler3(...)
declare dso_local void @_CxxThrowException(i8*, %eh.ThrowInfo*)
declare dso_local void @"??1MakeCleanup@@QEAA@XZ"(%struct.MakeCleanup*)

; CHECK-LABEL: throw_exception:
; CHECK: callq cond
; CHECK: je
; CHECK: callq cond
; CHECK: je
; CHECK: retq
; CHECK: callq _CxxThrowException
; CHECK-NOT: {{(addq|subq) .*, %rsp}}
; CHECK: callq _CxxThrowException
; CHECK-NOT: {{(addq|subq) .*, %rsp}}
; CHECK: # %unreachable
; CHECK: int3
; CHECK: .seh_handlerdata