tcg/riscv: Use tcg_pcrel_diff in tcg_out_ldst
authorRichard Henderson <richard.henderson@linaro.org>
Tue, 17 Jan 2023 23:04:15 +0000 (13:04 -1000)
committerAlistair Francis <alistair.francis@wdc.com>
Fri, 20 Jan 2023 00:14:14 +0000 (10:14 +1000)
We failed to update this with the w^x split, so misses the fact
that true pc-relative offsets are usually small.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-Id: <20230117230415.354239-1-richard.henderson@linaro.org>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
tcg/riscv/tcg-target.c.inc

index fc0edd811f213b2513f428df61638e1ee6846b70..01cb67ef7b45259a70769ca514f7ae7cea414bf2 100644 (file)
@@ -599,7 +599,7 @@ static void tcg_out_ldst(TCGContext *s, RISCVInsn opc, TCGReg data,
     intptr_t imm12 = sextreg(offset, 0, 12);
 
     if (offset != imm12) {
-        intptr_t diff = offset - (uintptr_t)s->code_ptr;
+        intptr_t diff = tcg_pcrel_diff(s, (void *)offset);
 
         if (addr == TCG_REG_ZERO && diff == (int32_t)diff) {
             imm12 = sextreg(diff, 0, 12);