Re: llvm SparcAsmParser off by one

Mark Kettenis <[email protected]>
Newsgroups gmane.os.openbsd.tech
Message-ID <[email protected]>
> Date: Fri, 21 Aug 2026 09:06:58 +0200
> From: Theo Buehler <[email protected]>
> 
> The build of lang/rust on sparc64 with llvm errors out:
> 
> warning: [email protected]: src/arch/sparc64.s:59:26: error: invalid register name
> warning: [email protected]:     .cfi_register %r15, %r31
> warning: [email protected]:                          ^
> 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];
>    }
> 

I'd probably have used <= 31 given the code in MorphToIntPairReg(),
but either way, ok kettenis@
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.