public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-6850] Ranger cache dominator queries should ignore backedges.
@ 2023-03-24 13:12 Andrew Macleod
0 siblings, 0 replies; only message in thread
From: Andrew Macleod @ 2023-03-24 13:12 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:0409aa5a2de9ce3164933814a4a7adc91f6acb96
commit r13-6850-g0409aa5a2de9ce3164933814a4a7adc91f6acb96
Author: Andrew MacLeod <amacleod@redhat.com>
Date: Thu Mar 23 10:28:34 2023 -0400
Ranger cache dominator queries should ignore backedges.
When querying dominators for cache values, ignore back edges in
read-only mode.
PR tree-optimization/109238
gcc/
* gimple-range-cache.cc (ranger_cache::resolve_dom): Ignore
predecessors which this block dominates.
gcc/testsuite/
* gcc.dg/pr109238.c: New.
Diff:
---
gcc/gimple-range-cache.cc | 5 +++++
gcc/testsuite/gcc.dg/pr109238.c | 16 ++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index cc56fd4dcb0..6a098d8ec28 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -1404,6 +1404,11 @@ ranger_cache::resolve_dom (vrange &r, tree name, basic_block bb)
Value_Range er (TREE_TYPE (name));
FOR_EACH_EDGE (e, ei, bb->preds)
{
+ // If the predecessor is dominated by this block, then there is a back
+ // edge, and won't provide anything useful. We'll actually end up with
+ // VARYING as we will not resolve this node.
+ if (dominated_by_p (CDI_DOMINATORS, e->src, bb))
+ continue;
edge_range (er, e, name, RFD_READ_ONLY);
r.union_ (er);
}
diff --git a/gcc/testsuite/gcc.dg/pr109238.c b/gcc/testsuite/gcc.dg/pr109238.c
new file mode 100644
index 00000000000..0cad8237208
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109238.c
@@ -0,0 +1,16 @@
+/* PR tree-optimization/109238 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wall" } */
+
+void foo (void *) __attribute__((noreturn));
+void bar (void *);
+
+void
+baz (void *p)
+{
+ void *c = __builtin_realloc (p, 16);
+ if (c)
+ foo (c);
+ for (;;)
+ bar (__builtin_realloc (p, 8)); /* { dg-bogus "pointer 'p' may be used after '__builtin_realloc'" } */
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-24 13:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-24 13:12 [gcc r13-6850] Ranger cache dominator queries should ignore backedges Andrew Macleod
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).