-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BOLT][RISCV] Carry-over annotations when fixing calls (#66763)
`FixRISCVCallsPass` changes all different forms of calls to `PseudoCALL` instructions. However, the original call's annotations were lost in the process. This patch fixes this by moving all annotations from the old to the new call. `MCPlusBuilder::moveAnnotations` had to be made public for this.
- Loading branch information
Showing
3 changed files
with
47 additions
and
1 deletion.
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
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,33 @@ | ||
/// Test that annotations are properly carried over to fixed calls. | ||
/// Note that --enable-bat is used to force offsets to be kept. | ||
|
||
// RUN: llvm-mc -triple riscv64 -filetype obj -o %t.o %s | ||
// RUN: ld.lld --emit-relocs -o %t %t.o | ||
// RUN: llvm-bolt --enable-bat --print-cfg --print-fix-riscv-calls \ | ||
// RUN: --print-only=_start -o /dev/null %t | FileCheck %s | ||
|
||
.text | ||
.global f | ||
.p2align 1 | ||
f: | ||
ret | ||
.size f, .-f | ||
|
||
// CHECK-LABEL: Binary Function "_start" after building cfg { | ||
// CHECK: auipc ra, f | ||
// CHECK-NEXT: jalr ra, -4(ra) # Offset: 4 | ||
// CHECK-NEXT: jal ra, f # Offset: 8 | ||
// CHECK-NEXT: jal zero, f # TAILCALL # Offset: 12 | ||
|
||
// CHECK-LABEL: Binary Function "_start" after fix-riscv-calls { | ||
// CHECK: call f # Offset: 0 | ||
// CHECK-NEXT: call f # Offset: 8 | ||
// CHECK-NEXT: tail f # TAILCALL # Offset: 12 | ||
|
||
.globl _start | ||
.p2align 1 | ||
_start: | ||
call f | ||
jal f | ||
jal zero, f | ||
.size _start, .-_start |