Page MenuHomePhabricator

[LLD][PowerPC] Add support for R_PPC64_TPREL34 used in TLS Local Exec
ClosedPublic

Authored by stefanp on Aug 26 2020, 4:08 AM.

Details

Summary

Add Thread Local Storage Local Exec support to LLD. This is to support PC Relative addressing of Local Exec.
The patch teaches LLD to handle:

paddi r9, r13, x1@tprel

The relocation is:

R_PPC_TPREL34

Diff Detail

Event Timeline

stefanp created this revision.Aug 26 2020, 4:08 AM
Herald added a project: Restricted Project. · View Herald Transcript
stefanp requested review of this revision.Aug 26 2020, 4:08 AM
NeHuang added inline comments.Sep 1 2020, 1:20 PM
lld/test/ELF/ppc64-tls-pcrel-le.s
4

Do we need the address set up for this case? Seems we are not checking/verifying the offset using in the paddi to access x, y and z

55

what is the test purpose of adding symbol y, it seems identical as the case for symbol x?

stefanp updated this revision to Diff 289679.Sep 3 2020, 4:32 AM

Removed the linker script that was not needed.
Added a quick summary of the test case.

lld/test/ELF/ppc64-tls-pcrel-le.s
4

That is a good point. All of the paddi instructions are not PC Relative in this case, they are all TP relative. Therefore the position of the paddi doesn't matter. I'll remove the sections.

55

I know that x and y are pretty much the same thing. The reason why I added the y was because I wanted a variable that was not just at TP - 0x7000. I wanted to check that we got the correct offset based on the size of x. Technically z could also serve this purpose but I would prefer to keep all three variables to keep what each one is testing separate.

NeHuang added inline comments.Sep 3 2020, 8:34 AM
lld/test/ELF/ppc64-tls-pcrel-le.s
18

SYMBOL-NEXT

19

SYMBOL-NEXT

21

<LocalExecAddrX>: and same for the CHECK-LABEL cases below

NeHuang accepted this revision.Sep 3 2020, 8:34 AM

LGTM. I only have some comments on the nits.

This revision is now accepted and ready to land.Sep 3 2020, 8:34 AM

[LLD][PowerPC] Add support for TLS Local Exec

Local Exec support exists, so this subject may be a bit confusing. This patch is about R_PPC64_TPREL34.

lld/test/ELF/ppc64-tls-pcrel-le.s
78

You can remove .size directives since they are not significant

stefanp updated this revision to Diff 289761.Sep 3 2020, 10:38 AM
stefanp retitled this revision from [LLD][PowerPC] Add support for TLS Local Exec to [LLD][PowerPC] Add support for R_PPC64_TPREL34 used in TLS Local Exec.

Fixed a couple of things on the test case.
Added the function name inside <>:.
Removed the .size directives.
Added SYMBOL-NEXT: where possible.

I need to apply your patch with curl -L 'https://reviews.llvm.org/D86608?download=1' | patch -p0 (for most other reviews I use -p1. arc diff uploaded patch can be applied with -p1

https://llvm.org/docs/GettingStarted.html#sending-patches

MaskRay added inline comments.Sep 10 2020, 1:45 PM
lld/test/ELF/ppc64-tls-pcrel-le.s
21

Consider simplifying the test

# CHECK-LABEL: <LocalExecAddr>:
# CHECK-NEXT:    paddi 3, 13, -28672, 0
# CHECK-NEXT:    paddi 3, 13, -28668, 0
# CHECK-NEXT:    

LocalExecAddr:
  paddi 3, 13, x@TPREL, 0
  paddi 3, 13, y@TPREL, 0
  paddi 3, 13, z@TPREL+12, 0

# CHECK-LABEL: <LocalExecVal>:
# CHECK-NEXT:    ...
# CHECK-NEXT:    ...

LocalExecVal:
  paddi 3, 13, x@TPREL, 0
  lwz 3, 0(3)
  paddi 3, 13, y@TPREL, 0
  lwz 3, 0(3)
  paddi 3, 13, z@TPREL+12, 0
  lwz 3, 0(3)
MaskRay accepted this revision.Sep 10 2020, 1:46 PM
stefanp updated this revision to Diff 291210.Sep 11 2020, 7:20 AM

Thank you for the reviews!

I'm sorry about not consistently using arc. I sometimes just create a patch and upload that. I'll try to use arc more consistently for Phabricator.

I've updated the test case to simplify it a little.
I'll wait until D83404 is in and then I'll commit this patch.