[BOLT][AArch64] Replace NOP with adrp in AdrRelaxationPass to preserve relative offsets.
authorDenis Revunov <revunov.denis@huawei-partners.com>
Wed, 18 Jan 2023 14:15:25 +0000 (09:15 -0500)
committerDenis Revunov <revunov.denis@huawei-partners.com>
Wed, 22 Feb 2023 09:45:19 +0000 (04:45 -0500)
commitabc1f3329831606b06a934bba8ac3fc3df522e07
tree90d42123d4911fe3f4b6d291084f4ea7f6507333
parent718cea8e6864b9d185f14ee361fce77dc32c5cb8
[BOLT][AArch64] Replace NOP with adrp in AdrRelaxationPass to preserve relative offsets.

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.

Reviewed By: rafauler, yota9

Differential Revision: https://reviews.llvm.org/D143887
bolt/lib/Passes/ADRRelaxationPass.cpp
bolt/test/runtime/AArch64/adrrelaxationpass.s