Index | Thread | Search

From:
Theo Buehler <tb@theobuehler.org>
Subject:
llvm SparcAsmParser off by one
To:
tech@openbsd.org
Date:
Fri, 21 Aug 2026 09:06:58 +0200

Download raw body.

Thread
The build of lang/rust on sparc64 with llvm errors out:

warning: psm@0.1.26: src/arch/sparc64.s:59:26: error: invalid register name
warning: psm@0.1.26:     .cfi_register %r15, %r31
warning: psm@0.1.26:                          ^
error: failed to run custom build command for `psm v0.1.26`

This is because of an off by one rejecting %r31. Not sure if this or
<= 31 would be preferred. I'll sync this to ports of course.

diff --git a/gnu/llvm/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp b/gnu/llvm/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
index e5c7fa86b3..a9fa9ba769 100644
--- a/gnu/llvm/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
+++ b/gnu/llvm/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
@@ -1614,7 +1614,7 @@
   // %r0 - %r31
   int64_t RegNo = 0;
   if (Name.starts_with_insensitive("r") &&
-      !Name.substr(1, 2).getAsInteger(10, RegNo) && RegNo < 31) {
+      !Name.substr(1, 2).getAsInteger(10, RegNo) && RegNo < 32) {
     RegKind = SparcOperand::rk_IntReg;
     return IntRegs[RegNo];
   }