This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Implement createRelocation for AArch64
ClosedPublic

Authored by Kepontry on Jul 22 2023, 2:24 AM.

Details

Summary
The implementation is based on the X86 version, with the same code
of symbol and addend extraction. The differences include the
support for RelType `R_AARCH64_CALL26` and the deletion of 8-bit
relocation.

Diff Detail

Event Timeline

Kepontry created this revision.Jul 22 2023, 2:24 AM
Kepontry requested review of this revision.Jul 22 2023, 2:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2023, 2:24 AM
Kepontry updated this revision to Diff 543171.Jul 22 2023, 4:50 AM

clang-format

yota9 added a comment.Jul 24 2023, 1:19 AM

Hi, thanks for the patch! Can you please add test for this?

hzq added a subscriber: hzq.Jul 27 2023, 5:32 AM
Kepontry updated this revision to Diff 545672.Jul 31 2023, 8:06 AM
Kepontry updated this revision to Diff 546028.Aug 1 2023, 6:41 AM

Fixed some compilation warnings. Now this patch is ready for review.

Amir added a comment.Aug 1 2023, 7:51 PM

Can you please retitle it as "[BOLT] Implement createRelocation for AArch64"?

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
1207–1213

This part looks to be common for X86 and AArch64. Can you please factor it out (in a separate diff)?

Kepontry retitled this revision from [BOLT] Impl createRelocation for AArch64 to [BOLT] Implement createRelocation for AArch64.Aug 5 2023, 11:20 PM
rafauler added inline comments.Aug 7 2023, 5:30 PM
bolt/lib/Core/Relocation.cpp
349–351

What happens with this assert() when the call target is at a lower address than the call instruction? (PC > Value).

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
1207–1209

structured binding here too, just like D157217

Kepontry updated this revision to Diff 548507.Aug 9 2023, 1:07 AM
Kepontry marked 2 inline comments as done.Aug 9 2023, 1:17 AM
Kepontry added inline comments.
bolt/lib/Core/Relocation.cpp
349–351

Oh, it was my mistake. This assert() now checks whether "Value(i.e., offset) + 128M" is less than 256M.

Amir added inline comments.Aug 9 2023, 4:37 PM
bolt/lib/Core/Relocation.cpp
350
Kepontry updated this revision to Diff 548842.Aug 9 2023, 6:09 PM
This revision is now accepted and ready to land.Aug 16 2023, 11:18 AM