File: noreturn-call.ll

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2~deb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 995,836 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (104 lines) | stat: -rw-r--r-- 3,044 bytes parent folder | download | duplicates (2)
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(i8* %0)
  ret void

if.then:
  call void @crash(i8* %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(i8* %0)
  ret void

if.then:
  call void @crash2(i8* %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(i8*) noreturn
declare void @crash2(i8*)
declare void @g(i8*)

%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(%struct.ByVal* nonnull sret %agg.tmp)
  call void @make_push_unprofitable(%struct.ByVal* nonnull byval(%struct.ByVal) align 4 %agg.tmp)
  call void @getbyval(%struct.ByVal* nonnull sret %agg.tmp5)
  call void @make_push_unprofitable(%struct.ByVal* nonnull byval(%struct.ByVal) align 4 %agg.tmp5)
  call void @getbyval(%struct.ByVal* nonnull sret %agg.tmp6)
  call void @make_push_unprofitable(%struct.ByVal* 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(%struct.ByVal* byval(%struct.ByVal) align 4)

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