public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794)
@ 2024-03-20 21:02 sjames at gcc dot gnu.org
2024-03-20 21:05 ` [Bug c++/114409] " sjames at gcc dot gnu.org
` (18 more replies)
0 siblings, 19 replies; 20+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-03-20 21:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114409
Bug ID: 114409
Summary: ICE after adding novector pragmas (internal compiler
error: in tsubst_expr, at cp/pt.cc:21794)
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: sjames at gcc dot gnu.org
Target Milestone: ---
Created attachment 57751
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57751&action=edit
EarlyCSE.cpp.ii.xz
While working on PR114403, I was adding novector pragmas and ended up hitting
an ICE.
```
$ g++ -c
/home/sam/data/build/llvm-project-test/lib/Transforms/Scalar/CMakeFiles/LLVMScalarOpts.dir/EarlyCSE.cpp.ii
In file included from
/home/sam/git/llvm-project/llvm/lib/Transforms/Scalar/EarlyCSE.cpp:18:
/home/sam/git/llvm-project/llvm/include/llvm/ADT/ScopedHashTable.h: In
instantiation of ‘llvm::ScopedHashTableScope<K, V, KInfo,
AllocatorTy>::~ScopedHashTableScope() [with K = {anonymous}::SimpleValue; V =
llvm::Value*; KInfo = llvm::DenseMapInfo<{anonymous}::SimpleValue>; AllocatorTy
= llvm::RecyclingAllocator<llvm::BumpPtrAllocatorImpl<>,
llvm::ScopedHashTableVal<{anonymous}::SimpleValue, llvm::Value*> >]’:
/home/sam/git/llvm-project/llvm/lib/Transforms/Scalar/EarlyCSE.cpp:671:9:
required from here
671 | : Scope(AvailableValues), LoadScope(AvailableLoads),
| ^~~~~~~~~~~~~~~~~~~~~~
/home/sam/git/llvm-project/llvm/include/llvm/ADT/ScopedHashTable.h:241:36:
internal compiler error: in tsubst_expr, at cp/pt.cc:21794
241 | while (ScopedHashTableVal<K, V> *ThisEntry = LastValInScope) {
| ^~~~~~~~~
0x55963b55a154 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
/usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/cp/pt.cc:21794
0x55963cdda158 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
/usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/cp/pt.cc:20637
0x55963b55a4ff tsubst_expr(tree_node*, tree_node*, int, tree_node*)
/usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/cp/pt.cc:21776
0x55963d07cfa1 tsubst_stmt
/usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/cp/pt.cc:19438
0x55963d07dbe9 tsubst_stmt
/usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/cp/pt.cc:18676
0x55963d07cfe3 tsubst_stmt
/usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/cp/pt.cc:18398
0x55963d07cea6 tsubst_stmt
/usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/cp/pt.cc:18771
0x55963d07cfe3 tsubst_stmt
/usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/cp/pt.cc:18398
0x55963d07cea6 tsubst_stmt
/usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/cp/pt.cc:18771
0x55963d3347e8 instantiate_body
/usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/cp/pt.cc:27064
0x55963cf46498 instantiate_decl(tree_node*, bool, bool)
/usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/cp/pt.cc:27349
0x55963ca8a8c1 instantiate_pending_templates(int)
/usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/cp/pt.cc:27425
0x55963ca7f13a c_parse_final_cleanups()
/usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/cp/decl2.cc:5151
0x55963d25b647 c_common_parse_file()
/usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/c-family/c-opts.cc:1329
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://bugs.gentoo.org/> for instructions.
```
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/114409] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794)
2024-03-20 21:02 [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) sjames at gcc dot gnu.org
@ 2024-03-20 21:05 ` sjames at gcc dot gnu.org
2024-03-20 21:16 ` pinskia at gcc dot gnu.org
` (17 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-03-20 21:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114409
--- Comment #1 from Sam James <sjames at gcc dot gnu.org> ---
If you can think of a workaround, please let me know, as unfortunately this
loop is the one where the assert in the other bug gets hit :(
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/114409] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794)
2024-03-20 21:02 [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) sjames at gcc dot gnu.org
2024-03-20 21:05 ` [Bug c++/114409] " sjames at gcc dot gnu.org
@ 2024-03-20 21:16 ` pinskia at gcc dot gnu.org
2024-03-20 21:21 ` pinskia at gcc dot gnu.org
` (16 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-20 21:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114409
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Just an FYI, using unroll instead of novect also ICEs. Let me reduce this and
see if it is a regression.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/114409] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794)
2024-03-20 21:02 [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) sjames at gcc dot gnu.org
2024-03-20 21:05 ` [Bug c++/114409] " sjames at gcc dot gnu.org
2024-03-20 21:16 ` pinskia at gcc dot gnu.org
@ 2024-03-20 21:21 ` pinskia at gcc dot gnu.org
2024-03-20 21:26 ` pinskia at gcc dot gnu.org
` (15 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-20 21:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114409
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Sam James from comment #1)
> If you can think of a workaround, please let me know, as unfortunately this
> loop is the one where the assert in the other bug gets hit :(
An easy workaround is to add:
asm("":::"memory");
Right after the opening `{`.
But that might be too much of a hammer in some cases ...
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/114409] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794)
2024-03-20 21:02 [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) sjames at gcc dot gnu.org
` (2 preceding siblings ...)
2024-03-20 21:21 ` pinskia at gcc dot gnu.org
@ 2024-03-20 21:26 ` pinskia at gcc dot gnu.org
2024-03-20 21:29 ` sjames at gcc dot gnu.org
` (14 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-20 21:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114409
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)
> (In reply to Sam James from comment #1)
> > If you can think of a workaround, please let me know, as unfortunately this
> > loop is the one where the assert in the other bug gets hit :(
>
> An easy workaround is to add:
> asm("":::"memory");
>
> Right after the opening `{`.
> But that might be too much of a hammer in some cases ...
Even a simple `__builtin_printf("");` added to the loop might avoid the
vectorization to figure out where the wrong code happens.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/114409] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794)
2024-03-20 21:02 [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) sjames at gcc dot gnu.org
` (3 preceding siblings ...)
2024-03-20 21:26 ` pinskia at gcc dot gnu.org
@ 2024-03-20 21:29 ` sjames at gcc dot gnu.org
2024-03-21 9:37 ` rguenth at gcc dot gnu.org
` (13 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-03-20 21:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114409
--- Comment #5 from Sam James <sjames at gcc dot gnu.org> ---
Thanks, I'll play with those...
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/114409] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794)
2024-03-20 21:02 [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) sjames at gcc dot gnu.org
` (4 preceding siblings ...)
2024-03-20 21:29 ` sjames at gcc dot gnu.org
@ 2024-03-21 9:37 ` rguenth at gcc dot gnu.org
2024-03-21 13:17 ` jakub at gcc dot gnu.org
` (12 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-03-21 9:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114409
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
The alternative is "bisceting" with -fdbg-cnt=vect_loop (IIRC there were some
ICEs reported when using that, so YMMV)
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/114409] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794)
2024-03-20 21:02 [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) sjames at gcc dot gnu.org
` (5 preceding siblings ...)
2024-03-21 9:37 ` rguenth at gcc dot gnu.org
@ 2024-03-21 13:17 ` jakub at gcc dot gnu.org
2024-03-21 13:26 ` jakub at gcc dot gnu.org
` (11 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-03-21 13:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114409
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Reduced testcase:
template <typename T>
void
foo (T x)
{
#pragma GCC novector
while (T y = x)
{
++y;
}
}
void
bar ()
{
foo (-42);
}
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/114409] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794)
2024-03-20 21:02 [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) sjames at gcc dot gnu.org
` (6 preceding siblings ...)
2024-03-21 13:17 ` jakub at gcc dot gnu.org
@ 2024-03-21 13:26 ` jakub at gcc dot gnu.org
2024-03-21 13:41 ` [Bug c++/114409] [14 Regression] " jakub at gcc dot gnu.org
` (10 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-03-21 13:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114409
--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Perhaps better testcase:
template <typename T>
T
foo (T)
{
static T t;
return 42 - ++t;
}
template <typename T>
void
bar (T x)
{
#pragma GCC novector
while (T y = foo (x))
;
}
void
baz ()
{
bar (0);
}
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/114409] [14 Regression] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794)
2024-03-20 21:02 [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) sjames at gcc dot gnu.org
` (7 preceding siblings ...)
2024-03-21 13:26 ` jakub at gcc dot gnu.org
@ 2024-03-21 13:41 ` jakub at gcc dot gnu.org
2024-03-21 13:53 ` jakub at gcc dot gnu.org
` (9 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-03-21 13:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114409
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |14.0
CC| |jason at gcc dot gnu.org,
| |ppalka at gcc dot gnu.org
Priority|P3 |P1
Summary|ICE after adding novector |[14 Regression] ICE after
|pragmas (internal compiler |adding novector pragmas
|error: in tsubst_expr, at |(internal compiler error:
|cp/pt.cc:21794) |in tsubst_expr, at
| |cp/pt.cc:21794)
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r14-4229-g9c62af101e11e1cce573c2b3d2e18b403412dbc8
The ANNOTATE_EXPR has a COMPOUND_EXPR with DECL_EXPR inside of it and
tsubst_copy_and_build doesn't handle that.
Wonder if the DECL_EXPR shouldn't be before the ANNOTATE_EXPR instead, at least
without templates I see in original dump
int y;
<<cleanup_point <<< Unknown tree: expr_stmt
(void) (y = foo<int> (x)) >>>>>;
if (!ANNOTATE_EXPR <y != 0, no-vector>) goto <D.2804>;
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/114409] [14 Regression] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794)
2024-03-20 21:02 [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) sjames at gcc dot gnu.org
` (8 preceding siblings ...)
2024-03-21 13:41 ` [Bug c++/114409] [14 Regression] " jakub at gcc dot gnu.org
@ 2024-03-21 13:53 ` jakub at gcc dot gnu.org
2024-03-21 14:31 ` jakub at gcc dot gnu.org
` (8 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-03-21 13:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114409
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2024-03-21
Status|UNCONFIRMED |NEW
--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Note, when not in a template, such as
void
qux (int x)
{
#pragma GCC novector
while (int y = foo (x))
;
}
with the above foo template, we ignore the annotation because the middle-end
doesn't find it at the right spot:
warning: ignoring loop annotation
C doesn't allow defining a variable in while loop's condition, so can't
cross-check what it does instead.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/114409] [14 Regression] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794)
2024-03-20 21:02 [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) sjames at gcc dot gnu.org
` (9 preceding siblings ...)
2024-03-21 13:53 ` jakub at gcc dot gnu.org
@ 2024-03-21 14:31 ` jakub at gcc dot gnu.org
2024-03-21 20:39 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-03-21 14:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114409
--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 57758
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57758&action=edit
gcc14-pr114409.patch
Ah, I have a fix for the bogus warning, ANNOTATE_EXPR really needs to wrap the
whole condition rather than just part of it.
But, I have no idea what to do with the templates case.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/114409] [14 Regression] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794)
2024-03-20 21:02 [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) sjames at gcc dot gnu.org
` (10 preceding siblings ...)
2024-03-21 14:31 ` jakub at gcc dot gnu.org
@ 2024-03-21 20:39 ` pinskia at gcc dot gnu.org
2024-04-10 7:58 ` [Bug c++/114409] [14 Regression] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) since r14-4229-g9c62af101e11e1cce573c2b3d2e18b403412dbc8 rguenth at gcc dot gnu.org
` (6 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-21 20:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114409
--- Comment #12 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced to use `GCC unroll` instead:
```
template <int> int t() {
#pragma GCC unroll 4
while (int ThisEntry = 0) { }
}
int tt = t<1>();
```
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/114409] [14 Regression] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) since r14-4229-g9c62af101e11e1cce573c2b3d2e18b403412dbc8
2024-03-20 21:02 [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) sjames at gcc dot gnu.org
` (11 preceding siblings ...)
2024-03-21 20:39 ` pinskia at gcc dot gnu.org
@ 2024-04-10 7:58 ` rguenth at gcc dot gnu.org
2024-04-10 12:40 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-04-10 7:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114409
--- Comment #13 from Richard Biener <rguenth at gcc dot gnu.org> ---
The question is what handles the COMPOUND_EXPR with DECL_EXPR when the
ANNOTATE_EXPR isn't around. tsubst_expr doesn't handle DECL_EXPRs.
It's built even w/o the #pragma via finish_cond and finish_while_stmt_cond
and in that case it's tsubst_stmt that handles the COMPOUND_EXPR and
that function does handle DECL_EXPRs. Maybe ANNOTATE_EXPR should be handled
at the "stmt" level [as well]? Or the COMPOUND_EXPR handling in
tsubst_expr should recurse to tsubst_stmt?
That said, ( DECL_EXPR <X>, .. use of X ) is phishy?
Jason?
The following fixes it:
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index bf4b89d8413..dae423a751f 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -20635,8 +20635,11 @@ tsubst_expr (tree t, tree args, tsubst_flags_t
complain, tree in_decl)
case COMPOUND_EXPR:
{
- tree op0 = tsubst_expr (TREE_OPERAND (t, 0), args,
+ tree op0 = tsubst_stmt (TREE_OPERAND (t, 0), args,
complain & ~tf_decltype, in_decl);
+ if (op0 == NULL_TREE)
+ /* If the first operand was a statement, we're done with it. */
+ RETURN (RECUR (TREE_OPERAND (t, 1)));
RETURN (build_x_compound_expr (EXPR_LOCATION (t),
op0,
RECUR (TREE_OPERAND (t, 1)),
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/114409] [14 Regression] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) since r14-4229-g9c62af101e11e1cce573c2b3d2e18b403412dbc8
2024-03-20 21:02 [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) sjames at gcc dot gnu.org
` (12 preceding siblings ...)
2024-04-10 7:58 ` [Bug c++/114409] [14 Regression] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) since r14-4229-g9c62af101e11e1cce573c2b3d2e18b403412dbc8 rguenth at gcc dot gnu.org
@ 2024-04-10 12:40 ` jakub at gcc dot gnu.org
2024-04-10 12:49 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-04-10 12:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114409
--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I had another look at this.
The reason why this works without the pragmas (i.e. without ANNOTATE_EXPRs) is
that
the WHILE_COND/FOR_COND are handled not by tsubst_expr but tsubst_stmt:
case FOR_STMT:
stmt = begin_for_stmt (NULL_TREE, NULL_TREE);
RECUR (FOR_INIT_STMT (t));
finish_init_stmt (stmt);
tmp = RECUR (FOR_COND (t));
finish_for_cond (tmp, stmt, false, 0, false);
and
case WHILE_STMT:
stmt = begin_while_stmt ();
tmp = RECUR (WHILE_COND (t));
finish_while_stmt_cond (tmp, stmt, false, 0, false);
in tsubst_stmt, where RECUR in that case means tsubst_stmt, not tsubst_expr.
So, one possible fix is to use tsubst_stmt rather than RECUR aka tsubst_expr
on the first operand of ANNOTATE_EXPR.
And another would be to move the ANNOTATE_EXPR handling from tsubst_expr to
tsubst_stmt.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/114409] [14 Regression] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) since r14-4229-g9c62af101e11e1cce573c2b3d2e18b403412dbc8
2024-03-20 21:02 [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) sjames at gcc dot gnu.org
` (13 preceding siblings ...)
2024-04-10 12:40 ` jakub at gcc dot gnu.org
@ 2024-04-10 12:49 ` jakub at gcc dot gnu.org
2024-04-10 12:50 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-04-10 12:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114409
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 #15 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 57917
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57917&action=edit
gcc14-pr114409-1.patch
One possible untested fix.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/114409] [14 Regression] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) since r14-4229-g9c62af101e11e1cce573c2b3d2e18b403412dbc8
2024-03-20 21:02 [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) sjames at gcc dot gnu.org
` (14 preceding siblings ...)
2024-04-10 12:49 ` jakub at gcc dot gnu.org
@ 2024-04-10 12:50 ` jakub at gcc dot gnu.org
2024-04-11 7:48 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-04-10 12:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114409
--- Comment #16 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 57918
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57918&action=edit
gcc14-pr114409-2.patch
Another possible untested fix.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/114409] [14 Regression] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) since r14-4229-g9c62af101e11e1cce573c2b3d2e18b403412dbc8
2024-03-20 21:02 [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) sjames at gcc dot gnu.org
` (15 preceding siblings ...)
2024-04-10 12:50 ` jakub at gcc dot gnu.org
@ 2024-04-11 7:48 ` cvs-commit at gcc dot gnu.org
2024-04-11 10:10 ` jakub at gcc dot gnu.org
2024-04-11 10:11 ` jakub at gcc dot gnu.org
18 siblings, 0 replies; 20+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-11 7:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114409
--- Comment #17 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:cb46aca0a07355abf2f0b04f52087bca8f848524
commit r14-9910-gcb46aca0a07355abf2f0b04f52087bca8f848524
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu Apr 11 09:46:00 2024 +0200
c++: Fix ANNOTATE_EXPR instantiation [PR114409]
The following testcase ICEs starting with the r14-4229 PR111529
change which moved ANNOTATE_EXPR handling from tsubst_expr to
tsubst_copy_and_build.
ANNOTATE_EXPR is only allowed in the IL to wrap a loop condition,
and the loop condition of while/for loops can be a COMPOUND_EXPR
with DECL_EXPR in the first operand and the corresponding VAR_DECL
in the second, as created by finish_cond
else if (!empty_expr_stmt_p (cond))
expr = build2 (COMPOUND_EXPR, TREE_TYPE (expr), cond, expr);
Since then Patrick reworked the instantiation, so that we have now
tsubst_stmt and tsubst_expr and ANNOTATE_EXPR ended up in the latter,
while only tsubst_stmt can handle DECL_EXPR.
Now, the reason why the while/for loops with variable declaration
in the condition works in templates without the pragmas (i.e. without
ANNOTATE_EXPR) is that both the FOR_STMT and WHILE_STMT handling uses
RECUR aka tsubst_stmt in handling of the *_COND operand:
case FOR_STMT:
stmt = begin_for_stmt (NULL_TREE, NULL_TREE);
RECUR (FOR_INIT_STMT (t));
finish_init_stmt (stmt);
tmp = RECUR (FOR_COND (t));
finish_for_cond (tmp, stmt, false, 0, false);
and
case WHILE_STMT:
stmt = begin_while_stmt ();
tmp = RECUR (WHILE_COND (t));
finish_while_stmt_cond (tmp, stmt, false, 0, false);
Therefore, it will handle DECL_EXPR embedded in COMPOUND_EXPR of the
{WHILE,FOR}_COND just fine.
But if that COMPOUND_EXPR with DECL_EXPR is wrapped with one or more
ANNOTATE_EXPRs, because ANNOTATE_EXPR is now done solely in tsubst_expr
and uses RECUR there (i.e. tsubst_expr), it will ICE on DECL_EXPR in there.
This could be fixed by keeping ANNOTATE_EXPR handling in tsubst_expr but
using tsubst_stmt for the first operand, but this patch instead
moves ANNOTATE_EXPR handling to tsubst_stmt (and uses tsubst_expr for the
second/third operand).
2024-04-11 Jakub Jelinek <jakub@redhat.com>
PR c++/114409
* pt.cc (tsubst_expr) <case ANNOTATE_EXPR>: Move to ...
(tsubst_stmt) <case ANNOTATE_EXPR>: ... here. Use tsubst_expr
instead of RECUR for the last 2 arguments.
* g++.dg/ext/pr114409-2.C: New test.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/114409] [14 Regression] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) since r14-4229-g9c62af101e11e1cce573c2b3d2e18b403412dbc8
2024-03-20 21:02 [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) sjames at gcc dot gnu.org
` (16 preceding siblings ...)
2024-04-11 7:48 ` cvs-commit at gcc dot gnu.org
@ 2024-04-11 10:10 ` jakub at gcc dot gnu.org
2024-04-11 10:11 ` jakub at gcc dot gnu.org
18 siblings, 0 replies; 20+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-04-11 10:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114409
--- Comment #18 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The P1 bug has been fixed, I've moved the rest to PR114691.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/114409] [14 Regression] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) since r14-4229-g9c62af101e11e1cce573c2b3d2e18b403412dbc8
2024-03-20 21:02 [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) sjames at gcc dot gnu.org
` (17 preceding siblings ...)
2024-04-11 10:10 ` jakub at gcc dot gnu.org
@ 2024-04-11 10:11 ` jakub at gcc dot gnu.org
18 siblings, 0 replies; 20+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-04-11 10:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114409
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #19 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
.
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2024-04-11 10:11 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-20 21:02 [Bug c++/114409] New: ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) sjames at gcc dot gnu.org
2024-03-20 21:05 ` [Bug c++/114409] " sjames at gcc dot gnu.org
2024-03-20 21:16 ` pinskia at gcc dot gnu.org
2024-03-20 21:21 ` pinskia at gcc dot gnu.org
2024-03-20 21:26 ` pinskia at gcc dot gnu.org
2024-03-20 21:29 ` sjames at gcc dot gnu.org
2024-03-21 9:37 ` rguenth at gcc dot gnu.org
2024-03-21 13:17 ` jakub at gcc dot gnu.org
2024-03-21 13:26 ` jakub at gcc dot gnu.org
2024-03-21 13:41 ` [Bug c++/114409] [14 Regression] " jakub at gcc dot gnu.org
2024-03-21 13:53 ` jakub at gcc dot gnu.org
2024-03-21 14:31 ` jakub at gcc dot gnu.org
2024-03-21 20:39 ` pinskia at gcc dot gnu.org
2024-04-10 7:58 ` [Bug c++/114409] [14 Regression] ICE after adding novector pragmas (internal compiler error: in tsubst_expr, at cp/pt.cc:21794) since r14-4229-g9c62af101e11e1cce573c2b3d2e18b403412dbc8 rguenth at gcc dot gnu.org
2024-04-10 12:40 ` jakub at gcc dot gnu.org
2024-04-10 12:49 ` jakub at gcc dot gnu.org
2024-04-10 12:50 ` jakub at gcc dot gnu.org
2024-04-11 7:48 ` cvs-commit at gcc dot gnu.org
2024-04-11 10:10 ` jakub at gcc dot gnu.org
2024-04-11 10:11 ` 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).