diff options
author | Denis Revunov <revunov.denis@huawei-partners.com> | 2023-01-18 09:15:25 -0500 |
---|---|---|
committer | Denis Revunov <revunov.denis@huawei-partners.com> | 2023-02-22 04:45:19 -0500 |
commit | abc1f3329831606b06a934bba8ac3fc3df522e07 (patch) | |
tree | 90d42123d4911fe3f4b6d291084f4ea7f6507333 /bolt/test | |
parent | 718cea8e6864b9d185f14ee361fce77dc32c5cb8 (diff) | |
download | llvm-abc1f3329831606b06a934bba8ac3fc3df522e07.tar.gz |
[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
Diffstat (limited to 'bolt/test')
-rw-r--r-- | bolt/test/runtime/AArch64/adrrelaxationpass.s | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/bolt/test/runtime/AArch64/adrrelaxationpass.s b/bolt/test/runtime/AArch64/adrrelaxationpass.s index 904e65df9bf7..5c50cd637192 100644 --- a/bolt/test/runtime/AArch64/adrrelaxationpass.s +++ b/bolt/test/runtime/AArch64/adrrelaxationpass.s @@ -1,5 +1,9 @@ # The second and third ADR instructions are non-local to functions # and must be replaced with ADRP + ADD by BOLT +# Also since main is non-simple, we can't change it's length so we have to +# replace NOP with adrp, and if there is no nop before adr in non-simple +# function, we can't guarantee we didn't break possible jump tables, so we +# fail in strict mode # REQUIRES: system-linux @@ -9,6 +13,8 @@ # RUN: llvm-bolt %t.exe -o %t.bolt --adr-relaxation=true # RUN: llvm-objdump --no-print-imm-hex -d --disassemble-symbols=main %t.bolt | FileCheck %s # RUN: %t.bolt +# RUN: not llvm-bolt %t.exe -o %t.bolt --adr-relaxation=true --strict \ +# RUN: 2>&1 | FileCheck %s --check-prefix CHECK-ERROR .data .align 8 @@ -31,6 +37,7 @@ test: .type main, %function main: adr x0, .CI + nop adr x1, test adr x2, Gvar2 adr x3, br @@ -47,3 +54,4 @@ br: # CHECK-NEXT: adrp x2, 0x{{[1-8a-f][0-9a-f]*}} # CHECK-NEXT: add x2, x2, #{{[1-8a-f][0-9a-f]*}} # CHECK-NEXT: adr x3, 0x{{[1-8a-f][0-9a-f]*}} +# CHECK-ERROR: BOLT-ERROR: Cannot relax adr in non-simple function main |