1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 3
2 # RUN: llc -mtriple=riscv32 -run-pass=instruction-select -relocation-model=pic \
3 # RUN: %s -o - | FileCheck --check-prefix=RV32-PIE %s
4 # RUN: llc -mtriple=riscv32 -run-pass=instruction-select \
5 # RUN: -mattr=+tagged-globals %s -o - | FileCheck \
6 # RUN: --check-prefix=RV32-NOPIE-TAG %s
7 # RUN: llc -mtriple=riscv32 -run-pass=instruction-select -code-model=small \
8 # RUN: %s -o - | FileCheck --check-prefix=RV32-SMALL-NOPIE-NOTAG %s
9 # RUN: llc -mtriple=riscv32 -run-pass=instruction-select -code-model=medium \
10 # RUN: %s -o - | FileCheck --check-prefix=RV32-MED %s
14 @x = global i32 0, align 4
15 define ptr @global_addr() {
19 @y = extern_weak global i32, align 4
20 define ptr @extern_weak_global_addr() {
24 @z = dso_local global i32 0, align 4
25 define ptr @local_global_addr() {
34 tracksRegLiveness: true
36 - { id: 0, class: gprb, preferred-register: '' }
39 ; RV32-PIE-LABEL: name: global_addr
40 ; RV32-PIE: [[PseudoLGA:%[0-9]+]]:gpr = PseudoLGA @x :: (dereferenceable invariant load (p0) from got)
41 ; RV32-PIE-NEXT: $x10 = COPY [[PseudoLGA]]
42 ; RV32-PIE-NEXT: PseudoRET implicit $x10
44 ; RV32-NOPIE-TAG-LABEL: name: global_addr
45 ; RV32-NOPIE-TAG: [[PseudoLGA:%[0-9]+]]:gpr = PseudoLGA @x :: (dereferenceable invariant load (p0) from got)
46 ; RV32-NOPIE-TAG-NEXT: $x10 = COPY [[PseudoLGA]]
47 ; RV32-NOPIE-TAG-NEXT: PseudoRET implicit $x10
49 ; RV32-SMALL-NOPIE-NOTAG-LABEL: name: global_addr
50 ; RV32-SMALL-NOPIE-NOTAG: [[LUI:%[0-9]+]]:gpr = LUI target-flags(riscv-hi) @x
51 ; RV32-SMALL-NOPIE-NOTAG-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI [[LUI]], target-flags(riscv-lo) @x
52 ; RV32-SMALL-NOPIE-NOTAG-NEXT: $x10 = COPY [[ADDI]]
53 ; RV32-SMALL-NOPIE-NOTAG-NEXT: PseudoRET implicit $x10
55 ; RV32-MED-LABEL: name: global_addr
56 ; RV32-MED: [[PseudoLLA:%[0-9]+]]:gpr = PseudoLLA @x
57 ; RV32-MED-NEXT: $x10 = COPY [[PseudoLLA]]
58 ; RV32-MED-NEXT: PseudoRET implicit $x10
59 %0:gprb(p0) = G_GLOBAL_VALUE @x
61 PseudoRET implicit $x10
64 name: extern_weak_global_addr
67 tracksRegLiveness: true
69 - { id: 0, class: gprb, preferred-register: '' }
72 ; RV32-PIE-LABEL: name: extern_weak_global_addr
73 ; RV32-PIE: [[PseudoLGA:%[0-9]+]]:gpr = PseudoLGA @y :: (dereferenceable invariant load (p0) from got)
74 ; RV32-PIE-NEXT: $x10 = COPY [[PseudoLGA]]
75 ; RV32-PIE-NEXT: PseudoRET implicit $x10
77 ; RV32-NOPIE-TAG-LABEL: name: extern_weak_global_addr
78 ; RV32-NOPIE-TAG: [[PseudoLGA:%[0-9]+]]:gpr = PseudoLGA @y :: (dereferenceable invariant load (p0) from got)
79 ; RV32-NOPIE-TAG-NEXT: $x10 = COPY [[PseudoLGA]]
80 ; RV32-NOPIE-TAG-NEXT: PseudoRET implicit $x10
82 ; RV32-SMALL-NOPIE-NOTAG-LABEL: name: extern_weak_global_addr
83 ; RV32-SMALL-NOPIE-NOTAG: [[LUI:%[0-9]+]]:gpr = LUI target-flags(riscv-hi) @y
84 ; RV32-SMALL-NOPIE-NOTAG-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI [[LUI]], target-flags(riscv-lo) @y
85 ; RV32-SMALL-NOPIE-NOTAG-NEXT: $x10 = COPY [[ADDI]]
86 ; RV32-SMALL-NOPIE-NOTAG-NEXT: PseudoRET implicit $x10
88 ; RV32-MED-LABEL: name: extern_weak_global_addr
89 ; RV32-MED: [[PseudoLGA:%[0-9]+]]:gpr = PseudoLGA @y :: (dereferenceable invariant load (p0) from got)
90 ; RV32-MED-NEXT: $x10 = COPY [[PseudoLGA]]
91 ; RV32-MED-NEXT: PseudoRET implicit $x10
92 %0:gprb(p0) = G_GLOBAL_VALUE @y
94 PseudoRET implicit $x10
97 name: local_global_addr
100 tracksRegLiveness: true
102 - { id: 0, class: gprb, preferred-register: '' }
105 ; RV32-PIE-LABEL: name: local_global_addr
106 ; RV32-PIE: [[PseudoLLA:%[0-9]+]]:gpr = PseudoLLA @z
107 ; RV32-PIE-NEXT: $x10 = COPY [[PseudoLLA]]
108 ; RV32-PIE-NEXT: PseudoRET implicit $x10
110 ; RV32-NOPIE-TAG-LABEL: name: local_global_addr
111 ; RV32-NOPIE-TAG: [[PseudoLGA:%[0-9]+]]:gpr = PseudoLGA @z :: (dereferenceable invariant load (p0) from got)
112 ; RV32-NOPIE-TAG-NEXT: $x10 = COPY [[PseudoLGA]]
113 ; RV32-NOPIE-TAG-NEXT: PseudoRET implicit $x10
115 ; RV32-SMALL-NOPIE-NOTAG-LABEL: name: local_global_addr
116 ; RV32-SMALL-NOPIE-NOTAG: [[LUI:%[0-9]+]]:gpr = LUI target-flags(riscv-hi) @z
117 ; RV32-SMALL-NOPIE-NOTAG-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI [[LUI]], target-flags(riscv-lo) @z
118 ; RV32-SMALL-NOPIE-NOTAG-NEXT: $x10 = COPY [[ADDI]]
119 ; RV32-SMALL-NOPIE-NOTAG-NEXT: PseudoRET implicit $x10
121 ; RV32-MED-LABEL: name: local_global_addr
122 ; RV32-MED: [[PseudoLLA:%[0-9]+]]:gpr = PseudoLLA @z
123 ; RV32-MED-NEXT: $x10 = COPY [[PseudoLLA]]
124 ; RV32-MED-NEXT: PseudoRET implicit $x10
125 %0:gprb(p0) = G_GLOBAL_VALUE @z
127 PseudoRET implicit $x10