Changeset View
Changeset View
Standalone View
Standalone View
llvm/test/CodeGen/RISCV/tagged-globals.ll
- This file was added.
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --no-generate-body-for-unused-prefixes | ||||||||||||
; RUN: llc --relocation-model=pic < %s | FileCheck %s | ||||||||||||
; RUN: llc --relocation-model=static < %s | FileCheck %s | ||||||||||||
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" | ||||||||||||
target triple = "riscv64-unknown-linux" | ||||||||||||
jrtc27: These shouldn't be here | ||||||||||||
smdAuthorUnsubmitted fixed, thanks smd: fixed, thanks | ||||||||||||
@global_ext = external global i32 | ||||||||||||
@global_int = internal global i32 0 | ||||||||||||
Not Done ReplyInline ActionsMaybe add one more testcase to show @global = internal global i32 0 will always access via GOT with +tagged-globals even --relocation-model=pic? kito-cheng: Maybe add one more testcase to show `@global = internal global i32 0` will always access via… | ||||||||||||
Done, thanks smd: Done, thanks | ||||||||||||
declare void @func() | ||||||||||||
Not Done ReplyInline ActionsNit: globalint makes it sound it's an integer, can you tweak that somehow? luismarques: Nit: `globalint` makes it sound it's an `integer`, can you tweak that somehow? | ||||||||||||
Not Done ReplyInline Actions
luismarques: | ||||||||||||
fixed, thanks smd: fixed, thanks | ||||||||||||
define i32* @global_addr() #0 { | ||||||||||||
; CHECK-LABEL: global_addr: | ||||||||||||
; CHECK: # %bb.0: | ||||||||||||
; CHECK-NEXT: .Lpcrel_hi0: | ||||||||||||
; CHECK-NEXT: auipc a0, %got_pcrel_hi(global_ext) | ||||||||||||
; CHECK-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi0)(a0) | ||||||||||||
; CHECK-NEXT: ret | ||||||||||||
ret i32* @global_ext | ||||||||||||
} | ||||||||||||
define i32 @global_load() #0 { | ||||||||||||
; CHECK-LABEL: global_load: | ||||||||||||
; CHECK: # %bb.0: | ||||||||||||
; CHECK-NEXT: .Lpcrel_hi1: | ||||||||||||
; CHECK-NEXT: auipc a0, %got_pcrel_hi(global_ext) | ||||||||||||
; CHECK-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi1)(a0) | ||||||||||||
; CHECK-NEXT: lw a0, 0(a0) | ||||||||||||
; CHECK-NEXT: ret | ||||||||||||
%load = load i32, i32* @global_ext | ||||||||||||
ret i32 %load | ||||||||||||
} | ||||||||||||
define void @global_store() #0 { | ||||||||||||
; CHECK-LABEL: global_store: | ||||||||||||
; CHECK: # %bb.0: | ||||||||||||
; CHECK-NEXT: .Lpcrel_hi2: | ||||||||||||
; CHECK-NEXT: auipc a0, %got_pcrel_hi(global_ext) | ||||||||||||
; CHECK-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi2)(a0) | ||||||||||||
; CHECK-NEXT: sw zero, 0(a0) | ||||||||||||
; CHECK-NEXT: ret | ||||||||||||
store i32 0, i32* @global_ext | ||||||||||||
ret void | ||||||||||||
} | ||||||||||||
define i32* @global_int_addr() #0 { | ||||||||||||
; CHECK-LABEL: global_int_addr: | ||||||||||||
; CHECK: # %bb.0: | ||||||||||||
; CHECK-NEXT: .Lpcrel_hi3: | ||||||||||||
; CHECK-NEXT: auipc a0, %got_pcrel_hi(global_int) | ||||||||||||
; CHECK-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi3)(a0) | ||||||||||||
; CHECK-NEXT: ret | ||||||||||||
ret i32* @global_int | ||||||||||||
} | ||||||||||||
define i32 @global_int_load() #0 { | ||||||||||||
; CHECK-LABEL: global_int_load: | ||||||||||||
; CHECK: # %bb.0: | ||||||||||||
; CHECK-NEXT: .Lpcrel_hi4: | ||||||||||||
; CHECK-NEXT: auipc a0, %got_pcrel_hi(global_int) | ||||||||||||
; CHECK-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi4)(a0) | ||||||||||||
; CHECK-NEXT: lw a0, 0(a0) | ||||||||||||
; CHECK-NEXT: ret | ||||||||||||
%load = load i32, i32* @global_int | ||||||||||||
ret i32 %load | ||||||||||||
} | ||||||||||||
define void @global_int_store() #0 { | ||||||||||||
; CHECK-LABEL: global_int_store: | ||||||||||||
; CHECK: # %bb.0: | ||||||||||||
; CHECK-NEXT: .Lpcrel_hi5: | ||||||||||||
; CHECK-NEXT: auipc a0, %got_pcrel_hi(global_int) | ||||||||||||
; CHECK-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi5)(a0) | ||||||||||||
; CHECK-NEXT: sw zero, 0(a0) | ||||||||||||
; CHECK-NEXT: ret | ||||||||||||
store i32 0, i32* @global_int | ||||||||||||
ret void | ||||||||||||
} | ||||||||||||
define void ()* @func_addr() #0 { | ||||||||||||
; CHECK-LABEL: func_addr: | ||||||||||||
; CHECK: # %bb.0: | ||||||||||||
; CHECK-NEXT: .Lpcrel_hi6: | ||||||||||||
; CHECK-NEXT: auipc a0, %got_pcrel_hi(func) | ||||||||||||
; CHECK-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi6)(a0) | ||||||||||||
; CHECK-NEXT: ret | ||||||||||||
ret void ()* @func | ||||||||||||
} | ||||||||||||
attributes #0 = { "target-features"="+tagged-globals" } |
These shouldn't be here