public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/111818] New: GCC: 14: internal compiler error: tree check: expected tree that contains 'decl common' structure, have 'integer_cst' in tree_could_trap_p, at tree-eh.cc:2733
@ 2023-10-15 1:38 141242068 at smail dot nju.edu.cn
2023-10-15 1:47 ` [Bug middle-end/111818] [11/12/13/14 Regression] ICE with __builtin_memcpy with volatile and constants pinskia at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: 141242068 at smail dot nju.edu.cn @ 2023-10-15 1:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111818
Bug ID: 111818
Summary: GCC: 14: internal compiler error: tree check: expected
tree that contains 'decl common' structure, have
'integer_cst' in tree_could_trap_p, at tree-eh.cc:2733
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: 141242068 at smail dot nju.edu.cn
Target Milestone: ---
When compile below program with GCC-14 and option `-O1`, GCC-14 crashes:
```
#define DUMMY_VALUE 0x12345678
static void foo(const volatile unsigned int x, void *p) {
__builtin_memcpy(p, &x, sizeof x);
__builtin_memcpy(p, &x, sizeof x);
}
void bar(int type, void *number) {
switch (type) {
case 1: foo(DUMMY_VALUE, number); break;
case 7: foo(0, number); break;
case 8: foo(0, number); break;
case 9: foo(0, number); break;
}
}
```
The crash reproducer: https://godbolt.org/z/7sP8zc3Kc
And the full stack dump:
```
<source>: In function 'foo':
<source>:3:23: warning: passing argument 2 of '__builtin_memcpy' discards
'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers]
3 | __builtin_memcpy(p, &x, sizeof x);
| ^~
<source>:3:23: note: expected 'const void *' but argument is of type 'const
volatile unsigned int *'
<source>:4:23: warning: passing argument 2 of '__builtin_memcpy' discards
'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers]
4 | __builtin_memcpy(p, &x, sizeof x);
| ^~
<source>:4:23: note: expected 'const void *' but argument is of type 'const
volatile unsigned int *'
during RTL pass: expand
In function 'foo',
inlined from 'bar' at <source>:9:11:
<source>:3:3: internal compiler error: tree check: expected tree that contains
'decl common' structure, have 'integer_cst' in tree_could_trap_p, at
tree-eh.cc:2733
3 | __builtin_memcpy(p, &x, sizeof x);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x22ff3ee internal_error(char const*, ...)
???:0
0x8a8243 tree_contains_struct_check_failed(tree_node const*,
tree_node_structure_enum, char const*, int, char const*)
???:0
0xc9ab0e set_mem_attributes_minus_bitpos(rtx_def*, tree_node*, int,
poly_int<1u, long>)
???:0
0xcc6c35 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
???:0
0xcd3083 store_expr(tree_node*, rtx_def*, int, bool, bool)
???:0
0xcd4d66 expand_assignment(tree_node*, tree_node*, bool)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
```
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/111818] [11/12/13/14 Regression] ICE with __builtin_memcpy with volatile and constants
2023-10-15 1:38 [Bug c/111818] New: GCC: 14: internal compiler error: tree check: expected tree that contains 'decl common' structure, have 'integer_cst' in tree_could_trap_p, at tree-eh.cc:2733 141242068 at smail dot nju.edu.cn
@ 2023-10-15 1:47 ` pinskia at gcc dot gnu.org
2023-10-16 6:59 ` rguenth at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-15 1:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111818
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |4.9.1
Known to fail| |10.1.0, 5.1.0
Target Milestone|--- |11.5
Ever confirmed|0 |1
Last reconfirmed| |2023-10-15
Summary|GCC: 14: internal compiler |[11/12/13/14 Regression]
|error: tree check: expected |ICE with __builtin_memcpy
|tree that contains 'decl |with volatile and constants
|common' structure, have |
|'integer_cst' in |
|tree_could_trap_p, at |
|tree-eh.cc:2733 |
Status|UNCONFIRMED |NEW
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
Even though GCC 11.x and 12.x and 13.x don't ICE without checking enabled. The
IR is still invalid:
_9 ={v} MEM <unsigned int> [(char * {ref-all})&305419896];
That is just wrong.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/111818] [11/12/13/14 Regression] ICE with __builtin_memcpy with volatile and constants
2023-10-15 1:38 [Bug c/111818] New: GCC: 14: internal compiler error: tree check: expected tree that contains 'decl common' structure, have 'integer_cst' in tree_could_trap_p, at tree-eh.cc:2733 141242068 at smail dot nju.edu.cn
2023-10-15 1:47 ` [Bug middle-end/111818] [11/12/13/14 Regression] ICE with __builtin_memcpy with volatile and constants pinskia at gcc dot gnu.org
@ 2023-10-16 6:59 ` rguenth at gcc dot gnu.org
2023-10-17 6:26 ` cvs-commit at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-10-16 6:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111818
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
It's inlining of
void foo (const volatile unsigned int x, void * p)
{
unsigned int _2;
unsigned int _5;
<bb 2> [local count: 1073741824]:
_2 ={v} MEM <unsigned int> [(char * {ref-all})&x];
into
foo (305419896, number_4(D));
Smaller testcase:
static void foo(const volatile unsigned int x, void *p)
{
__builtin_memcpy(p, &x, sizeof x);
}
void bar(void *number)
{
foo(0, number);
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/111818] [11/12/13/14 Regression] ICE with __builtin_memcpy with volatile and constants
2023-10-15 1:38 [Bug c/111818] New: GCC: 14: internal compiler error: tree check: expected tree that contains 'decl common' structure, have 'integer_cst' in tree_could_trap_p, at tree-eh.cc:2733 141242068 at smail dot nju.edu.cn
2023-10-15 1:47 ` [Bug middle-end/111818] [11/12/13/14 Regression] ICE with __builtin_memcpy with volatile and constants pinskia at gcc dot gnu.org
2023-10-16 6:59 ` rguenth at gcc dot gnu.org
@ 2023-10-17 6:26 ` cvs-commit at gcc dot gnu.org
2023-10-17 6:27 ` [Bug middle-end/111818] [11/12/13 " rguenth at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-17 6:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111818
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:ce55521bcd149fdc431f1d78e706b66d470210ae
commit r14-4678-gce55521bcd149fdc431f1d78e706b66d470210ae
Author: Richard Biener <rguenther@suse.de>
Date: Mon Oct 16 12:50:46 2023 +0200
middle-end/111818 - failed DECL_NOT_GIMPLE_REG_P setting of volatile
The following addresses a missed DECL_NOT_GIMPLE_REG_P setting of
a volatile declared parameter which causes inlining to substitute
a constant parameter into a context where its address is required.
The main issue is in update_address_taken which clears
DECL_NOT_GIMPLE_REG_P from the parameter but fails to rewrite it
because is_gimple_reg returns false for volatiles. The following
changes maybe_optimize_var to make the 1:1 correspondence between
clearing DECL_NOT_GIMPLE_REG_P of a register typed decl and
actually rewriting it to SSA.
PR middle-end/111818
* tree-ssa.cc (maybe_optimize_var): When clearing
DECL_NOT_GIMPLE_REG_P always rewrite into SSA.
* gcc.dg/torture/pr111818.c: New testcase.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/111818] [11/12/13 Regression] ICE with __builtin_memcpy with volatile and constants
2023-10-15 1:38 [Bug c/111818] New: GCC: 14: internal compiler error: tree check: expected tree that contains 'decl common' structure, have 'integer_cst' in tree_could_trap_p, at tree-eh.cc:2733 141242068 at smail dot nju.edu.cn
` (2 preceding siblings ...)
2023-10-17 6:26 ` cvs-commit at gcc dot gnu.org
@ 2023-10-17 6:27 ` rguenth at gcc dot gnu.org
2023-11-10 14:24 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-10-17 6:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111818
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
Keywords| |wrong-code
Summary|[11/12/13/14 Regression] |[11/12/13 Regression] ICE
|ICE with __builtin_memcpy |with __builtin_memcpy with
|with volatile and constants |volatile and constants
Known to fail| |13.2.1
Known to work| |14.0
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed on trunk sofar.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/111818] [11/12/13 Regression] ICE with __builtin_memcpy with volatile and constants
2023-10-15 1:38 [Bug c/111818] New: GCC: 14: internal compiler error: tree check: expected tree that contains 'decl common' structure, have 'integer_cst' in tree_could_trap_p, at tree-eh.cc:2733 141242068 at smail dot nju.edu.cn
` (3 preceding siblings ...)
2023-10-17 6:27 ` [Bug middle-end/111818] [11/12/13 " rguenth at gcc dot gnu.org
@ 2023-11-10 14:24 ` cvs-commit at gcc dot gnu.org
2023-11-27 13:09 ` [Bug middle-end/111818] [11/12 " cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-11-10 14:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111818
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:ffb0615cf1aa628ca8aa10bda31fe1bc554eccf3
commit r13-8044-gffb0615cf1aa628ca8aa10bda31fe1bc554eccf3
Author: Richard Biener <rguenther@suse.de>
Date: Mon Oct 16 12:50:46 2023 +0200
middle-end/111818 - failed DECL_NOT_GIMPLE_REG_P setting of volatile
The following addresses a missed DECL_NOT_GIMPLE_REG_P setting of
a volatile declared parameter which causes inlining to substitute
a constant parameter into a context where its address is required.
The main issue is in update_address_taken which clears
DECL_NOT_GIMPLE_REG_P from the parameter but fails to rewrite it
because is_gimple_reg returns false for volatiles. The following
changes maybe_optimize_var to make the 1:1 correspondence between
clearing DECL_NOT_GIMPLE_REG_P of a register typed decl and
actually rewriting it to SSA.
PR middle-end/111818
* tree-ssa.cc (maybe_optimize_var): When clearing
DECL_NOT_GIMPLE_REG_P always rewrite into SSA.
* gcc.dg/torture/pr111818.c: New testcase.
(cherry picked from commit ce55521bcd149fdc431f1d78e706b66d470210ae)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/111818] [11/12 Regression] ICE with __builtin_memcpy with volatile and constants
2023-10-15 1:38 [Bug c/111818] New: GCC: 14: internal compiler error: tree check: expected tree that contains 'decl common' structure, have 'integer_cst' in tree_could_trap_p, at tree-eh.cc:2733 141242068 at smail dot nju.edu.cn
` (4 preceding siblings ...)
2023-11-10 14:24 ` cvs-commit at gcc dot gnu.org
@ 2023-11-27 13:09 ` cvs-commit at gcc dot gnu.org
2023-12-15 12:18 ` [Bug middle-end/111818] [11 " cvs-commit at gcc dot gnu.org
2023-12-15 12:22 ` rguenth at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-11-27 13:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111818
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:2cc700fec5c72d9c1385ec83621771bb9db58d96
commit r12-10014-g2cc700fec5c72d9c1385ec83621771bb9db58d96
Author: Richard Biener <rguenther@suse.de>
Date: Mon Oct 16 12:50:46 2023 +0200
middle-end/111818 - failed DECL_NOT_GIMPLE_REG_P setting of volatile
The following addresses a missed DECL_NOT_GIMPLE_REG_P setting of
a volatile declared parameter which causes inlining to substitute
a constant parameter into a context where its address is required.
The main issue is in update_address_taken which clears
DECL_NOT_GIMPLE_REG_P from the parameter but fails to rewrite it
because is_gimple_reg returns false for volatiles. The following
changes maybe_optimize_var to make the 1:1 correspondence between
clearing DECL_NOT_GIMPLE_REG_P of a register typed decl and
actually rewriting it to SSA.
PR middle-end/111818
* tree-ssa.cc (maybe_optimize_var): When clearing
DECL_NOT_GIMPLE_REG_P always rewrite into SSA.
* gcc.dg/torture/pr111818.c: New testcase.
(cherry picked from commit ce55521bcd149fdc431f1d78e706b66d470210ae)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/111818] [11 Regression] ICE with __builtin_memcpy with volatile and constants
2023-10-15 1:38 [Bug c/111818] New: GCC: 14: internal compiler error: tree check: expected tree that contains 'decl common' structure, have 'integer_cst' in tree_could_trap_p, at tree-eh.cc:2733 141242068 at smail dot nju.edu.cn
` (5 preceding siblings ...)
2023-11-27 13:09 ` [Bug middle-end/111818] [11/12 " cvs-commit at gcc dot gnu.org
@ 2023-12-15 12:18 ` cvs-commit at gcc dot gnu.org
2023-12-15 12:22 ` rguenth at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-15 12:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111818
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:45c296f2d81f6259e268e07707b4aa87dffba20a
commit r11-11142-g45c296f2d81f6259e268e07707b4aa87dffba20a
Author: Richard Biener <rguenther@suse.de>
Date: Mon Oct 16 12:50:46 2023 +0200
middle-end/111818 - failed DECL_NOT_GIMPLE_REG_P setting of volatile
The following addresses a missed DECL_NOT_GIMPLE_REG_P setting of
a volatile declared parameter which causes inlining to substitute
a constant parameter into a context where its address is required.
The main issue is in update_address_taken which clears
DECL_NOT_GIMPLE_REG_P from the parameter but fails to rewrite it
because is_gimple_reg returns false for volatiles. The following
changes maybe_optimize_var to make the 1:1 correspondence between
clearing DECL_NOT_GIMPLE_REG_P of a register typed decl and
actually rewriting it to SSA.
PR middle-end/111818
* tree-ssa.c (maybe_optimize_var): When clearing
DECL_NOT_GIMPLE_REG_P always rewrite into SSA.
* gcc.dg/torture/pr111818.c: New testcase.
(cherry picked from commit ce55521bcd149fdc431f1d78e706b66d470210ae)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/111818] [11 Regression] ICE with __builtin_memcpy with volatile and constants
2023-10-15 1:38 [Bug c/111818] New: GCC: 14: internal compiler error: tree check: expected tree that contains 'decl common' structure, have 'integer_cst' in tree_could_trap_p, at tree-eh.cc:2733 141242068 at smail dot nju.edu.cn
` (6 preceding siblings ...)
2023-12-15 12:18 ` [Bug middle-end/111818] [11 " cvs-commit at gcc dot gnu.org
@ 2023-12-15 12:22 ` rguenth at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-12-15 12:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111818
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |11.4.0
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
Known to work| |11.4.1
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-12-15 12:22 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-15 1:38 [Bug c/111818] New: GCC: 14: internal compiler error: tree check: expected tree that contains 'decl common' structure, have 'integer_cst' in tree_could_trap_p, at tree-eh.cc:2733 141242068 at smail dot nju.edu.cn
2023-10-15 1:47 ` [Bug middle-end/111818] [11/12/13/14 Regression] ICE with __builtin_memcpy with volatile and constants pinskia at gcc dot gnu.org
2023-10-16 6:59 ` rguenth at gcc dot gnu.org
2023-10-17 6:26 ` cvs-commit at gcc dot gnu.org
2023-10-17 6:27 ` [Bug middle-end/111818] [11/12/13 " rguenth at gcc dot gnu.org
2023-11-10 14:24 ` cvs-commit at gcc dot gnu.org
2023-11-27 13:09 ` [Bug middle-end/111818] [11/12 " cvs-commit at gcc dot gnu.org
2023-12-15 12:18 ` [Bug middle-end/111818] [11 " cvs-commit at gcc dot gnu.org
2023-12-15 12:22 ` rguenth 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).