[lld] [RISCV] Use X_X0 instead of literal 0. (PR #158753)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 15 16:01:52 PDT 2025


https://github.com/topperc created https://github.com/llvm/llvm-project/pull/158753

None

>From 6a8b4ab96a972b05c172f293de82dac694666013 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Mon, 15 Sep 2025 16:00:55 -0700
Subject: [PATCH] [RISCV] Use X_X0 instead of literal 0.

---
 lld/ELF/Arch/RISCV.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lld/ELF/Arch/RISCV.cpp b/lld/ELF/Arch/RISCV.cpp
index 85ddf1b6da283..7f2bfefa5578a 100644
--- a/lld/ELF/Arch/RISCV.cpp
+++ b/lld/ELF/Arch/RISCV.cpp
@@ -756,7 +756,7 @@ static void relaxCall(Ctx &ctx, const InputSection &sec, size_t i, uint64_t loc,
 
   // When the caller specifies the old value of `remove`, disallow its
   // increment.
-  if (remove >= 6 && rvc && isInt<12>(displace) && rd == 0) {
+  if (remove >= 6 && rvc && isInt<12>(displace) && rd == X_X0) {
     sec.relaxAux->relocTypes[i] = R_RISCV_RVC_JUMP;
     sec.relaxAux->writes.push_back(0xa001); // c.j
     remove = 6;



More information about the llvm-commits mailing list