[PATCH] D61610: [PPC64] implement Thunk Section Spacing

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 6 23:25:33 PDT 2019


MaskRay added subscribers: peter.smith, atanasyan.
MaskRay added a comment.

@atanasyan Should MIPS override `getThunkSectionSpacing` as well? Then we can make the function pure virtual: `virtual uint32_t getThunkSectionSpacing() const = 0;`



================
Comment at: lld/ELF/Arch/PPC64.cpp:931
+  // REL14 range
+  return 0x8000;
+}
----------------
This probably should be slightly smaller than 0x8000.

@peter.smith probably has idea how the ARM/AArch64 constants were derived.

```
uint32_t AArch64::getThunkSectionSpacing() const {
  // See comment in Arch/ARM.cpp for a more detailed explanation of
  // getThunkSectionSpacing(). For AArch64 the only branches we are permitted to
  // Thunk have a range of +/- 128 MiB
  return (128 * 1024 * 1024) - 0x30000;
}
```


================
Comment at: lld/test/ELF/ppc64-branch-thunkspacing.s:3
+
+# 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
----------------
`-o %t.o`


================
Comment at: lld/test/ELF/ppc64-branch-thunkspacing.s:5
+# 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
----------------
No `2>&1`. It is only used to check warnings/errors.


================
Comment at: lld/test/ELF/ppc64-branch-thunkspacing.s:6
+# RUN: ld.lld  %t %tfar -o %t2 2>&1
+# RUN: llvm-objdump -d -triple=powerpc64-unknown-freebsd13.0 %t2 | FileCheck %s
+
----------------
You can omit `-triple=powerpc64-unknown-freebsd13.0`. llvm-objdump auto detects the triple.


================
Comment at: lld/test/ELF/ppc64-branch-thunkspacing.s:18
+        mr 31,1
+	bl  too_far1
+
----------------
mixed tab and spaces? Probably move the bl instruction to another `.init` section:

```
.section .init,"ax", at progbits,unique,2
.align 2
  bl too_far1
```

to mimic the crti.o crtn.o `.init`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61610/new/

https://reviews.llvm.org/D61610





More information about the llvm-commits mailing list