1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 3
2 # RUN: llc -mtriple=riscv64 -run-pass=instruction-select -relocation-model=pic \
3 # RUN: %s -o - | FileCheck --check-prefix=RV64-PIE %s
4 # RUN: llc -mtriple=riscv64 -run-pass=instruction-select \
5 # RUN: -mattr=+tagged-globals %s -o - | FileCheck \
6 # RUN: --check-prefix=RV64-NOPIE-TAG %s
7 # RUN: llc -mtriple=riscv64 -run-pass=instruction-select -code-model=small \
8 # RUN: %s -o - | FileCheck --check-prefix=RV64-SMALL-NOPIE-NOTAG %s
9 # RUN: llc -mtriple=riscv64 -run-pass=instruction-select -code-model=medium \
10 # RUN: %s -o - | FileCheck --check-prefix=RV64-MED %s
13 @x = global i32 0, align 4
14 define ptr @global_addr() {
18 @y = extern_weak global i32, align 4
19 define ptr @extern_weak_global_addr() {
23 @z = dso_local global i32 0, align 4
24 define ptr @local_global_addr() {
33 tracksRegLiveness: true
35 - { id: 0, class: gprb, preferred-register: '' }
38 ; RV64-PIE-LABEL: name: global_addr
39 ; RV64-PIE: [[PseudoLGA:%[0-9]+]]:gpr = PseudoLGA @x :: (dereferenceable invariant load (p0) from got)
40 ; RV64-PIE-NEXT: $x10 = COPY [[PseudoLGA]]
41 ; RV64-PIE-NEXT: PseudoRET implicit $x10
43 ; RV64-NOPIE-TAG-LABEL: name: global_addr
44 ; RV64-NOPIE-TAG: [[PseudoLGA:%[0-9]+]]:gpr = PseudoLGA @x :: (dereferenceable invariant load (p0) from got)
45 ; RV64-NOPIE-TAG-NEXT: $x10 = COPY [[PseudoLGA]]
46 ; RV64-NOPIE-TAG-NEXT: PseudoRET implicit $x10
48 ; RV64-SMALL-NOPIE-NOTAG-LABEL: name: global_addr
49 ; RV64-SMALL-NOPIE-NOTAG: [[LUI:%[0-9]+]]:gpr = LUI target-flags(riscv-hi) @x
50 ; RV64-SMALL-NOPIE-NOTAG-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI [[LUI]], target-flags(riscv-lo) @x
51 ; RV64-SMALL-NOPIE-NOTAG-NEXT: $x10 = COPY [[ADDI]]
52 ; RV64-SMALL-NOPIE-NOTAG-NEXT: PseudoRET implicit $x10
54 ; RV64-MED-LABEL: name: global_addr
55 ; RV64-MED: [[PseudoLLA:%[0-9]+]]:gpr = PseudoLLA @x
56 ; RV64-MED-NEXT: $x10 = COPY [[PseudoLLA]]
57 ; RV64-MED-NEXT: PseudoRET implicit $x10
58 %0:gprb(p0) = G_GLOBAL_VALUE @x
60 PseudoRET implicit $x10
63 name: extern_weak_global_addr
66 tracksRegLiveness: true
68 - { id: 0, class: gprb, preferred-register: '' }
71 ; RV64-PIE-LABEL: name: extern_weak_global_addr
72 ; RV64-PIE: [[PseudoLGA:%[0-9]+]]:gpr = PseudoLGA @y :: (dereferenceable invariant load (p0) from got)
73 ; RV64-PIE-NEXT: $x10 = COPY [[PseudoLGA]]
74 ; RV64-PIE-NEXT: PseudoRET implicit $x10
76 ; RV64-NOPIE-TAG-LABEL: name: extern_weak_global_addr
77 ; RV64-NOPIE-TAG: [[PseudoLGA:%[0-9]+]]:gpr = PseudoLGA @y :: (dereferenceable invariant load (p0) from got)
78 ; RV64-NOPIE-TAG-NEXT: $x10 = COPY [[PseudoLGA]]
79 ; RV64-NOPIE-TAG-NEXT: PseudoRET implicit $x10
81 ; RV64-SMALL-NOPIE-NOTAG-LABEL: name: extern_weak_global_addr
82 ; RV64-SMALL-NOPIE-NOTAG: [[LUI:%[0-9]+]]:gpr = LUI target-flags(riscv-hi) @y
83 ; RV64-SMALL-NOPIE-NOTAG-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI [[LUI]], target-flags(riscv-lo) @y
84 ; RV64-SMALL-NOPIE-NOTAG-NEXT: $x10 = COPY [[ADDI]]
85 ; RV64-SMALL-NOPIE-NOTAG-NEXT: PseudoRET implicit $x10
87 ; RV64-MED-LABEL: name: extern_weak_global_addr
88 ; RV64-MED: [[PseudoLGA:%[0-9]+]]:gpr = PseudoLGA @y :: (dereferenceable invariant load (p0) from got)
89 ; RV64-MED-NEXT: $x10 = COPY [[PseudoLGA]]
90 ; RV64-MED-NEXT: PseudoRET implicit $x10
91 %0:gprb(p0) = G_GLOBAL_VALUE @y
93 PseudoRET implicit $x10
96 name: local_global_addr
99 tracksRegLiveness: true
101 - { id: 0, class: gprb, preferred-register: '' }
104 ; RV64-PIE-LABEL: name: local_global_addr
105 ; RV64-PIE: [[PseudoLLA:%[0-9]+]]:gpr = PseudoLLA @z
106 ; RV64-PIE-NEXT: $x10 = COPY [[PseudoLLA]]
107 ; RV64-PIE-NEXT: PseudoRET implicit $x10
109 ; RV64-NOPIE-TAG-LABEL: name: local_global_addr
110 ; RV64-NOPIE-TAG: [[PseudoLGA:%[0-9]+]]:gpr = PseudoLGA @z :: (dereferenceable invariant load (p0) from got)
111 ; RV64-NOPIE-TAG-NEXT: $x10 = COPY [[PseudoLGA]]
112 ; RV64-NOPIE-TAG-NEXT: PseudoRET implicit $x10
114 ; RV64-SMALL-NOPIE-NOTAG-LABEL: name: local_global_addr
115 ; RV64-SMALL-NOPIE-NOTAG: [[LUI:%[0-9]+]]:gpr = LUI target-flags(riscv-hi) @z
116 ; RV64-SMALL-NOPIE-NOTAG-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI [[LUI]], target-flags(riscv-lo) @z
117 ; RV64-SMALL-NOPIE-NOTAG-NEXT: $x10 = COPY [[ADDI]]
118 ; RV64-SMALL-NOPIE-NOTAG-NEXT: PseudoRET implicit $x10
120 ; RV64-MED-LABEL: name: local_global_addr
121 ; RV64-MED: [[PseudoLLA:%[0-9]+]]:gpr = PseudoLLA @z
122 ; RV64-MED-NEXT: $x10 = COPY [[PseudoLLA]]
123 ; RV64-MED-NEXT: PseudoRET implicit $x10
124 %0:gprb(p0) = G_GLOBAL_VALUE @z
126 PseudoRET implicit $x10