diff --git a/llvm/test/CodeGen/AArch64/tagged-globals.ll b/llvm/test/CodeGen/AArch64/tagged-globals-pic.ll similarity index 80% rename from llvm/test/CodeGen/AArch64/tagged-globals.ll rename to llvm/test/CodeGen/AArch64/tagged-globals-pic.ll index cdca6c7a1fba..0f0df91352bd 100644 --- a/llvm/test/CodeGen/AArch64/tagged-globals.ll +++ b/llvm/test/CodeGen/AArch64/tagged-globals-pic.ll @@ -1,5 +1,3 @@ -; RUN: llc --relocation-model=static < %s \ -; RUN: | FileCheck %s --check-prefixes=CHECK-STATIC,CHECK-SELECTIONDAGISEL ; RUN: llc --relocation-model=pic < %s \ ; RUN: | FileCheck %s --check-prefix=CHECK-PIC @@ -14,8 +12,6 @@ ; things are a problem as GlobalISel is only used by default at -O0, so we don't ; mind the code size and performance increase. -; RUN: llc --aarch64-enable-global-isel-at-O=0 -O0 < %s \ -; RUN: | FileCheck %s --check-prefixes=CHECK-STATIC,CHECK-GLOBALISEL ; RUN: llc --aarch64-enable-global-isel-at-O=0 -O0 --relocation-model=pic < %s \ ; RUN: | FileCheck %s --check-prefix=CHECK-PIC @@ -26,15 +22,6 @@ target triple = "aarch64-unknown-linux-android" declare void @func() define i32* @global_addr() #0 { - ; Static relocation model has common codegen between SelectionDAGISel and - ; GlobalISel when the address-taken of a global isn't folded into a load or - ; store instruction. - ; CHECK-STATIC: global_addr: - ; CHECK-STATIC: adrp [[REG:x[0-9]+]], :pg_hi21_nc:global - ; CHECK-STATIC: movk [[REG]], #:prel_g3:global+4294967296 - ; CHECK-STATIC: add x0, [[REG]], :lo12:global - ; CHECK-STATIC: ret - ; CHECK-PIC: global_addr: ; CHECK-PIC: adrp [[REG:x[0-9]+]], :got:global ; CHECK-PIC: ldr x0, {{\[}}[[REG]], :got_lo12:global] @@ -90,11 +77,6 @@ define void @global_store() #0 { } define void ()* @func_addr() #0 { - ; CHECK-STATIC: func_addr: - ; CHECK-STATIC: adrp [[REG:x[0-9]+]], func - ; CHECK-STATIC: add x0, [[REG]], :lo12:func - ; CHECK-STATIC: ret - ; CHECK-PIC: func_addr: ; CHECK-PIC: adrp [[REG:x[0-9]+]], :got:func ; CHECK-PIC: ldr x0, {{\[}}[[REG]], :got_lo12:func] diff --git a/llvm/test/CodeGen/AArch64/tagged-globals-static.ll b/llvm/test/CodeGen/AArch64/tagged-globals-static.ll new file mode 100644 index 000000000000..ba8bc26ffee1 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/tagged-globals-static.ll @@ -0,0 +1,69 @@ +; RUN: llc --relocation-model=static < %s \ +; RUN: | FileCheck %s --check-prefixes=CHECK-STATIC,CHECK-SELECTIONDAGISEL + +; RUN: llc --aarch64-enable-global-isel-at-O=0 -O0 < %s \ +; RUN: | FileCheck %s --check-prefixes=CHECK-STATIC,CHECK-GLOBALISEL + +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "aarch64-unknown-linux-android" + +@global = external dso_local global i32 +declare void @func() + +define i32* @global_addr() #0 { + ; Static relocation model has common codegen between SelectionDAGISel and + ; GlobalISel when the address-taken of a global isn't folded into a load or + ; store instruction. + ; CHECK-STATIC: global_addr: + ; CHECK-STATIC: adrp [[REG:x[0-9]+]], :pg_hi21_nc:global + ; CHECK-STATIC: movk [[REG]], #:prel_g3:global+4294967296 + ; CHECK-STATIC: add x0, [[REG]], :lo12:global + ; CHECK-STATIC: ret + + ret i32* @global +} + +define i32 @global_load() #0 { + ; CHECK-SELECTIONDAGISEL: global_load: + ; CHECK-SELECTIONDAGISEL: adrp [[REG:x[0-9]+]], :pg_hi21_nc:global + ; CHECK-SELECTIONDAGISEL: ldr w0, {{\[}}[[REG]], :lo12:global{{\]}} + ; CHECK-SELECTIONDAGISEL: ret + + ; CHECK-GLOBALISEL: global_load: + ; CHECK-GLOBALISEL: adrp [[REG:x[0-9]+]], :pg_hi21_nc:global + ; CHECK-GLOBALISEL: movk [[REG]], #:prel_g3:global+4294967296 + ; CHECK-GLOBALISEL: add [[REG]], [[REG]], :lo12:global + ; CHECK-GLOBALISEL: ldr w0, {{\[}}[[REG]]{{\]}} + ; CHECK-GLOBALISEL: ret + + %load = load i32, i32* @global + ret i32 %load +} + +define void @global_store() #0 { + ; CHECK-SELECTIONDAGISEL: global_store: + ; CHECK-SELECTIONDAGISEL: adrp [[REG:x[0-9]+]], :pg_hi21_nc:global + ; CHECK-SELECTIONDAGISEL: str wzr, {{\[}}[[REG]], :lo12:global{{\]}} + ; CHECK-SELECTIONDAGISEL: ret + + ; CHECK-GLOBALISEL: global_store: + ; CHECK-GLOBALISEL: adrp [[REG:x[0-9]+]], :pg_hi21_nc:global + ; CHECK-GLOBALISEL: movk [[REG]], #:prel_g3:global+4294967296 + ; CHECK-GLOBALISEL: add [[REG]], [[REG]], :lo12:global + ; CHECK-GLOBALISEL: str wzr, {{\[}}[[REG]]{{\]}} + ; CHECK-GLOBALISEL: ret + + store i32 0, i32* @global + ret void +} + +define void ()* @func_addr() #0 { + ; CHECK-STATIC: func_addr: + ; CHECK-STATIC: adrp [[REG:x[0-9]+]], func + ; CHECK-STATIC: add x0, [[REG]], :lo12:func + ; CHECK-STATIC: ret + + ret void ()* @func +} + +attributes #0 = { "target-features"="+tagged-globals" } diff --git a/llvm/test/tools/gold/X86/relocation-model-pic.ll b/llvm/test/tools/gold/X86/relocation-model-pic.ll index 30a55da8698e..a0f6020db48d 100644 --- a/llvm/test/tools/gold/X86/relocation-model-pic.ll +++ b/llvm/test/tools/gold/X86/relocation-model-pic.ll @@ -24,11 +24,6 @@ ; RUN: --plugin-opt=save-temps %t.o -o %t-out ; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=PIC -; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \ -; RUN: --export-dynamic --noinhibit-exec \ -; RUN: --plugin-opt=save-temps %t.o -o %t-out -; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=STATIC - ; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \ ; RUN: -r \ ; RUN: --plugin-opt=save-temps %t.o -o %t-out @@ -36,7 +31,6 @@ ; PIC: R_X86_64_GOTPCREL foo -; STATIC: R_X86_64_PC32 foo target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu"