1 ; RUN: opt -passes=inline < %s -S -o - -inline-threshold=3 | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
6 declare void @pad() readnone
8 define void @outer1(ptr %a) {
9 ; CHECK-LABEL: @outer1(
10 ; CHECK-NOT: call void @inner1
12 call void @inner1(ptr %a, ptr %b)
16 define void @inner1(ptr %a, ptr %b) {
18 store i32 %1, ptr %b ; This store does not clobber the first load.
26 define void @outer2(ptr %a, ptr %b) {
27 ; CHECK-LABEL: @outer2(
28 ; CHECK: call void @inner2
29 call void @inner2(ptr %a, ptr %b)
33 define void @inner2(ptr %a, ptr %b) {
35 store i32 %1, ptr %b ; This store clobbers the first load.
42 define void @outer3(ptr %a) {
43 ; CHECK-LABEL: @outer3(
44 ; CHECK: call void @inner3
45 call void @inner3(ptr %a)
51 define void @inner3(ptr %a) {
53 call void @ext() ; This call clobbers the first load.
59 define void @outer4(ptr %a, ptr %b, ptr %c) {
60 ; CHECK-LABEL: @outer4(
61 ; CHECK-NOT: call void @inner4
62 call void @inner4(ptr %a, ptr %b, i1 false)
66 define void @inner4(ptr %a, ptr %b, i1 %pred) {
68 br i1 %pred, label %cond_true, label %cond_false
71 store i32 %1, ptr %b ; This store does not clobber the first load.
83 define void @outer5(ptr %a, double %b) {
84 ; CHECK-LABEL: @outer5(
85 ; CHECK-NOT: call void @inner5
86 call void @inner5(ptr %a, double %b)
90 declare double @llvm.fabs.f64(double) nounwind readnone
92 define void @inner5(ptr %a, double %b) {
94 %2 = call double @llvm.fabs.f64(double %b) ; This intrinsic does not clobber the first load.
100 define void @outer6(ptr %a, ptr %ptr) {
101 ; CHECK-LABEL: @outer6(
102 ; CHECK-NOT: call void @inner6
103 call void @inner6(ptr %a, ptr %ptr)
107 declare void @llvm.lifetime.start.p0(i64, ptr nocapture) argmemonly nounwind
109 define void @inner6(ptr %a, ptr %ptr) {
110 %1 = load i32, ptr %a
111 call void @llvm.lifetime.start.p0(i64 32, ptr %ptr) ; This intrinsic does not clobber the first load.
112 %2 = load i32, ptr %a
114 %3 = load i32, ptr %a
118 define void @outer7(ptr %a) {
119 ; CHECK-LABEL: @outer7(
120 ; CHECK-NOT: call void @inner7
121 call void @inner7(ptr %a)
125 declare void @ext2() readnone
127 define void @inner7(ptr %a) {
128 %1 = load i32, ptr %a
129 call void @ext2() ; This call does not clobber the first load.
130 %2 = load i32, ptr %a
135 define void @outer8(ptr %a) {
136 ; CHECK-LABEL: @outer8(
137 ; CHECK-NOT: call void @inner8
138 call void @inner8(ptr %a, ptr @ext2)
142 define void @inner8(ptr %a, ptr %f) {
143 %1 = load i32, ptr %a
144 call void %f() ; This indirect call does not clobber the first load.
145 %2 = load i32, ptr %a
162 define void @outer9(ptr %a) {
163 ; CHECK-LABEL: @outer9(
164 ; CHECK: call void @inner9
165 call void @inner9(ptr %a, ptr @ext)
169 define void @inner9(ptr %a, ptr %f) {
170 %1 = load i32, ptr %a
171 call void %f() ; This indirect call clobbers the first load.
172 %2 = load i32, ptr %a
189 define void @outer10(ptr %a) {
190 ; CHECK-LABEL: @outer10(
191 ; CHECK: call void @inner10
193 call void @inner10(ptr %a, ptr %b)
197 define void @inner10(ptr %a, ptr %b) {
198 %1 = load i32, ptr %a
200 %2 = load volatile i32, ptr %a ; volatile load should be kept.
202 %3 = load volatile i32, ptr %a ; Same as the above.