Index | Thread | Search

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

Download raw body.

Thread
On Fri, Aug 21, 2026 at 09:06:58AM +0200, Theo Buehler wrote:
> 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) {

I'd need to test, but I suppose this should also reject things like
%r-9 to avoid an OOB access...

>      RegKind = SparcOperand::rk_IntReg;
>      return IntRegs[RegNo];
>    }
>