xref: /llvm-project/llvm/test/CodeGen/X86/noreturn-call-linux.ll (revision 2f448bf509432c1a19ec46ab8cbc7353c03c6280)
1; RUN: llc < %s -mtriple=x86_64-linux-gnu | FileCheck %s
2
3; PR43155, we used to emit dead stack adjustments for noreturn calls with stack
4; arguments.
5
6; Original source code:
7; __attribute__((noreturn)) void exit_manyarg(int, int, int, int, int, int, int, int, int, int);
8; struct ByVal {
9;   int vals[10];
10; };
11; struct ByVal getbyval();
12; void make_push_unprofitable(struct ByVal);
13; int foo(int c) {
14;   if (c)
15;     exit_manyarg(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
16;   make_push_unprofitable(getbyval());
17;   make_push_unprofitable(getbyval());
18;   make_push_unprofitable(getbyval());
19;   return 0;
20; }
21
22%struct.ByVal = type { [10 x i32] }
23
24define dso_local i32 @foo(i32 %c) {
25entry:
26  %agg.tmp = alloca %struct.ByVal, align 8
27  %agg.tmp1 = alloca %struct.ByVal, align 8
28  %agg.tmp2 = alloca %struct.ByVal, align 8
29  %tobool = icmp eq i32 %c, 0
30  br i1 %tobool, label %if.end, label %if.then
31
32if.then:                                          ; preds = %entry
33  tail call void @exit_manyarg(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10) #3
34  unreachable
35
36if.end:                                           ; preds = %entry
37  call void @getbyval(ptr nonnull sret(%struct.ByVal) %agg.tmp) #4
38  call void @make_push_unprofitable(ptr nonnull byval(%struct.ByVal) align 8 %agg.tmp) #4
39  call void @getbyval(ptr nonnull sret(%struct.ByVal) %agg.tmp1) #4
40  call void @make_push_unprofitable(ptr nonnull byval(%struct.ByVal) align 8 %agg.tmp1) #4
41  call void @getbyval(ptr nonnull sret(%struct.ByVal) %agg.tmp2) #4
42  call void @make_push_unprofitable(ptr nonnull byval(%struct.ByVal) align 8 %agg.tmp2) #4
43  ret i32 0
44}
45
46; CHECK-LABEL: foo:
47;   The main body is not important.
48; CHECK: callq exit_manyarg
49; CHECK-NOT: sub
50; CHECK-NOT: add
51; CHECK: # -- End function
52
53; Function Attrs: noreturn
54declare dso_local void @exit_manyarg(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32) noreturn
55
56declare dso_local void @make_push_unprofitable(ptr byval(%struct.ByVal) align 8)
57
58declare dso_local void @getbyval(ptr sret(%struct.ByVal))
59
60