public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/101195] New: ICE: in tree_to_uhwi, at tree.c:6324
@ 2021-06-24 13:46 cnsun at uwaterloo dot ca
2021-06-24 18:54 ` [Bug middle-end/101195] " pinskia at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: cnsun at uwaterloo dot ca @ 2021-06-24 13:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101195
Bug ID: 101195
Summary: ICE: in tree_to_uhwi, at tree.c:6324
Product: gcc
Version: tree-ssa
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: cnsun at uwaterloo dot ca
Target Milestone: ---
$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/scratch/software/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /tmp/tmp.gHvB6MNy5h-gcc-builder/gcc/configure
--enable-languages=c,c++,lto --enable-checking-yes --enable-multiarch
--prefix=/scratch/software/gcc-trunk --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210624 (experimental) [master revision
:e518ee6cd:fcf617f0d2a5a1b624718e07d7b219cb0234436f] (GCC)
$ cat mutant.c
test_eh_return_data_regno() {
volatile res = __builtin_eh_return_data_regno(-42.);
}
$ gcc-trunk mutant.c
mutant.c:1:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
1 | test_eh_return_data_regno() {
| ^~~~~~~~~~~~~~~~~~~~~~~~~
mutant.c: In function ‘test_eh_return_data_regno’:
mutant.c:2:12: warning: type defaults to ‘int’ in declaration of ‘res’
[-Wimplicit-int]
2 | volatile res = __builtin_eh_return_data_regno(-42.);
| ^~~
during RTL pass: expand
mutant.c:2:18: internal compiler error: in tree_to_uhwi, at tree.c:6324
2 | volatile res = __builtin_eh_return_data_regno(-42.);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x7c7c7e tree_to_uhwi(tree_node const*)
/tmp/tmp.gHvB6MNy5h-gcc-builder/gcc/gcc/tree.c:6324
0x7c7c7e tree_to_uhwi(tree_node const*)
/tmp/tmp.gHvB6MNy5h-gcc-builder/gcc/gcc/tree.c:6322
0xb50537 expand_builtin_eh_return_data_regno(tree_node*)
/tmp/tmp.gHvB6MNy5h-gcc-builder/gcc/gcc/except.c:2170
0xa222f6 expand_builtin(tree_node*, rtx_def*, rtx_def*, machine_mode, int)
/tmp/tmp.gHvB6MNy5h-gcc-builder/gcc/gcc/builtins.c:10409
0xb7366c expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
/tmp/tmp.gHvB6MNy5h-gcc-builder/gcc/gcc/expr.c:11439
0xb7e018 store_expr(tree_node*, rtx_def*, int, bool, bool)
/tmp/tmp.gHvB6MNy5h-gcc-builder/gcc/gcc/expr.c:5994
0xb7f65f expand_assignment(tree_node*, tree_node*, bool)
/tmp/tmp.gHvB6MNy5h-gcc-builder/gcc/gcc/expr.c:5729
0xa4cb8b expand_call_stmt
/tmp/tmp.gHvB6MNy5h-gcc-builder/gcc/gcc/cfgexpand.c:2844
0xa4cb8b expand_gimple_stmt_1
/tmp/tmp.gHvB6MNy5h-gcc-builder/gcc/gcc/cfgexpand.c:3877
0xa4cb8b expand_gimple_stmt
/tmp/tmp.gHvB6MNy5h-gcc-builder/gcc/gcc/cfgexpand.c:4041
0xa528c9 expand_gimple_basic_block
/tmp/tmp.gHvB6MNy5h-gcc-builder/gcc/gcc/cfgexpand.c:6083
0xa5479f execute
/tmp/tmp.gHvB6MNy5h-gcc-builder/gcc/gcc/cfgexpand.c:6809
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/101195] ICE: in tree_to_uhwi, at tree.c:6324
2021-06-24 13:46 [Bug c/101195] New: ICE: in tree_to_uhwi, at tree.c:6324 cnsun at uwaterloo dot ca
@ 2021-06-24 18:54 ` pinskia at gcc dot gnu.org
2021-06-25 6:16 ` rguenth at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-06-24 18:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101195
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|tree-ssa |12.0
Keywords| |ice-on-valid-code
Component|c |middle-end
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Looks like there is a missing check on the argument types for this builtin.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/101195] ICE: in tree_to_uhwi, at tree.c:6324
2021-06-24 13:46 [Bug c/101195] New: ICE: in tree_to_uhwi, at tree.c:6324 cnsun at uwaterloo dot ca
2021-06-24 18:54 ` [Bug middle-end/101195] " pinskia at gcc dot gnu.org
@ 2021-06-25 6:16 ` rguenth at gcc dot gnu.org
2023-10-20 3:03 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-25 6:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101195
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2021-06-25
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
DEF_GCC_BUILTIN (BUILT_IN_EH_RETURN_DATA_REGNO, "eh_return_data_regno",
BT_FN_INT_INT, ATTR_LEAF_LIST)
so -42 is perfectly fine, but
2165 {
2166 error ("argument of %<__builtin_eh_return_regno%> must be
constant");
2167 return constm1_rtx;
2168 }
2169
2170 iwhich = tree_to_uhwi (which);
we then don't check the argument range before accessing it as unsigned.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/101195] ICE: in tree_to_uhwi, at tree.c:6324
2021-06-24 13:46 [Bug c/101195] New: ICE: in tree_to_uhwi, at tree.c:6324 cnsun at uwaterloo dot ca
2021-06-24 18:54 ` [Bug middle-end/101195] " pinskia at gcc dot gnu.org
2021-06-25 6:16 ` rguenth at gcc dot gnu.org
@ 2023-10-20 3:03 ` pinskia at gcc dot gnu.org
2024-01-28 23:42 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-20 3:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101195
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |141242068 at smail dot nju.edu.cn
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 111886 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/101195] ICE: in tree_to_uhwi, at tree.c:6324
2021-06-24 13:46 [Bug c/101195] New: ICE: in tree_to_uhwi, at tree.c:6324 cnsun at uwaterloo dot ca
` (2 preceding siblings ...)
2023-10-20 3:03 ` pinskia at gcc dot gnu.org
@ 2024-01-28 23:42 ` pinskia at gcc dot gnu.org
2024-01-29 9:19 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-28 23:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101195
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gabravier at gmail dot com
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 113647 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/101195] ICE: in tree_to_uhwi, at tree.c:6324
2021-06-24 13:46 [Bug c/101195] New: ICE: in tree_to_uhwi, at tree.c:6324 cnsun at uwaterloo dot ca
` (3 preceding siblings ...)
2024-01-28 23:42 ` pinskia at gcc dot gnu.org
@ 2024-01-29 9:19 ` jakub at gcc dot gnu.org
2024-01-30 8:59 ` cvs-commit at gcc dot gnu.org
2024-01-30 9:04 ` jakub at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-01-29 9:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101195
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 57249
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57249&action=edit
gcc14-pr101195.patch
Initially I thought we should emit some error message, like that the argument
must be non-negative constant, but given the
iwhich = EH_RETURN_DATA_REGNO (iwhich);
if (iwhich == INVALID_REGNUM)
return constm1_rtx;
a few lines later where it will on pretty much all architectures return
INVALID_REGNUM for all but 2-4 values and so silently expand to -1 at runtime
I think silently expanding the negative values to that as well is just fine.
There is no fundamental difference between -1, -42, 42 or 237 in this regard,
all of them most likely aren't eh regnos.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/101195] ICE: in tree_to_uhwi, at tree.c:6324
2021-06-24 13:46 [Bug c/101195] New: ICE: in tree_to_uhwi, at tree.c:6324 cnsun at uwaterloo dot ca
` (4 preceding siblings ...)
2024-01-29 9:19 ` jakub at gcc dot gnu.org
@ 2024-01-30 8:59 ` cvs-commit at gcc dot gnu.org
2024-01-30 9:04 ` jakub at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-30 8:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101195
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:26c9b95b9f712ff1f813351b5d45371620085221
commit r14-8516-g26c9b95b9f712ff1f813351b5d45371620085221
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Jan 30 09:57:21 2024 +0100
except: Fix __builtin_eh_return_data_regno (-42) expansion [PR101195]
The expansion of this builtin emits an error if the argument is not
INTEGER_CST, otherwise uses tree_to_uhwi on the argument (which is declared
int) and then uses EH_RETURN_DATA_REGNO macro which on most targets returns
INVALID_REGNUM for all values but some small number (2 or 4); if it returns
INVALID_REGNUM, we silently expand to -1.
Now, I think the error for non-INTEGER_CST makes sense to catch when people
unintentionally don't call it with a constant (but, users shouldn't really
use this builtin anyway, it is for the unwinder only). Initially I thought
about emitting an error for the negative values as well on which
tree_to_uhwi otherwise ICEs, but given that the function will silently
expand to -1 for INT_MAX - 1 or INT_MAX - 3 other values, I think treating
the negatives the same silently is fine too.
2024-01-30 Jakub Jelinek <jakub@redhat.com>
PR middle-end/101195
* except.cc (expand_builtin_eh_return_data_regno): If which doesn't
fit into unsigned HOST_WIDE_INT, return constm1_rtx.
* gcc.dg/pr101195.c: New test.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/101195] ICE: in tree_to_uhwi, at tree.c:6324
2021-06-24 13:46 [Bug c/101195] New: ICE: in tree_to_uhwi, at tree.c:6324 cnsun at uwaterloo dot ca
` (5 preceding siblings ...)
2024-01-30 8:59 ` cvs-commit at gcc dot gnu.org
@ 2024-01-30 9:04 ` jakub at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-01-30 9:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101195
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |14.0
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for GCC 14. Not important to backport IMHO, this builtin is meant to be
used just in the unwinder, not in normal user code.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-01-30 9:04 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-24 13:46 [Bug c/101195] New: ICE: in tree_to_uhwi, at tree.c:6324 cnsun at uwaterloo dot ca
2021-06-24 18:54 ` [Bug middle-end/101195] " pinskia at gcc dot gnu.org
2021-06-25 6:16 ` rguenth at gcc dot gnu.org
2023-10-20 3:03 ` pinskia at gcc dot gnu.org
2024-01-28 23:42 ` pinskia at gcc dot gnu.org
2024-01-29 9:19 ` jakub at gcc dot gnu.org
2024-01-30 8:59 ` cvs-commit at gcc dot gnu.org
2024-01-30 9:04 ` jakub at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).