1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00
llvm-mirror/test/CodeGen/PowerPC/ppc32-pic.ll
Fangrui Song ad4c9cc3ec [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
2019-06-25 15:56:32 +00:00

31 lines
1.1 KiB
LLVM

; 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, ...)
define i32 @foo() {
entry:
%0 = load i32, i32* @bar, align 4
%call = call i32 (i32, ...) @call_foo(i32 %0, i32 0, i32 1, i32 2, i32 4, i32 8, i32 16, i32 32, i32 64)
ret i32 0
}
!llvm.module.flags = !{!0}
!0 = !{i32 1, !"PIC Level", i32 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)