NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
port-alpha/60772: insane calling convention for uint32_t variables
>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
>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.
Home |
Main Index |
Thread Index |
Old Index