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:
libstdc++-v3/src/filesystem/ops.cc:780:29: internal compiler error: in
expand_call, at calls.cc:3930
780 | return fs::equiv_files(p1.c_str(), st1, p2.c_str(), st2, ec);
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x1fb63ff internal_error(char const*, ...)
gcc/diagnostic-global-context.cc:517
0x969aa8 fancy_abort(char const*, int, char const*)
gcc/diagnostic.cc:1803
0x76de1d expand_call(tree_node*, rtx_def*, int)
gcc/calls.cc:3930
0xe7dd2e expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
gcc/expr.cc:12479
0xe89bf7 expand_expr(tree_node*, rtx_def*, machine_mode, expand_modifier)
gcc/expr.h:323
0xe89bf7 store_expr(tree_node*, rtx_def*, int, bool, bool)
gcc/expr.cc:6645
0xe8b7df expand_assignment(tree_node*, tree_node*, bool)
gcc/expr.cc:6483
0xd50e9d expand_call_stmt
gcc/cfgexpand.cc:3149
0xd50e9d expand_gimple_stmt_1
gcc/cfgexpand.cc:4223
0xd50e9d expand_gimple_stmt
gcc/cfgexpand.cc:4370
0xd51b95 expand_gimple_basic_block
gcc/cfgexpand.cc:6433
0xd53d26 execute
gcc/cfgexpand.cc:7181
The section about TARGET_PROMOTE_FUNCTION_MODE in gcc/targhooks.cc
looks like this:
machine_mode
default_promote_function_mode (const_tree type ATTRIBUTE_UNUSED,
machine_mode mode,
int *punsignedp ATTRIBUTE_UNUSED,
const_tree funtype ATTRIBUTE_UNUSED,
int for_return ATTRIBUTE_UNUSED)
{
if (type != NULL_TREE && for_return == 2)
return promote_mode (type, mode, punsignedp);
return mode;
}
machine_mode
default_promote_function_mode_always_promote (const_tree type,
machine_mode mode,
int *punsignedp,
const_tree funtype
ATTRIBUTE_UNUSED,
int for_return ATTRIBUTE_UNUSED)
{
return promote_mode (type, mode, punsignedp);
}
The above means that not specifying TARGET_PROMOTE_FUNCTION_MODE is not
equivalent to specifying default_promote_function_mode_always_promote.
How about leaving TARGET_PROMOTE_FUNCTION_MODE and just removing
TARGET_PROMOTE_PROTOTYPES?
=====
jjsuwa_sys3...@yahoo.co.jp