1; RUN: llc -mtriple=hexagon-unknown-elf -hexagon-small-data-threshold=8 -relocation-model=static < %s | FileCheck --check-prefixes=CHECK,STATIC %s
2; RUN: llc -mtriple=hexagon-unknown-elf -hexagon-small-data-threshold=8 -relocation-model=pic < %s | FileCheck --check-prefixes=CHECK,PIC %s
3
4; If a global has a specified section, it should probably be placed in that
5; section, but with PIC any accesses to globals in small data should still
6; go through GOT.
7
8@g0 = global i32 zeroinitializer
9@g1 = global i32 zeroinitializer, section ".sdata"
10
11; CHECK-LABEL: f0:
12; STATIC: memw(gp+#g0)
13; PIC: r[[R0:[0-9]+]] = add(pc,##_GLOBAL_OFFSET_TABLE_@PCREL)
14; PIC: = memw(r[[R0]]+##g0@GOT)
15define i32 @f0() #0 {
16  %v0 = load i32, i32* @g0
17  ret i32 %v0
18}
19
20; CHECK-LABEL: f1:
21; STATIC: memw(gp+#g1)
22; PIC: r[[R1:[0-9]+]] = add(pc,##_GLOBAL_OFFSET_TABLE_@PCREL)
23; PIC: = memw(r[[R1]]+##g1@GOT)
24define i32 @f1() #0 {
25  %v0 = load i32, i32* @g1
26  ret i32 %v0
27}
28
29; CHECK-LABEL: f2:
30; STATIC: CONST64(#123456789012345678)
31; PIC: r0 = ##-1506741426
32; PIC: r1 = ##28744523
33define i64 @f2() #0 {
34  ret i64 123456789012345678
35}
36
37attributes #0 = { nounwind "target-cpu"="hexagonv60" }
38