From 7d5f415e3c1a7c9d8a9f670a72ddea7bebf4f0ce Mon Sep 17 00:00:00 2001 From: Maxim Menshikov Date: Tue, 11 Aug 2026 15:14:59 +0100 Subject: [PATCH] DispatchResolve: Avoid clobbering t1 in RhpInterfaceDispatch The `tail` pseudo-instruction expands to auipc t1 + jalr t1, which destroys the dispatch cell address just placed in t1 as the thunk target's parameter. Perform the tail jump manually through t2 instead, matching what RhpInterfaceDispatchSlow does in StubDispatch.S. Signed-off-by: Maxim Menshikov --- src/coreclr/nativeaot/Runtime/riscv64/DispatchResolve.S | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/coreclr/nativeaot/Runtime/riscv64/DispatchResolve.S b/src/coreclr/nativeaot/Runtime/riscv64/DispatchResolve.S index 4d8f61eec705a0..af37dc78d1d005 100644 --- a/src/coreclr/nativeaot/Runtime/riscv64/DispatchResolve.S +++ b/src/coreclr/nativeaot/Runtime/riscv64/DispatchResolve.S @@ -19,7 +19,9 @@ LEAF_ENTRY RhpInterfaceDispatch, _TEXT // t1: parameter of the thunk's target PREPARE_EXTERNAL_VAR RhpCidResolve, t0 mv t1, t5 - tail C_FUNC(RhpUniversalTransitionTailCall) +1: + auipc t2, %pcrel_hi(C_FUNC(RhpUniversalTransitionTailCall)) + jalr x0, t2, %pcrel_lo(1b) LEAF_END RhpInterfaceDispatch, _TEXT