diff options
| author | Fangrui Song <maskray@google.com> | 2019-06-25 15:56:32 +0000 |
|---|---|---|
| committer | Fangrui Song <maskray@google.com> | 2019-06-25 15:56:32 +0000 |
| commit | 96a192ea53717428b7a96673d00d2d68e8542dfb (patch) | |
| tree | 9cb4700772e8a73e40870be611c36d2581a2cdeb /llvm/test/CodeGen | |
| parent | bcf0eb7a6409b083532c020faa85ef219efbfbab (diff) | |
| download | bcm5719-llvm-96a192ea53717428b7a96673d00d2d68e8542dfb.tar.gz bcm5719-llvm-96a192ea53717428b7a96673d00d2d68e8542dfb.zip | |
[PPC32] Support PLT calls for -msecure-plt -fpic
Summary:
In Secure PLT ABI, -fpic is similar to -fPIC. The differences are that:
* -fpic stores the address of _GLOBAL_OFFSET_TABLE_ in r30, while -fPIC stores .got2+0x8000.
* -fpic uses an addend of 0 for R_PPC_PLTREL24, while -fPIC uses 0x8000.
Reviewers: hfinkel, jhibbits, joerg, nemanjai, spetrovic
Reviewed By: jhibbits
Subscribers: adalava, kbarton, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63563
llvm-svn: 364324
Diffstat (limited to 'llvm/test/CodeGen')
| -rw-r--r-- | llvm/test/CodeGen/PowerPC/ppc32-pic.ll | 28 | ||||
| -rw-r--r-- | llvm/test/CodeGen/PowerPC/ppc32-secure-plt-tls2.ll | 18 |
2 files changed, 35 insertions, 11 deletions
diff --git a/llvm/test/CodeGen/PowerPC/ppc32-pic.ll b/llvm/test/CodeGen/PowerPC/ppc32-pic.ll index 79c36b07e49..63a62727de3 100644 --- a/llvm/test/CodeGen/PowerPC/ppc32-pic.ll +++ b/llvm/test/CodeGen/PowerPC/ppc32-pic.ll @@ -1,4 +1,7 @@ -; RUN: llc < %s -mtriple=powerpc-unknown-linux-gnu -relocation-model=pic | FileCheck -check-prefix=SMALL-BSS %s +; RUN: llc < %s -mtriple=powerpc -relocation-model=pic | \ +; RUN: FileCheck -check-prefixes=SMALL,SMALL-BSS %s +; RUN: llc < %s -mtriple=powerpc -relocation-model=pic -mattr=+secure-plt | \ +; RUN: FileCheck -check-prefixes=SMALL,SMALL-SECUREPLT %s @bar = common global i32 0, align 4 declare i32 @call_foo(i32, ...) @@ -12,13 +15,16 @@ entry: !llvm.module.flags = !{!0} !0 = !{i32 1, !"PIC Level", i32 1} -; SMALL-BSS-LABEL:foo: -; SMALL-BSS: stwu 1, -32(1) -; SMALL-BSS: stw 30, 24(1) -; SMALL-BSS: bl _GLOBAL_OFFSET_TABLE_@local-4 -; SMALL-BSS: mflr 30 -; SMALL-BSS-DAG: stw {{[0-9]+}}, 8(1) -; SMALL-BSS-DAG: lwz [[VREG:[0-9]+]], bar@GOT(30) -; SMALL-BSS-DAG: lwz {{[0-9]+}}, 0([[VREG]]) -; SMALL-BSS: bl call_foo@PLT -; SMALL-BSS: lwz 30, 24(1) +; SMALL-LABEL: foo: +; SMALL: stwu 1, -32(1) +; SMALL: stw 30, 24(1) +; SMALL-BSS: bl _GLOBAL_OFFSET_TABLE_@local-4 +; SMALL-SECURE: bl .L0$pb +; SMALL: mflr 30 +; SMALL-SECURE: addis 30, 30, _GLOBAL_OFFSET_TABLE_-.Lo$pb@ha +; SMALL-SECURE: addi 30, 30, _GLOBAL_OFFSET_TABLE_-.Lo$pb@l +; SMALL-DAG: stw {{[0-9]+}}, 8(1) +; SMALL-DAG: lwz [[VREG:[0-9]+]], bar@GOT(30) +; SMALL-DAG: lwz {{[0-9]+}}, 0([[VREG]]) +; SMALL: bl call_foo@PLT{{$}} +; SMALL: lwz 30, 24(1) diff --git a/llvm/test/CodeGen/PowerPC/ppc32-secure-plt-tls2.ll b/llvm/test/CodeGen/PowerPC/ppc32-secure-plt-tls2.ll new file mode 100644 index 00000000000..38ebf99ef72 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/ppc32-secure-plt-tls2.ll @@ -0,0 +1,18 @@ +; RUN: llc < %s -mtriple=powerpc -mattr=+secure-plt -relocation-model=pic | FileCheck -check-prefix=SECURE-PLT-TLS %s + +@a = thread_local local_unnamed_addr global i32 6, align 4 +define i32 @main() local_unnamed_addr #0 { +entry: + %0 = load i32, i32* @a, align 4 + ret i32 %0 +} + + +!llvm.module.flags = !{!0} +!0 = !{i32 7, !"PIC Level", i32 1} + +; SECURE-PLT-TLS: mflr 30 +; SECURE-PLT-TLS-NEXT: addis 30, 30, _GLOBAL_OFFSET_TABLE_-.L0$pb@ha +; SECURE-PLT-TLS-NEXT: addi 30, 30, _GLOBAL_OFFSET_TABLE_-.L0$pb@l +; SECURE-PLT-TLS: addi 3, 30, a@got@tlsgd +; SECURE-PLT-TLS: bl __tls_get_addr(a@tlsgd)@PLT{{$}} |

