Skip to content

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Sep 15, 2025

No description provided.

@topperc topperc changed the title [RISCV] Use X_X0 instead of literal 0. [RISCV] Use X_X0 instead of literal 0. NFC Sep 15, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 15, 2025

@llvm/pr-subscribers-backend-risc-v

@llvm/pr-subscribers-lld-elf

Author: Craig Topper (topperc)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/158753.diff

1 Files Affected:

  • (modified) lld/ELF/Arch/RISCV.cpp (+1-1)
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;

Copy link
Member

@lenary lenary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@topperc topperc merged commit 0d92775 into llvm:main Sep 16, 2025
13 checks passed
@topperc topperc deleted the pr/lld-x_x0 branch September 16, 2025 04:01
@MaskRay
Copy link
Member

MaskRay commented Sep 16, 2025

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants