-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[BOLT][AArch64] Fixes assertion errors occurred when perf2bolt was executed #83394
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
977f649
[BOLT][AArch64] Fixes assertion errors occurred when perf2bolt was ex…
kaadam e1e9894
Enable this test only on AArch64 target
kaadam f486e7f
Added assembly test
kaadam 5bb02a1
Fix the comment
kaadam e72ceab
Added a detailed description into the test
kaadam 499c3fc
Minimize the test case for better comprehension
kaadam 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 hidden or 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 hidden or 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,83 @@ | ||
// Test how BOLT handles indirect branch sequence of instructions in | ||
// AArch64MCPlus builder. | ||
|
||
// clang-format off | ||
|
||
// REQUIRES: system-linux | ||
// RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o | ||
// RUN: %clang %cflags --target=aarch64-unknown-linux %t.o -o %t.exe -Wl,-q | ||
// RUN: llvm-bolt %t.exe -o %t.bolt --print-cfg --strict\ | ||
// RUN: -v=1 2>&1 | FileCheck %s | ||
|
||
// Pattern 1: there is no shift amount after the 'add' instruction. | ||
// | ||
// adr x6, 0x219fb0 <sigall_set+0x88> | ||
// add x6, x6, x14, lsl #2 | ||
// ldr w7, [x6] | ||
// add x6, x6, w7, sxtw => no shift amount | ||
// br x6 | ||
// | ||
|
||
// Pattern 2: nop/adr pair is used in place of adrp/add | ||
// | ||
// nop => nop/adr instead of adrp/add | ||
// adr x13, 0x215a18 <_nl_value_type_LC_COLLATE+0x50> | ||
// ldrh w13, [x13, w12, uxtw #1] | ||
// adr x12, 0x247b30 <__gettextparse+0x5b0> | ||
// add x13, x12, w13, sxth #2 | ||
// br x13 | ||
|
||
.section .text | ||
.align 4 | ||
.globl _start | ||
.type _start, %function | ||
_start: | ||
bl test1 | ||
bl test2 | ||
// mov x0, #4 | ||
// mov w8, #93 | ||
// svc #0 | ||
|
||
// Pattern 1 | ||
// CHECK: BOLT-WARNING: Failed to match indirect branch: ShiftVAL != 2 | ||
.globl test1 | ||
.type test1, %function | ||
test1: | ||
mov x1, #0 | ||
adr x3, datatable | ||
add x3, x3, x1, lsl #2 | ||
ldr w2, [x3] | ||
add x3, x3, w2, sxtw | ||
br x3 | ||
test1_0: | ||
ret | ||
test1_1: | ||
ret | ||
test1_2: | ||
ret | ||
|
||
// Pattern 2 | ||
// CHECK: BOLT-WARNING: Failed to match indirect branch: nop/adr instead of adrp/add | ||
.globl test2 | ||
.type test2, %function | ||
test2: | ||
nop | ||
adr x3, jump_table | ||
ldrh w3, [x3, x1, lsl #1] | ||
adr x1, test2_0 | ||
add x3, x1, w3, sxth #2 | ||
br x3 | ||
test2_0: | ||
ret | ||
test2_1: | ||
ret | ||
|
||
.section .rodata,"a",@progbits | ||
datatable: | ||
.word test1_0-datatable | ||
.word test1_1-datatable | ||
.word test1_2-datatable | ||
|
||
jump_table: | ||
.hword (test2_0-test2_0)>>2 | ||
.hword (test2_1-test2_0)>>2 |
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.
Uh oh!
There was an error while loading. Please reload this page.