-
Notifications
You must be signed in to change notification settings - Fork 11.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BOLT][AArch64] Reduce the number of ADR relaxations #111577
Merged
+53
−3
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
## Check that llvm-bolt will not unnecessarily relax ADR instruction. | ||
|
||
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o | ||
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -static | ||
# RUN: llvm-bolt %t.exe -o %t.bolt --split-functions --split-strategy=random2 | ||
# RUN: llvm-objdump -d --disassemble-symbols=_start %t.bolt | FileCheck %s | ||
# RUN: llvm-objdump -d --disassemble-symbols=foo.cold.0 %t.bolt \ | ||
# RUN: | FileCheck --check-prefix=CHECK-FOO %s | ||
|
||
## ADR below references its containing function that is split. But ADR is always | ||
## in the main fragment, thus there is no need to relax it. | ||
.text | ||
.globl _start | ||
.type _start, %function | ||
_start: | ||
# CHECK: <_start>: | ||
.cfi_startproc | ||
adr x1, _start | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation |
||
# CHECK-NOT: adrp | ||
# CHECK: adr | ||
cmp x1, x11 | ||
b.hi .L1 | ||
mov x0, #0x0 | ||
.L1: | ||
ret x30 | ||
.cfi_endproc | ||
.size _start, .-_start | ||
|
||
|
||
## In foo, ADR is in the split fragment but references the main one. Thus, it | ||
## needs to be relaxed into ADRP + ADD. | ||
.globl foo | ||
.type foo, %function | ||
foo: | ||
.cfi_startproc | ||
cmp x1, x11 | ||
b.hi .L2 | ||
mov x0, #0x0 | ||
.L2: | ||
# CHECK-FOO: <foo.cold.0>: | ||
adr x1, foo | ||
# CHECK-FOO: adrp | ||
# CHECK-FOO-NEXT: add | ||
ret x30 | ||
.cfi_endproc | ||
.size foo, .-foo | ||
|
||
## Force relocation mode. | ||
.reloc 0, R_AARCH64_NONE |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine to me. Can we add a negative test? (e.g. one where the func is not in the main fragment to show the adrp is still there?)