1; The reason for the bug was that when deciding if a global
2; variable can be part of sdata, we were wrongly ignoring
3; the presence of any section specified for the variable
4; using the section attribute. If such a section is specified,
5; and that section is not sdata*/sbss* then the variable
6; cannot use GPREL addressing, i.e. memw(#variablename).
7
8; RUN: llc -march=hexagon < %s | FileCheck %s
9; CHECK-LABEL: foo
10; CHECK-DAG: memw(##b)
11; CHECK-DAG: memw(gp+#d)
12; CHECK-DAG: memw(##g)
13; CHECK-DAG: memw(gp+#h)
14; CHECK-DAG: memw(gp+#f)
15; CHECK-DAG: memw(##e)
16; CHECK-DAG: memw(gp+#a)
17; CHECK-DAG: memw(gp+#c)
18; CHECK-LABEL: bar
19; CHECK: memw(##b)
20
21@b = global i32 0, section ".data.section", align 4
22@a = common global i32 0, align 4
23@d = global i32 0, section ".sbss", align 4
24@c = global i32 0, section ".sdata", align 4
25@f = global i32 0, section ".sbss.4", align 4
26@e = global i32 0, section ".sdatafoo", align 4
27@h = global i32 0, section ".sdata.4", align 4
28@g = global i32 0, section ".sbssfoo", align 4
29
30define void @foo() nounwind {
31entry:
32  %0 = load i32, i32* @b, align 4
33  store i32 %0, i32* @a, align 4
34  %1 = load i32, i32* @d, align 4
35  store i32 %1, i32* @c, align 4
36  %2 = load i32, i32* @f, align 4
37  store i32 %2, i32* @e, align 4
38  %3 = load i32, i32* @h, align 4
39  store i32 %3, i32* @g, align 4
40  ret void
41}
42
43define void @bar() nounwind section ".function.section" {
44entry:
45  %0 = load i32, i32* @a, align 4
46  store i32 %0, i32* @b, align 4
47  ret void
48}
49
50define i32 @main() nounwind readnone {
51entry:
52  ret i32 0
53}
54
55