[llvm] [BOLT][RISCV] Precommit test for a call that links through t0 (PR #218396)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 24 05:51:26 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-risc-v
Author: Kito Cheng (kito-cheng)
<details>
<summary>Changes</summary>
The machine outliner calls its outlined functions with "call t0, func" and the callee returns with "jr t0". BOLT currently rewrites that call to link through ra, which the CHECK lines below pin down.
---
Full diff: https://github.com/llvm/llvm-project/pull/218396.diff
1 Files Affected:
- (added) bolt/test/RISCV/call-link-register.s (+24)
``````````diff
diff --git a/bolt/test/RISCV/call-link-register.s b/bolt/test/RISCV/call-link-register.s
new file mode 100644
index 0000000000000..50288e3bd31d3
--- /dev/null
+++ b/bolt/test/RISCV/call-link-register.s
@@ -0,0 +1,24 @@
+// RUN: %clang %cflags64 -Wl,--no-relax -o %t %s
+// RUN: llvm-bolt -o %t.bolt %t
+// RUN: llvm-objdump -d --disassemble-symbols=_start %t.bolt | FileCheck %s
+
+ .text
+
+ .globl _start
+ .p2align 1
+_start:
+// CHECK-LABEL: <_start>:
+/// The auipc of the pair, replaced by a nop once the call is rewritten.
+// CHECK-NEXT: nop
+/// FIXME: the link register is dropped here: the call is rewritten to link
+/// through ra, so f returns to whatever t0 happens to hold.
+// CHECK-NEXT: jal 0x{{.*}} <f>
+ call t0, f
+ ret
+ .size _start, .-_start
+
+ .globl f
+ .p2align 1
+f:
+ jr t0
+ .size f, .-f
``````````
</details>
https://github.com/llvm/llvm-project/pull/218396
More information about the llvm-commits
mailing list