File: noreturn-call.ll

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (104 lines) | stat: -rw-r--r-- 3,016 bytes parent folder | download | duplicates (13)
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
; RUN: llc < %s -mtriple=i686-pc-win32 | FileCheck %s

define void @test1(i32 %c) {
; CHECK-LABEL: test1:
entry:
  %0 = alloca i8, i32 %c
  %tobool = icmp eq i32 %c, 0
  br i1 %tobool, label %if.end, label %if.then

if.end:
  call void @g(ptr %0)
  ret void

if.then:
  call void @crash(ptr %0)
  unreachable
; CHECK: calll _crash
; There is no need to adjust the stack after the call, since
; the function is noreturn and that code will therefore never run.
; CHECK-NOT: add
; CHECK-NOT: pop
}

define void @test2(i32 %c) {
; CHECK-LABEL: test2:
entry:
  %0 = alloca i8, i32 %c
  %tobool = icmp eq i32 %c, 0
  br i1 %tobool, label %if.end, label %if.then

if.end:
  call void @g(ptr %0)
  ret void

if.then:
  call void @crash2(ptr %0)
  unreachable
; CHECK: calll _crash2
; Even though _crash2 is not marked noreturn, it is in practice because
; of the "unreachable" right after it. This happens e.g. when falling off
; a non-void function after a call.
; CHECK-NOT: add
; CHECK-NOT: pop
}

declare void @crash(ptr) noreturn
declare void @crash2(ptr)
declare void @g(ptr)

%struct.ByVal = type { [10 x i32] }

define dso_local i32 @pr43155() {
entry:
  %agg.tmp = alloca %struct.ByVal, align 4
  %agg.tmp5 = alloca %struct.ByVal, align 4
  %agg.tmp6 = alloca %struct.ByVal, align 4
  %call = tail call i32 @cond()
  %tobool = icmp eq i32 %call, 0
  br i1 %tobool, label %if.end, label %if.then

if.then:                                          ; preds = %entry
  tail call x86_stdcallcc void @stdcall_abort(i32 12, i32 2)
  unreachable

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

if.then3:                                         ; preds = %if.end
  tail call x86_stdcallcc void @stdcall_abort(i32 15, i32 2)
  unreachable

if.end4:                                          ; preds = %if.end
  call void @getbyval(ptr nonnull sret(%struct.ByVal) %agg.tmp)
  call void @make_push_unprofitable(ptr nonnull byval(%struct.ByVal) align 4 %agg.tmp)
  call void @getbyval(ptr nonnull sret(%struct.ByVal) %agg.tmp5)
  call void @make_push_unprofitable(ptr nonnull byval(%struct.ByVal) align 4 %agg.tmp5)
  call void @getbyval(ptr nonnull sret(%struct.ByVal) %agg.tmp6)
  call void @make_push_unprofitable(ptr nonnull byval(%struct.ByVal) align 4 %agg.tmp6)
  ret i32 0
}

;   Check that there are no stack adjustments after stdcall_abort.
; CHECK-LABEL: pr43155:
;   The main function body contents are not important.
; CHECK: retl
; CHECK:  # %if.then
; CHECK: calll _stdcall_abort@8
; CHECK-NOT: sub
; CHECK-NOT: add
; CHECK:  # %if.then3
; CHECK: calll _stdcall_abort@8
; CHECK-NOT: sub
; CHECK-NOT: add
; CHECK: # -- End function

declare dso_local i32 @cond()

declare dso_local x86_stdcallcc void @stdcall_abort(i32, i32) noreturn

declare dso_local void @make_push_unprofitable(ptr byval(%struct.ByVal) align 4)

declare dso_local void @getbyval(ptr sret(%struct.ByVal))