blob: 0d735a4698f60aaa541ba1ef06f2703fc6a29592 [file] [log] [blame]
Kristof Beyls5ac6adb2017-02-23 12:24:55 +00001; RUN: llc -mtriple armv7--linux-gnueabihf -relocation-model=static < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7ARM
2; RUN: llc -mtriple armv7--linux-gnueabihf -relocation-model=pic < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7ARM
3; RUN: llc -mtriple armv7--linux-gnueabihf -relocation-model=ropi < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7ARM
4; RUN: llc -mtriple armv7--linux-gnueabihf -relocation-model=rwpi < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7ARM
5; RUN: llc -mtriple thumbv7--linux-gnueabihf -relocation-model=static < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7THUMB
6; RUN: llc -mtriple thumbv7--linux-gnueabihf -relocation-model=pic < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7THUMB
7; RUN: llc -mtriple thumbv7--linux-gnueabihf -relocation-model=ropi < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7THUMB
8; RUN: llc -mtriple thumbv7--linux-gnueabihf -relocation-model=rwpi < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7THUMB
9; RUN: llc -mtriple thumbv6m--linux-gnueabihf -relocation-model=static < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V6M
10; RUN: llc -mtriple thumbv6m--linux-gnueabihf -relocation-model=pic < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V6M
11; RUN: llc -mtriple thumbv6m--linux-gnueabihf -relocation-model=ropi < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V6M
12; RUN: llc -mtriple thumbv6m--linux-gnueabihf -relocation-model=rwpi < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V6M
James Molloy9abb2fa2016-09-26 07:26:24 +000013
14@.str = private unnamed_addr constant [2 x i8] c"s\00", align 1
15@.str1 = private unnamed_addr constant [69 x i8] c"this string is far too long to fit in a literal pool by far and away\00", align 1
16@.str2 = private unnamed_addr constant [27 x i8] c"this string is just right!\00", align 1
17@.str3 = private unnamed_addr constant [26 x i8] c"this string is used twice\00", align 1
18@.str4 = private unnamed_addr constant [29 x i8] c"same string in two functions\00", align 1
19@.arr1 = private unnamed_addr constant [2 x i16] [i16 3, i16 4], align 2
20@.arr2 = private unnamed_addr constant [2 x i16] [i16 7, i16 8], align 2
21@.arr3 = private unnamed_addr constant [2 x i16*] [i16* null, i16* null], align 4
22@.ptr = private unnamed_addr constant [2 x i16*] [i16* getelementptr inbounds ([2 x i16], [2 x i16]* @.arr2, i32 0, i32 0), i16* null], align 2
James Molloy6215fad2016-10-06 07:56:00 +000023@.arr4 = private unnamed_addr constant [2 x i16] [i16 3, i16 4], align 16
James Molloy9abb2fa2016-09-26 07:26:24 +000024
25; CHECK-LABEL: @test1
26; CHECK: adr r0, [[x:.*]]
27; CHECK: [[x]]:
28; CHECK: .asciz "s\000\000"
29define void @test1() #0 {
30 tail call void @a(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0)) #2
31 ret void
32}
33
34declare void @a(i8*) #1
35
36; CHECK-LABEL: @test2
37; CHECK-NOT: .asci
38; CHECK: .fnend
39define void @test2() #0 {
40 tail call void @a(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str1, i32 0, i32 0)) #2
41 ret void
42}
43
44; CHECK-LABEL: @test3
45; CHECK: adr r0, [[x:.*]]
46; CHECK: [[x]]:
47; CHECK: .asciz "this string is just right!\000"
48define void @test3() #0 {
49 tail call void @a(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str2, i32 0, i32 0)) #2
50 ret void
51}
52
53
54; CHECK-LABEL: @test4
55; CHECK: adr r{{.*}}, [[x:.*]]
56; CHECK: [[x]]:
57; CHECK: .asciz "this string is used twice\000\000"
58define void @test4() #0 {
59 tail call void @a(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str3, i32 0, i32 0)) #2
60 tail call void @a(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str3, i32 0, i32 0)) #2
61 ret void
62}
63
64; CHECK-LABEL: @test5a
65; CHECK-NOT: adr
66define void @test5a() #0 {
67 tail call void @a(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str4, i32 0, i32 0)) #2
68 ret void
69}
70
71define void @test5b() #0 {
72 tail call void @b(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str4, i32 0, i32 0)) #2
73 ret void
74}
75
76; CHECK-LABEL: @test6a
77; CHECK: adr r0, [[x:.*]]
78; CHECK: [[x]]:
79; CHECK: .short 3
80; CHECK: .short 4
81define void @test6a() #0 {
82 tail call void @c(i16* getelementptr inbounds ([2 x i16], [2 x i16]* @.arr1, i32 0, i32 0)) #2
83 ret void
84}
85
86; CHECK-LABEL: @test6b
87; CHECK: adr r0, [[x:.*]]
88; CHECK: [[x]]:
89; CHECK: .short 3
90; CHECK: .short 4
91define void @test6b() #0 {
92 tail call void @c(i16* getelementptr inbounds ([2 x i16], [2 x i16]* @.arr1, i32 0, i32 0)) #2
93 ret void
94}
95
96; This shouldn't be promoted, as the string is used by another global.
97; CHECK-LABEL: @test7
98; CHECK-NOT: adr
99define void @test7() #0 {
100 tail call void @c(i16* getelementptr inbounds ([2 x i16], [2 x i16]* @.arr2, i32 0, i32 0)) #2
101 ret void
102}
103
104; This shouldn't be promoted, because the array contains pointers.
105; CHECK-LABEL: @test8
106; CHECK-NOT: .zero
107; CHECK: .fnend
108define void @test8() #0 {
109 %a = load i16*, i16** getelementptr inbounds ([2 x i16*], [2 x i16*]* @.arr3, i32 0, i32 0)
110 tail call void @c(i16* %a) #2
111 ret void
112}
113
114@fn1.a = private unnamed_addr constant [4 x i16] [i16 4, i16 0, i16 0, i16 0], align 2
115@fn2.a = private unnamed_addr constant [8 x i8] [i8 4, i8 0, i8 0, i8 0, i8 23, i8 0, i8 6, i8 0], align 1
116
117; Just check these don't crash.
118define void @fn1() "target-features"="+strict-align" {
119entry:
120 %a = alloca [4 x i16], align 2
121 %0 = bitcast [4 x i16]* %a to i8*
122 call void @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* bitcast ([4 x i16]* @fn1.a to i8*), i32 8, i32 2, i1 false)
123 ret void
124}
125
126define void @fn2() "target-features"="+strict-align" {
127entry:
128 %a = alloca [8 x i8], align 2
129 %0 = bitcast [8 x i8]* %a to i8*
130 call void @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* bitcast ([8 x i8]* @fn2.a to i8*), i32 16, i32 1, i1 false)
131 ret void
132}
133
James Molloy6215fad2016-10-06 07:56:00 +0000134; This shouldn't be promoted, as the global requires >4 byte alignment.
135; CHECK-LABEL: @test9
136; CHECK-NOT: adr
137define void @test9() #0 {
138 tail call void @c(i16* getelementptr inbounds ([2 x i16], [2 x i16]* @.arr4, i32 0, i32 0)) #2
139 ret void
140}
141
Kristof Beyls5ac6adb2017-02-23 12:24:55 +0000142; CHECK-LABEL: @test10
143; CHECK-V6M: adr r{{[0-9]*}}, [[x:.*]]
144; CHECK-V6M: [[x]]:
145; CHECK-V6M: .asciz "s\000\000"
146; CHECK-V7: ldrb{{(.w)?}} r{{[0-9]*}}, [[x:.*]]
147; CHECK-V7: [[x]]:
148; CHECK-V7: .asciz "s\000\000"
149define void @test10(i8* %a) local_unnamed_addr #0 {
150 call void @llvm.memmove.p0i8.p0i8.i32(i8* %a, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i32 1, i32 1, i1 false)
151 ret void
152}
153
154; CHECK-LABEL: @test11
155; CHECK-V6M: adr r{{[0-9]*}}, [[x:.*]]
156; CHECK-V6M: [[x]]:
157; CHECK-V6M: .short 3
158; CHECK-V6M: .short 4
159; CHECK-V7THUMB: ldrh{{(.w)?}} r{{[0-9]*}}, [[x:.*]]
160; CHECK-V7THUMB: [[x]]:
161; CHECK-V7THUMB: .short 3
162; CHECK-V7THUMB: .short 4
163; CHECK-V7ARM: adr r{{[0-9]*}}, [[x:.*]]
164; CHECK-V7ARM: [[x]]:
165; CHECK-V7ARM: .short 3
166; CHECK-V7ARM: .short 4
167define void @test11(i16* %a) local_unnamed_addr #0 {
168 call void @llvm.memmove.p0i16.p0i16.i32(i16* %a, i16* getelementptr inbounds ([2 x i16], [2 x i16]* @.arr1, i32 0, i32 0), i32 2, i32 2, i1 false)
169 ret void
170}
171
James Molloy6215fad2016-10-06 07:56:00 +0000172
James Molloy9abb2fa2016-09-26 07:26:24 +0000173declare void @b(i8*) #1
174declare void @c(i16*) #1
175declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i32, i1)
Kristof Beyls5ac6adb2017-02-23 12:24:55 +0000176declare void @llvm.memmove.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) local_unnamed_addr
177declare void @llvm.memmove.p0i16.p0i16.i32(i16*, i16*, i32, i32, i1) local_unnamed_addr
James Molloy9abb2fa2016-09-26 07:26:24 +0000178
179attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
180attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
181attributes #2 = { nounwind }
182
183!llvm.module.flags = !{!0, !1}
James Molloy9abb2fa2016-09-26 07:26:24 +0000184
185!0 = !{i32 1, !"wchar_size", i32 4}
186!1 = !{i32 1, !"min_enum_size", i32 4}