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