[PATCH] D61610: [PPC64] implement Thunk Section Spacing
Alfredo Dal'Ava JĂșnior via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 7 08:29:46 PDT 2019
adalava updated this revision to Diff 198480.
adalava edited the summary of this revision.
adalava added a comment.
- add space reservation, add comments and improve test
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61610/new/
https://reviews.llvm.org/D61610
Files:
lld/ELF/Arch/PPC64.cpp
lld/test/ELF/Inputs/ppc64-far-branch-rangethunk.s
lld/test/ELF/ppc64-branch-thunkspacing.s
Index: lld/test/ELF/ppc64-branch-thunkspacing.s
===================================================================
--- lld/test/ELF/ppc64-branch-thunkspacing.s
+++ lld/test/ELF/ppc64-branch-thunkspacing.s
@@ -1,20 +1,21 @@
# REQUIRES: ppc
-# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-freebsd13.0 %s -o %t
-# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-freebsd13.0 %S/Inputs/ppc64-far-branch-rangethunk.s -o %tfar
-# RUN: ld.lld %t %tfar -o %t2 2>&1
-# RUN: llvm-objdump -d -triple=powerpc64-unknown-freebsd13.0 %t2 | FileCheck %s
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-freebsd13.0 %s -o %t.o
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-freebsd13.0 %S/Inputs/ppc64-far-branch-rangethunk.s -o %tfar.o
+# RUN: ld.lld %t.o %tfar.o -o %t2
+# RUN: llvm-objdump -d %t2 | FileCheck %s
+
+.section .init,"ax", at progbits
+.align 2
+.globl _start
+.type _start, at function
- .section .init,"ax", at progbits
- .align 2
- .globl _start
- .type _start, at function
_start:
- stwu 1,-16(1)
- mflr 0
- stw 31,12(1)
- stw 0,20(1)
- mr 31,1
+ stwu 1,-16(1)
+ mflr 0
+ stw 31,12(1)
+ stw 0,20(1)
+ mr 31,1
bl too_far1
Index: lld/test/ELF/Inputs/ppc64-far-branch-rangethunk.s
===================================================================
--- lld/test/ELF/Inputs/ppc64-far-branch-rangethunk.s
+++ lld/test/ELF/Inputs/ppc64-far-branch-rangethunk.s
@@ -1,4 +1,6 @@
+.section .init,"ax", at progbits,unique,2
+.align 2
.global too_far1
.type too_far1,%function
Index: lld/ELF/Arch/PPC64.cpp
===================================================================
--- lld/ELF/Arch/PPC64.cpp
+++ lld/ELF/Arch/PPC64.cpp
@@ -927,8 +927,22 @@
}
uint32_t PPC64::getThunkSectionSpacing() const {
- // REL14 range
- return 0x8000;
+ // PowerPC64 has the following basic branch instructions:
+ //
+ // - b[l,a] PPC64_REL24 range [33,554,432...33,554,428]
+ // - bc[l,a] PPC64_REL14 range [-32,768...32764]
+ //
+ // We take the most strict range and intentionally use a lower
+ // size than the maximum branch range so the end of the ThunkSection
+ // is more likely to be within range of the branch instruction that
+ // is furthest away.
+ //
+ // Reducing it in 0x1000 allow creating 256 16 byte Thunks at any
+ // offset in a ThunkSection without risk of a branch to one of the
+ // Thunks going out of range.
+ //
+ // See comment in Arch/ARM.cpp for more detais of getThunkSectionSpacing().
+ return 0x8000 - 0x1000;
}
TargetInfo *elf::getPPC64TargetInfo() {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61610.198480.patch
Type: text/x-patch
Size: 2605 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190507/1643768a/attachment.bin>
More information about the llvm-commits
mailing list