This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Fix thunk alignment issue when using pc-rel instruction
ClosedPublic

Authored by NeHuang on Aug 14 2020, 7:33 AM.

Details

Summary

Thunk alignment is needed when using pc-rel instructions to avoid crossing the 64 byte boundary.

Patched by @nemanjai

Diff Detail

Event Timeline

NeHuang created this revision.Aug 14 2020, 7:33 AM
NeHuang requested review of this revision.Aug 14 2020, 7:33 AM
NeHuang updated this revision to Diff 285706.Aug 14 2020, 11:38 AM
NeHuang edited the summary of this revision. (Show Details)
  • Updated the LIT cases accordingly.
  • Create a test case for thunk alignment fix.
NeHuang edited reviewers, added: sfertile; removed: Sean.Aug 14 2020, 12:12 PM
MaskRay added inline comments.Aug 14 2020, 12:22 PM
lld/test/ELF/ppc64-thunk-alignment.s
1 ↗(On Diff #285706)

I don't think the additional test is necessary. The address differences should be reflected by other tests.

Having too many tests for a feature is also something we should try to avoid.

MaskRay added inline comments.Aug 14 2020, 12:24 PM
lld/test/ELF/ppc64-toc-call-to-pcrel.s
35

Doesn't it have <__toc_save_callee>?

NeHuang updated this revision to Diff 285743.EditedAug 14 2020, 12:56 PM

Thanks MaskRay. The additional test removed.

NeHuang marked 2 inline comments as done.Aug 14 2020, 12:59 PM
NeHuang added inline comments.
lld/test/ELF/ppc64-thunk-alignment.s
1 ↗(On Diff #285706)

Will do.

lld/test/ELF/ppc64-toc-call-to-pcrel.s
35

Sorry I did not quite get your point. 0x10020040 is the start address of __toc_save_callee stub.

NeHuang marked 2 inline comments as done.Aug 14 2020, 1:02 PM
MaskRay added inline comments.Aug 14 2020, 1:33 PM
lld/test/ELF/ppc64-toc-call-to-pcrel.s
35

For b and bl , objdump -d symbolizes the target address. If it symbolizes bfl and the result is meaningful, please add <__toc_save_callee>

NeHuang added inline comments.Aug 14 2020, 2:08 PM
lld/test/ELF/ppc64-toc-call-to-pcrel.s
35

Thanks for the clarification. Run object dump with llvm-objdump -d --no-show-raw-insn --mcpu=future ppc64-toc-call-to-pcrel.s.tmp and got results as below, I do not think the dis-assembler gives us the stub name for bfl and we can not add <__toc_save_callee> here.

...
1002002c: lwz 3, 32724(30)
10020030: bfl 0, 0x10020040
10020034: ld 2, 24(1)
...
NeHuang marked an inline comment as done.Aug 14 2020, 2:27 PM
sfertile accepted this revision.Aug 16 2020, 6:01 PM

LGTM.

This revision is now accepted and ready to land.Aug 16 2020, 6:01 PM
MaskRay accepted this revision.Aug 16 2020, 7:12 PM