This is an archive of the discontinued LLVM Phabricator instance.

[BOLT][AArch64] Replace NOP with adrp in AdrRelaxationPass to preserve relative offsets.
ClosedPublic

Authored by treapster on Feb 13 2023, 1:32 AM.

Details

Summary

Avoid replacing one adr instruction with two adrp+add by utilizing linker-provided nops when they are present. By doing so we preserve relative offsets of next instructions in a function which reduces chances to break undetected jump tables. This commit makes release-mode lld-linked clang, lld and etc work after BOLT, because they have jump tables which rely on offsets in a function.

Diff Detail

Event Timeline

treapster created this revision.Feb 13 2023, 1:32 AM
Herald added a reviewer: Amir. · View Herald Transcript
Herald added a reviewer: maksfb. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
treapster requested review of this revision.Feb 13 2023, 1:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 13 2023, 1:32 AM

Looks good to me, but who wrote this was @yota9. @yota9 can you take a look at these changes?

bolt/test/runtime/AArch64/adrrelaxationpass.s
3

nit: I think this file is 80column, can you format the text?

18

nit: break command line for 80-column:

# RUN: not llvm-bolt %t.exe -o %t.bolt --adr-relaxation=true --strict \
# RUN:   2>&1 | FileCheck %s --check-prefix CHECK-ERROR
yota9 accepted this revision.Feb 21 2023, 1:30 PM
yota9 added a subscriber: rafaelauler.

LGTM, please check @rafaelauler comments.

This revision is now accepted and ready to land.Feb 21 2023, 1:30 PM
treapster marked 2 inline comments as done.Feb 22 2023, 1:29 AM