1; RUN: llc < %s -march=mips -mcpu=mips32 -mips-ssection-threshold=8 \
2; RUN:     -relocation-model=static -mattr=+noabicalls -mgpopt \
3; RUN:   | FileCheck %s
4
5; Test that object with an explicit section that is not .sdata or .sbss are not
6; considered in the small data section if they would otherwise qualify to be in
7; small data section. Also test that explicitly placing something in the small
8; data section uses %gp_rel addressing mode.
9
10@a = global [2 x i32] zeroinitializer, section ".rodata", align 4
11@b = global [4 x i32] zeroinitializer, section ".sdata", align 4
12@c = global [4 x i32] zeroinitializer, section ".sbss", align 4
13
14; CHECK-LABEL: g
15; CHECK:       lui $[[R:[0-9]+]], %hi(a)
16; CHECK:       lw  ${{[0-9]+}}, %lo(a)($[[R]])
17
18define i32 @g() {
19entry:
20  %0 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @a, i32 0, i32 0), align 4
21  ret i32 %0
22}
23
24; CHECK-LABEL: f:
25; CHECK-LABEL: lw ${{[0-9]+}}, %gp_rel(b)($gp)
26
27define i32 @f() {
28entry:
29  %0 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @b, i32 0, i32 0), align 4
30  ret i32 %0
31}
32
33; CHECK-LABEL: h:
34; CHECK-LABEL: lw ${{[0-9]+}}, %gp_rel(c)($gp)
35
36define i32 @h() {
37entry:
38  %0 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @c, i32 0, i32 0), align 4
39  ret i32 %0
40}
41
42
43; CHECK:  .type a,@object
44; CHECK:  .section  .rodata,"a",@progbits
45; CHECK:  .globl  a
46
47; CHECK:  .type b,@object
48; CHECK:  .section  .sdata,"aw",@progbits
49; CHECK:  .globl  b
50
51; CHECK:  .type c,@object
52; CHECK:  .section  .sbss,"aw",@nobits
53; CHECK:  .globl  c
54