1; RUN: llc -O3 -o - %s | FileCheck %s
2; Test case from PR16882.
3target triple = "thumbv7a-none-eabi"
4
5define i32 @test1() {
6; CHECK-LABEL: @test1
7; CHECK-NOT: push
8entry:
9  tail call void @overflow() #0
10  unreachable
11}
12
13; Function Attrs: noreturn nounwind
14declare void @overflow() #0
15
16define i32 @test2(i32 %x, i32 %y) {
17; CHECK-LABEL: @test2
18; CHECK-NOT: push
19; CHECK-NOT: pop
20entry:
21  %conv = sext i32 %x to i64
22  %conv1 = sext i32 %y to i64
23  %mul = mul nsw i64 %conv1, %conv
24  %conv2 = trunc i64 %mul to i32
25  %conv3 = sext i32 %conv2 to i64
26  %cmp = icmp eq i64 %mul, %conv3
27  br i1 %cmp, label %if.end, label %if.then
28
29if.then:                                          ; preds = %entry
30  tail call void @overflow() #0
31  unreachable
32
33if.end:                                           ; preds = %entry
34  ret i32 %conv2
35}
36
37; Test case for PR17825.
38define i32 @test3() {
39; CHECK-LABEL: @test3
40; CHECK: push
41entry:
42  tail call void @overflow_with_unwind() #1
43  unreachable
44}
45
46; Test case for uwtable
47define i32 @test4() uwtable {
48; CHECK-LABEL: @test4
49; CHECK: push
50entry:
51  tail call void @overflow() #0
52  unreachable
53}
54
55define i32 @test5() uwtable {
56; CHECK-LABEL: @test5
57; CHECK: push
58entry:
59  tail call void @overflow_with_unwind() #1
60  unreachable
61}
62
63
64define i32 @test1_nofpelim() "no-frame-pointer-elim"="true" {
65; CHECK-LABEL: @test1_nofpelim
66; CHECK: push
67entry:
68  tail call void @overflow() #0
69  unreachable
70}
71
72define i32 @test2_nofpelim(i32 %x, i32 %y) "no-frame-pointer-elim"="true" {
73; CHECK-LABEL: @test2_nofpelim
74; CHECK: push
75entry:
76  %conv = sext i32 %x to i64
77  %conv1 = sext i32 %y to i64
78  %mul = mul nsw i64 %conv1, %conv
79  %conv2 = trunc i64 %mul to i32
80  %conv3 = sext i32 %conv2 to i64
81  %cmp = icmp eq i64 %mul, %conv3
82  br i1 %cmp, label %if.end, label %if.then
83
84if.then:                                          ; preds = %entry
85  tail call void @overflow() #0
86  unreachable
87
88if.end:                                           ; preds = %entry
89  ret i32 %conv2
90}
91
92; Test case for PR17825.
93define i32 @test3_nofpelim() "no-frame-pointer-elim"="true" {
94; CHECK-LABEL: @test3_nofpelim
95; CHECK: push
96entry:
97  tail call void @overflow_with_unwind() #1
98  unreachable
99}
100
101; Test case for uwtable
102define i32 @test4_nofpelim() uwtable "no-frame-pointer-elim"="true" {
103; CHECK-LABEL: @test4_nofpelim
104; CHECK: push
105entry:
106  tail call void @overflow() #0
107  unreachable
108}
109
110define i32 @test5_nofpelim() uwtable "no-frame-pointer-elim"="true" {
111; CHECK-LABEL: @test5_nofpelim
112; CHECK: push
113entry:
114  tail call void @overflow_with_unwind() #1
115  unreachable
116}
117
118; Function Attrs: noreturn
119declare void @overflow_with_unwind() #1
120
121attributes #0 = { noreturn nounwind }
122attributes #1 = { noreturn }
123