NetBSD Problem Report #60772

From www@netbsd.org  Wed Sep 23 11:53:42 2026
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits)
	 client-signature RSA-PSS (2048 bits))
	(Client CN "mail.netbsd.org", Issuer "YR1" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 091851A923B
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 23 Sep 2026 11:53:42 +0000 (UTC)
Message-Id: <20260923115340.DDD461A923C@mollari.NetBSD.org>
Date: Wed, 23 Sep 2026 11:53:40 +0000 (UTC)
From: rokuyama.rk@gmail.com
Reply-To: rokuyama.rk@gmail.com
To: gnats-bugs@NetBSD.org
Subject: insane calling convention for uint32_t variables
X-Send-Pr-Version: www-1.0
X-From4GNATS: "rokuyama.rk@gmail.com via gnats" <gnats-admin@NetBSD.org>

>Number:         60772
>Category:       port-alpha
>Synopsis:       insane calling convention for uint32_t variables
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-alpha-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Sep 23 11:55:00 +0000 2026
>Last-Modified:  Wed Sep 23 12:05:01 +0000 2026
>Originator:     Rin Okuyama
>Release:        11.99.8
>Organization:
Internet Initiative Japan Inc.
>Environment:
NetBSD ds10.local 11.99.8 NetBSD 11.99.8 (GENERIC-$Revision: 1.421 $) #0: Tue Sep 22 21:26:27 JST 2026  rin@sakaizumii.local:/home/rin/src/sys/arch/alpha/compile/obj.alpha-alpha/GENERIC alpha
>Description:
Due to "Digital UNIX: Calling Standard for Alpha Systems" Sec. 4.1.5,

https://archive.org/details/digital-unix-calling-standard/page/n1/mode/2up

when passing uint{8,16}_t and int{8,16}_t variables via registers,
these must be zero- and sign-extended, respectively. However, on the
other hand, {u,}int32_t must be sign-extended regardless of unsigned
or signed!

For our assembler-implemented functions, at least bswap32(3/9)
violates this rule, which results in part of GCC14 fallouts; GCC14
seems to utilize this calling convention for any optimization level
higher than -O0. If bswap32(3/9) is fixed, ipf and nfs ones of GCC14
fallouts are fixed.

However, unfortunately, other fallouts are not resolved. Especially,
GCC14 does not work natively as before...
>How-To-Repeat:
As the simplest test for this calling convention, compile this:

```
unsigned char u_char_func(void)
{
        return 0xffU;
}

unsigned short u_short_func(void)
{
        return 0xffffU;
}

unsigned int u_int_func(void)
{
        return 0xffffffffU;
}
```

Both GCC12 and GCC14 give:

```
0000000000000000 <u_char_func>:
   0:   ff 00 1f 20     lda     v0,255
   4:   01 80 fa 6b     ret

0000000000000008 <u_short_func>:
   8:   01 00 1f 24     ldah    v0,1
   c:   ff ff 00 20     lda     v0,-1(v0)
  10:   01 80 fa 6b     ret

0000000000000014 <u_int_func>:
  14:   ff ff 1f 20     lda     v0,-1
  18:   01 80 fa 6b     ret
```
>Fix:
At least, bswap32(3/9) must sign-extend its result before return.

Other assembler-implemented functions may be fixed similarly.

>Audit-Trail:
From: "Rin Okuyama" <rin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/60772 CVS commit: src/common/lib/libc/arch/alpha/gen
Date: Wed, 23 Sep 2026 11:58:49 +0000

 Module Name:	src
 Committed By:	rin
 Date:		Wed Sep 23 11:58:49 UTC 2026

 Modified Files:
 	src/common/lib/libc/arch/alpha/gen: byte_swap_4.S

 Log Message:
 bswap32: alpha: Sign-extend uint32_t calculated result

 as per "Digital UNIX: Calling Standard for Alpha Systems".

 PR port-alpha/60772: insane calling convention for uint32_t variables


 To generate a diff of this commit:
 cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/arch/alpha/gen/byte_swap_4.S

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Rin Okuyama" <rin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/60772 CVS commit: src/external/gpl3/gcc
Date: Wed, 23 Sep 2026 12:03:37 +0000

 Module Name:	src
 Committed By:	rin
 Date:		Wed Sep 23 12:03:37 UTC 2026

 Modified Files:
 	src/external/gpl3/gcc: README.gcc14

 Log Message:
 README.gcc14: alpha: Fallouts for nfs and ipf ATF cases are gone

 PR port-alpha/60772: insane calling convention for uint32_t variables


 To generate a diff of this commit:
 cvs rdiff -u -r1.32 -r1.33 src/external/gpl3/gcc/README.gcc14

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.