On 2025/07/01 7:40, H.J. Lu wrote:
On Mon, Jun 23, 2025 at 5:41 AM Takayuki 'January June' Suwa
<jjsuwa_sys3...@yahoo.co.jp> wrote:
On 2025/06/23 6:20, H.J. Lu wrote:
On Sun, Jun 22, 2025 at 9:54 PM Max Filippov <jcmvb...@gmail.com> wrote:
On Sun, Jun 22, 2025 at 5:49 AM Takayuki 'January June' Suwa
<jjsuwa_sys3...@yahoo.co.jp> wrote:
On 2025/06/22 6:41, Max Filippov wrote:
On Sat, Jun 21, 2025 at 2:12 PM Takayuki 'January June' Suwa
<jjsuwa_sys3...@yahoo.co.jp> wrote:
That hook has since been deprecated
(commit a670ebde3995481225ec62b29686ec07a21e5c10) and has led to incorrect
results on Xtensa:
/* example */
#define <stdint.h>
uint32_t __attribute__((noinline)) test0(uint32_t a, uint16_t b) {
return a + b;
}
uint32_t __attribute__((noinline)) test1(uint32_t a, uint32_t b) {
return test0(a, b);
}
;; before (-mabi=call0)
test0:
add.n a2, a3, a2
ret.n
test1:
sext a3, a3, 15 ;; NG, do not sign-extend
j.l test0, a9
;; after (-mabi=call0)
test0:
extui a3, a3, 0, 16 ;; OK
add.n a2, a3, a2
ret.n
test1:
j.l test0, a9
With this patch, the result is consistent with other targets such as
AArch64.
gcc/ChangeLog:
* config/xtensa/xtensa.cc
(TARGET_PROMOTE_PROTOTYPES, TARGET_PROMOTE_FUNCTION_MODE):
Remove.
---
gcc/config/xtensa/xtensa.cc | 5 -----
1 file changed, 5 deletions(-)
This results in a bunch of ICEs with the following backtrace:
How about leaving TARGET_PROMOTE_FUNCTION_MODE and just removing
TARGET_PROMOTE_PROTOTYPES?
commit a670ebde3995481225ec62b29686ec07a21e5c10
Author: H.J. Lu <hjl.to...@gmail.com>
Date: Thu Nov 21 07:54:35 2024 +0800
Drop targetm.promote_prototypes from C, C++ and Ada frontends
dropped targetm.calls.promote_prototypes in FEs. But
commit 78db4753c9646a372512e6a951fced12f74de0bc
Author: H.J. Lu <hjl.to...@gmail.com>
Date: Thu Nov 21 08:11:06 2024 +0800
Honor TARGET_PROMOTE_PROTOTYPES during RTL expand
used targetm.calls.promote_prototypes. TARGET_PROMOTE_PROTOTYPES
shouldn't be removed.
The sign extension of signed char function arguments is missing with
this change,
breaking the ABI, e.g
void s8(signed char c);
void cs8(signed char *c)
{
s8(*c);
}
is translated to
cs8:
entry sp, 32
l8ui a10, a2, 0
call8 s8
retw.n
--
Thanks.
-- Max
Thank you for your attention to this issue. I will also withdraw my patch.
xtensa ABI requires sign extension of signed 8/16-bit arguments to 32
bits and zero extension of unsigned 8/16-bit arguments to 32 bits.
TARGET_PROMOTE_PROTOTYPES is an optimization, not an ABI requirement.
xtensa should remove TARGET_PROMOTE_PROTOTYPES and define
a proper TARGET_PROMOTE_FUNCTION_MODE, instead Please try this:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120888#c4
For the first example I provided, this seems to be fine.
I'll defer to Max for more comprehensive regression testing.
=====
jjsuwa_sys3...@yahoo.co.jp