1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --no-generate-body-for-unused-prefixes
2 ; RUN: llc -mtriple=riscv64 --relocation-model=pic < %s | FileCheck %s
3 ; RUN: llc -mtriple=riscv64 --relocation-model=static < %s | FileCheck %s
5 @global_ext = external global i32
6 @global_int = internal global i32 0
9 define ptr @global_addr() #0 {
10 ; CHECK-LABEL: global_addr:
12 ; CHECK-NEXT: .Lpcrel_hi0:
13 ; CHECK-NEXT: auipc a0, %got_pcrel_hi(global_ext)
14 ; CHECK-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi0)(a0)
19 define i32 @global_load() #0 {
20 ; CHECK-LABEL: global_load:
22 ; CHECK-NEXT: .Lpcrel_hi1:
23 ; CHECK-NEXT: auipc a0, %got_pcrel_hi(global_ext)
24 ; CHECK-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi1)(a0)
25 ; CHECK-NEXT: lw a0, 0(a0)
27 %load = load i32, ptr @global_ext
31 define void @global_store() #0 {
32 ; CHECK-LABEL: global_store:
34 ; CHECK-NEXT: .Lpcrel_hi2:
35 ; CHECK-NEXT: auipc a0, %got_pcrel_hi(global_ext)
36 ; CHECK-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi2)(a0)
37 ; CHECK-NEXT: sw zero, 0(a0)
39 store i32 0, ptr @global_ext
43 define ptr @global_int_addr() #0 {
44 ; CHECK-LABEL: global_int_addr:
46 ; CHECK-NEXT: .Lpcrel_hi3:
47 ; CHECK-NEXT: auipc a0, %got_pcrel_hi(global_int)
48 ; CHECK-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi3)(a0)
53 define i32 @global_int_load() #0 {
54 ; CHECK-LABEL: global_int_load:
56 ; CHECK-NEXT: .Lpcrel_hi4:
57 ; CHECK-NEXT: auipc a0, %got_pcrel_hi(global_int)
58 ; CHECK-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi4)(a0)
59 ; CHECK-NEXT: lw a0, 0(a0)
61 %load = load i32, ptr @global_int
65 define void @global_int_store() #0 {
66 ; CHECK-LABEL: global_int_store:
68 ; CHECK-NEXT: .Lpcrel_hi5:
69 ; CHECK-NEXT: auipc a0, %got_pcrel_hi(global_int)
70 ; CHECK-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi5)(a0)
71 ; CHECK-NEXT: sw zero, 0(a0)
73 store i32 0, ptr @global_int
77 define ptr @func_addr() #0 {
78 ; CHECK-LABEL: func_addr:
80 ; CHECK-NEXT: .Lpcrel_hi6:
81 ; CHECK-NEXT: auipc a0, %got_pcrel_hi(func)
82 ; CHECK-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi6)(a0)
87 attributes #0 = { "target-features"="+tagged-globals" }