Skip to content

Commit fd32639

Browse files
committed
[test] Split some tests which test both static and pic relocation models
TargetMachine::shouldAssumeDSOLocal currently implies dso_local for Static. Split some tests so that these `external dso_local global` will align with the Clang behavior.
1 parent 03fc4f2 commit fd32639

File tree

3 files changed

+69
-24
lines changed

3 files changed

+69
-24
lines changed

llvm/test/CodeGen/AArch64/tagged-globals.ll renamed to llvm/test/CodeGen/AArch64/tagged-globals-pic.ll

-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
; RUN: llc --relocation-model=static < %s \
2-
; RUN: | FileCheck %s --check-prefixes=CHECK-STATIC,CHECK-SELECTIONDAGISEL
31
; RUN: llc --relocation-model=pic < %s \
42
; RUN: | FileCheck %s --check-prefix=CHECK-PIC
53

@@ -14,8 +12,6 @@
1412
; things are a problem as GlobalISel is only used by default at -O0, so we don't
1513
; mind the code size and performance increase.
1614

17-
; RUN: llc --aarch64-enable-global-isel-at-O=0 -O0 < %s \
18-
; RUN: | FileCheck %s --check-prefixes=CHECK-STATIC,CHECK-GLOBALISEL
1915
; RUN: llc --aarch64-enable-global-isel-at-O=0 -O0 --relocation-model=pic < %s \
2016
; RUN: | FileCheck %s --check-prefix=CHECK-PIC
2117

@@ -26,15 +22,6 @@ target triple = "aarch64-unknown-linux-android"
2622
declare void @func()
2723

2824
define i32* @global_addr() #0 {
29-
; Static relocation model has common codegen between SelectionDAGISel and
30-
; GlobalISel when the address-taken of a global isn't folded into a load or
31-
; store instruction.
32-
; CHECK-STATIC: global_addr:
33-
; CHECK-STATIC: adrp [[REG:x[0-9]+]], :pg_hi21_nc:global
34-
; CHECK-STATIC: movk [[REG]], #:prel_g3:global+4294967296
35-
; CHECK-STATIC: add x0, [[REG]], :lo12:global
36-
; CHECK-STATIC: ret
37-
3825
; CHECK-PIC: global_addr:
3926
; CHECK-PIC: adrp [[REG:x[0-9]+]], :got:global
4027
; CHECK-PIC: ldr x0, {{\[}}[[REG]], :got_lo12:global]
@@ -90,11 +77,6 @@ define void @global_store() #0 {
9077
}
9178

9279
define void ()* @func_addr() #0 {
93-
; CHECK-STATIC: func_addr:
94-
; CHECK-STATIC: adrp [[REG:x[0-9]+]], func
95-
; CHECK-STATIC: add x0, [[REG]], :lo12:func
96-
; CHECK-STATIC: ret
97-
9880
; CHECK-PIC: func_addr:
9981
; CHECK-PIC: adrp [[REG:x[0-9]+]], :got:func
10082
; CHECK-PIC: ldr x0, {{\[}}[[REG]], :got_lo12:func]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
; RUN: llc --relocation-model=static < %s \
2+
; RUN: | FileCheck %s --check-prefixes=CHECK-STATIC,CHECK-SELECTIONDAGISEL
3+
4+
; RUN: llc --aarch64-enable-global-isel-at-O=0 -O0 < %s \
5+
; RUN: | FileCheck %s --check-prefixes=CHECK-STATIC,CHECK-GLOBALISEL
6+
7+
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
8+
target triple = "aarch64-unknown-linux-android"
9+
10+
@global = external dso_local global i32
11+
declare void @func()
12+
13+
define i32* @global_addr() #0 {
14+
; Static relocation model has common codegen between SelectionDAGISel and
15+
; GlobalISel when the address-taken of a global isn't folded into a load or
16+
; store instruction.
17+
; CHECK-STATIC: global_addr:
18+
; CHECK-STATIC: adrp [[REG:x[0-9]+]], :pg_hi21_nc:global
19+
; CHECK-STATIC: movk [[REG]], #:prel_g3:global+4294967296
20+
; CHECK-STATIC: add x0, [[REG]], :lo12:global
21+
; CHECK-STATIC: ret
22+
23+
ret i32* @global
24+
}
25+
26+
define i32 @global_load() #0 {
27+
; CHECK-SELECTIONDAGISEL: global_load:
28+
; CHECK-SELECTIONDAGISEL: adrp [[REG:x[0-9]+]], :pg_hi21_nc:global
29+
; CHECK-SELECTIONDAGISEL: ldr w0, {{\[}}[[REG]], :lo12:global{{\]}}
30+
; CHECK-SELECTIONDAGISEL: ret
31+
32+
; CHECK-GLOBALISEL: global_load:
33+
; CHECK-GLOBALISEL: adrp [[REG:x[0-9]+]], :pg_hi21_nc:global
34+
; CHECK-GLOBALISEL: movk [[REG]], #:prel_g3:global+4294967296
35+
; CHECK-GLOBALISEL: add [[REG]], [[REG]], :lo12:global
36+
; CHECK-GLOBALISEL: ldr w0, {{\[}}[[REG]]{{\]}}
37+
; CHECK-GLOBALISEL: ret
38+
39+
%load = load i32, i32* @global
40+
ret i32 %load
41+
}
42+
43+
define void @global_store() #0 {
44+
; CHECK-SELECTIONDAGISEL: global_store:
45+
; CHECK-SELECTIONDAGISEL: adrp [[REG:x[0-9]+]], :pg_hi21_nc:global
46+
; CHECK-SELECTIONDAGISEL: str wzr, {{\[}}[[REG]], :lo12:global{{\]}}
47+
; CHECK-SELECTIONDAGISEL: ret
48+
49+
; CHECK-GLOBALISEL: global_store:
50+
; CHECK-GLOBALISEL: adrp [[REG:x[0-9]+]], :pg_hi21_nc:global
51+
; CHECK-GLOBALISEL: movk [[REG]], #:prel_g3:global+4294967296
52+
; CHECK-GLOBALISEL: add [[REG]], [[REG]], :lo12:global
53+
; CHECK-GLOBALISEL: str wzr, {{\[}}[[REG]]{{\]}}
54+
; CHECK-GLOBALISEL: ret
55+
56+
store i32 0, i32* @global
57+
ret void
58+
}
59+
60+
define void ()* @func_addr() #0 {
61+
; CHECK-STATIC: func_addr:
62+
; CHECK-STATIC: adrp [[REG:x[0-9]+]], func
63+
; CHECK-STATIC: add x0, [[REG]], :lo12:func
64+
; CHECK-STATIC: ret
65+
66+
ret void ()* @func
67+
}
68+
69+
attributes #0 = { "target-features"="+tagged-globals" }

llvm/test/tools/gold/X86/relocation-model-pic.ll

-6
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,13 @@
2424
; RUN: --plugin-opt=save-temps %t.o -o %t-out
2525
; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=PIC
2626

27-
; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
28-
; RUN: --export-dynamic --noinhibit-exec \
29-
; RUN: --plugin-opt=save-temps %t.o -o %t-out
30-
; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=STATIC
31-
3227
; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
3328
; RUN: -r \
3429
; RUN: --plugin-opt=save-temps %t.o -o %t-out
3530
; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=PIC
3631

3732

3833
; PIC: R_X86_64_GOTPCREL foo
39-
; STATIC: R_X86_64_PC32 foo
4034

4135
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4236
target triple = "x86_64-unknown-linux-gnu"

0 commit comments

Comments
 (0)