public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/108520] New: [C2x] ICE in nonnull_arg_p, at tree.cc:14372 with -O1 and above (gnu::assume)
@ 2023-01-24 15:53 pexu@gcc-bugzilla.mail.kapsi.fi
2023-01-24 15:57 ` [Bug middle-end/108520] [13 Regression] " mpolacek at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: pexu@gcc-bugzilla.mail.kapsi.fi @ 2023-01-24 15:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108520
Bug ID: 108520
Summary: [C2x] ICE in nonnull_arg_p, at tree.cc:14372 with -O1
and above (gnu::assume)
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: pexu@gcc-bugzilla.mail.kapsi.fi
Target Milestone: ---
Hi.
Consider the following testcase. The important aspects are i) optimized, ii)
array of structures containing multiple elements, iii) assume.
Using 13.0.1 20230124 (experimental).
# cat assume.c
static
void f0() { }
[[ gnu::nonnull(1) ]]
void f1(void *)
{
const struct { void (*f)(); } af[] = {
{ f0 } , { f0 } , { f0 }
};
for (__typeof__(af[0]) * it = af, * const end = af + sizeof(af) /
sizeof(af[0]); it != end; ++it)
{
[[ gnu::assume (it->f) ]];
it->f();
}
}
# gcc -c -std=gnu2x -Wall -Wextra -O1 assume.c
during GIMPLE pass: ethread
assume.c: In function 'f1':
assume.c:16:3: internal compiler error: in nonnull_arg_p, at tree.cc:14372
---
(gdb) bt
#0 <address> in fancy_abort(char const*, int, char const*) ()
#1 <address> in nonnull_arg_p(tree_node const*) [clone .cold] ()
#2 <address> in get_range_global (r=..., name=<optimized out>)
at <...>/src/gcc/gcc/value-query.cc:330
#3 <address> in global_range_query::range_of_expr (this=<optimized out>,
r=..., expr=<optimized out>,
stmt=<optimized out>) at <...>/src/gcc/gcc/value-query.cc:406
#4 <address> in gimple_infer_range::check_assume_func (this=<optimized out>,
call=<optimized out>)
at <...>/src/gcc/gcc/gimple-range-infer.cc:87
#5 <address> in gimple_infer_range::gimple_infer_range (this=<optimized out>,
s=<optimized out>)
at <...>/src/gcc/gcc/gimple-range-infer.cc:166
#6 <address> in infer_range_manager::register_all_uses (this=<optimized out>,
name=<optimized out>)
at <...>/src/gcc/gcc/gimple-range-infer.cc:374
#7 <address> in infer_range_manager::has_range_p (this=<optimized out>,
name=<optimized out>,
bb=<optimized out>) at <...>/src/gcc/gcc/gimple-range-infer.cc:273
#8 <address> in infer_range_manager::maybe_adjust_range (this=<optimized out>,
r=..., name=<optimized out>,
bb=<optimized out>) at <...>/src/gcc/gcc/gimple-range-infer.cc:290
#9 <address> in path_range_query::adjust_for_non_null_uses (this=<optimized
out>, bb=<optimized out>)
at <...>/src/gcc/gcc/gimple-range-path.cc:502
#10 <address> in path_range_query::compute_ranges (this=<optimized out>,
dependencies=<optimized out>)
at <...>/src/gcc/gcc/gimple-range-path.cc:623
#11 <address> in back_threader::find_taken_edge_cond (this=<optimized out>,
path=..., cond=<optimized out>)
at <...>/src/gcc/gcc/bitmap.h:955
#12 <address> in back_threader::maybe_register_path (this=<optimized out>,
profit=...)
at <...>/src/gcc/gcc/tree-ssa-threadbackward.cc:248
#13 <address> in back_threader::find_paths_to_names (this=<optimized out>,
bb=<optimized out>,
interesting=<optimized out>, overall_paths=<optimized out>,
at <...>/src/gcc/gcc/tree-ssa-threadbackward.cc:371
#14 <address> in back_threader::find_paths_to_names (this=<optimized out>,
bb=<optimized out>,
interesting=<optimized out>, overall_paths=<optimized out>,
at <...>/src/gcc/gcc/bitmap.h:955
#15 <address> in back_threader::maybe_thread_block (this=<optimized out>,
bb=<optimized out>)
at <...>/src/gcc/gcc/bitmap.h:955
#16 <address> in back_threader::thread_blocks (this=<optimized out>)
at <...>/src/gcc/gcc/tree-ssa-threadbackward.cc:975
#17 <address> in pass_thread_jumps_full::execute (this=<optimized out>,
fun=<optimized out>)
at <...>/src/gcc/gcc/tree-ssa-threadbackward.cc:1105
#18 <address> in execute_one_pass (pass=<optimized out>)
at <...>/src/gcc/gcc/passes.cc:2644
#19 <address> in execute_pass_list_1 (pass=<optimized out>)
at <...>/src/gcc/gcc/passes.cc:2753
#20 <address> in execute_pass_list_1 (pass=<optimized out>)
at <...>/src/gcc/gcc/passes.cc:2754
#21 <address> in execute_pass_list (fn=<optimized out>, pass=<optimized out>)
at <...>/src/gcc/gcc/passes.cc:2764
#22 <address> in cgraph_node::expand (this=<optimized out>)
at <...>/src/gcc/gcc/context.h:48
#23 <address> in symbol_table::compile (this=<optimized out>)
at <...>/src/gcc/gcc/cgraphunit.cc:2015
#24 <address> in symbol_table::finalize_compilation_unit (this=<optimized out>)
at <...>/src/gcc/gcc/cgraphunit.cc:2302
#25 <address> in compile_file () at <...>/src/gcc/gcc/toplev.cc:471
#26 <address> in toplev::main(int, char**) ()
#27 <address> in main (argc=<...>, argv=<...>) at <...>/src/gcc/gcc/main.cc:39
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/108520] [13 Regression] [C2x] ICE in nonnull_arg_p, at tree.cc:14372 with -O1 and above (gnu::assume)
2023-01-24 15:53 [Bug c/108520] New: [C2x] ICE in nonnull_arg_p, at tree.cc:14372 with -O1 and above (gnu::assume) pexu@gcc-bugzilla.mail.kapsi.fi
@ 2023-01-24 15:57 ` mpolacek at gcc dot gnu.org
2023-01-24 16:17 ` [Bug tree-optimization/108520] [13 Regression] ICE in nonnull_arg_p, at tree.cc:14372 with -O1 and above (gnu::assume and gnu::nonnull) pinskia at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-01-24 15:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108520
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
Last reconfirmed| |2023-01-24
Summary|[C2x] ICE in nonnull_arg_p, |[13 Regression] [C2x] ICE
|at tree.cc:14372 with -O1 |in nonnull_arg_p, at
|and above (gnu::assume) |tree.cc:14372 with -O1 and
| |above (gnu::assume)
Status|UNCONFIRMED |NEW
Target Milestone|--- |13.0
CC| |mpolacek at gcc dot gnu.org
Component|c |middle-end
Ever confirmed|0 |1
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/108520] [13 Regression] ICE in nonnull_arg_p, at tree.cc:14372 with -O1 and above (gnu::assume and gnu::nonnull)
2023-01-24 15:53 [Bug c/108520] New: [C2x] ICE in nonnull_arg_p, at tree.cc:14372 with -O1 and above (gnu::assume) pexu@gcc-bugzilla.mail.kapsi.fi
2023-01-24 15:57 ` [Bug middle-end/108520] [13 Regression] " mpolacek at gcc dot gnu.org
@ 2023-01-24 16:17 ` pinskia at gcc dot gnu.org
2023-01-26 13:30 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-24 16:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108520
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|middle-end |tree-optimization
Summary|[13 Regression] [C2x] ICE |[13 Regression] ICE in
|in nonnull_arg_p, at |nonnull_arg_p, at
|tree.cc:14372 with -O1 and |tree.cc:14372 with -O1 and
|above (gnu::assume) |above (gnu::assume and
| |gnu::nonnull)
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, simplified C/C++ testcase:
```
static void f0() { }
typedef void (*ft)();
struct st { ft f; };
#define array_s 3
[[ gnu::nonnull(1) ]]
void f1(void *)
{
struct st af[array_s] = {
{ f0 } , { f0 } , { f0 }
};
for (struct st *i = af, *e = af+array_s; i != e; i++)
{
[[ gnu::assume (i->f) ]];
i->f();
}
}
```
get_range_global is assuming (bad pun) that it can call nonnull_arg_p even for
non-current function parm_decls.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/108520] [13 Regression] ICE in nonnull_arg_p, at tree.cc:14372 with -O1 and above (gnu::assume and gnu::nonnull)
2023-01-24 15:53 [Bug c/108520] New: [C2x] ICE in nonnull_arg_p, at tree.cc:14372 with -O1 and above (gnu::assume) pexu@gcc-bugzilla.mail.kapsi.fi
2023-01-24 15:57 ` [Bug middle-end/108520] [13 Regression] " mpolacek at gcc dot gnu.org
2023-01-24 16:17 ` [Bug tree-optimization/108520] [13 Regression] ICE in nonnull_arg_p, at tree.cc:14372 with -O1 and above (gnu::assume and gnu::nonnull) pinskia at gcc dot gnu.org
@ 2023-01-26 13:30 ` jakub at gcc dot gnu.org
2023-01-26 13:31 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-26 13:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108520
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |aldyh at gcc dot gnu.org,
| |amacleod at redhat dot com,
| |jakub at gcc dot gnu.org
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, unless nothing in the ranger uses cfun but passes around struct function
*fun
on which it should operate, I think gimple_infer_range::check_assume_func needs
to
temporarily set_cfun to fun and switch it back later.
Generally set_cfun is fairly expensive, but for the assumption functions one
would hope that at least in most cases they have the same optimization and
target nodes as the "caller".
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/108520] [13 Regression] ICE in nonnull_arg_p, at tree.cc:14372 with -O1 and above (gnu::assume and gnu::nonnull)
2023-01-24 15:53 [Bug c/108520] New: [C2x] ICE in nonnull_arg_p, at tree.cc:14372 with -O1 and above (gnu::assume) pexu@gcc-bugzilla.mail.kapsi.fi
` (2 preceding siblings ...)
2023-01-26 13:30 ` jakub at gcc dot gnu.org
@ 2023-01-26 13:31 ` jakub at gcc dot gnu.org
2023-02-10 14:49 ` cvs-commit at gcc dot gnu.org
2023-02-10 14:53 ` amacleod at redhat dot com
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-26 13:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108520
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Slightly cleaned up testcase:
static void foo () {}
struct S { void (*f) (); };
[[gnu::nonnull (1)]]
void
bar (void *x)
{
struct S a[3] = { { foo }, { foo }, { foo } };
for (struct S *i = a, *e = a + 3; i != e; i++)
{
[[assume (i->f)]];
i->f ();
}
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/108520] [13 Regression] ICE in nonnull_arg_p, at tree.cc:14372 with -O1 and above (gnu::assume and gnu::nonnull)
2023-01-24 15:53 [Bug c/108520] New: [C2x] ICE in nonnull_arg_p, at tree.cc:14372 with -O1 and above (gnu::assume) pexu@gcc-bugzilla.mail.kapsi.fi
` (3 preceding siblings ...)
2023-01-26 13:31 ` jakub at gcc dot gnu.org
@ 2023-02-10 14:49 ` cvs-commit at gcc dot gnu.org
2023-02-10 14:53 ` amacleod at redhat dot com
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-10 14:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108520
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andrew Macleod <amacleod@gcc.gnu.org>:
https://gcc.gnu.org/g:99f3ad2e5b117ee79a6dcf97288261e2fa32ab4c
commit r13-5806-g99f3ad2e5b117ee79a6dcf97288261e2fa32ab4c
Author: Andrew MacLeod <amacleod@redhat.com>
Date: Mon Feb 6 13:07:01 2023 -0500
Add function context for querying global ranges.
When processing arguments for assume functions, call get_global_range
directly and utilize a function context pointer to avoid any assumptions
about using cfun.
PR tree-optimization/108520
gcc/
* gimple-range-infer.cc (check_assume_func): Invoke
gimple_range_global directly instead using global_range_query.
* value-query.cc (get_range_global): Add function context and
avoid calling nonnull_arg_p if not cfun.
(gimple_range_global): Add function context pointer.
* value-query.h (imple_range_global): Add function context.
gcc/testsuite/
* g++.dg/pr108520.C: New.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/108520] [13 Regression] ICE in nonnull_arg_p, at tree.cc:14372 with -O1 and above (gnu::assume and gnu::nonnull)
2023-01-24 15:53 [Bug c/108520] New: [C2x] ICE in nonnull_arg_p, at tree.cc:14372 with -O1 and above (gnu::assume) pexu@gcc-bugzilla.mail.kapsi.fi
` (4 preceding siblings ...)
2023-02-10 14:49 ` cvs-commit at gcc dot gnu.org
@ 2023-02-10 14:53 ` amacleod at redhat dot com
5 siblings, 0 replies; 7+ messages in thread
From: amacleod at redhat dot com @ 2023-02-10 14:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108520
Andrew Macleod <amacleod at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #6 from Andrew Macleod <amacleod at redhat dot com> ---
fixed.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-02-10 14:53 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-24 15:53 [Bug c/108520] New: [C2x] ICE in nonnull_arg_p, at tree.cc:14372 with -O1 and above (gnu::assume) pexu@gcc-bugzilla.mail.kapsi.fi
2023-01-24 15:57 ` [Bug middle-end/108520] [13 Regression] " mpolacek at gcc dot gnu.org
2023-01-24 16:17 ` [Bug tree-optimization/108520] [13 Regression] ICE in nonnull_arg_p, at tree.cc:14372 with -O1 and above (gnu::assume and gnu::nonnull) pinskia at gcc dot gnu.org
2023-01-26 13:30 ` jakub at gcc dot gnu.org
2023-01-26 13:31 ` jakub at gcc dot gnu.org
2023-02-10 14:49 ` cvs-commit at gcc dot gnu.org
2023-02-10 14:53 ` amacleod at redhat dot com
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).