public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-1078] Convert Walloca pass to get_range_query.
Date: Wed, 26 May 2021 19:31:52 +0000 (GMT)	[thread overview]
Message-ID: <20210526193152.C6B41384783B@sourceware.org> (raw)

https://gcc.gnu.org/g:fe9a499cb8775cfbcea356ab0cae5c365971cf86

commit r12-1078-gfe9a499cb8775cfbcea356ab0cae5c365971cf86
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Wed May 19 18:27:47 2021 +0200

    Convert Walloca pass to get_range_query.
    
    This patch converts the Walloca pass to use an on-demand ranger
    accesible with get_range_query instead of having to create a ranger and pass
    it around.
    
    gcc/ChangeLog:
    
            * gimple-ssa-warn-alloca.c (alloca_call_type): Use
              get_range_query instead of query argument.
            (pass_walloca::execute): Enable and disable global ranger.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/Wstringop-overflow-55.c: Adapt for range query changes.
            * gcc.dg/pr80776-1.c: Same.

Diff:
---
 gcc/gimple-ssa-warn-alloca.c                 | 10 ++++++----
 gcc/testsuite/gcc.dg/Wstringop-overflow-55.c |  8 ++++----
 gcc/testsuite/gcc.dg/pr80776-1.c             |  4 +---
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/gcc/gimple-ssa-warn-alloca.c b/gcc/gimple-ssa-warn-alloca.c
index e9a24d4d1d0..72480f1d8cb 100644
--- a/gcc/gimple-ssa-warn-alloca.c
+++ b/gcc/gimple-ssa-warn-alloca.c
@@ -165,7 +165,7 @@ adjusted_warn_limit (bool idx)
 // call was created by the gimplifier for a VLA.
 
 static class alloca_type_and_limit
-alloca_call_type (range_query &query, gimple *stmt, bool is_vla)
+alloca_call_type (gimple *stmt, bool is_vla)
 {
   gcc_assert (gimple_alloca_call_p (stmt));
   tree len = gimple_call_arg (stmt, 0);
@@ -217,7 +217,7 @@ alloca_call_type (range_query &query, gimple *stmt, bool is_vla)
   int_range_max r;
   if (warn_limit_specified_p (is_vla)
       && TREE_CODE (len) == SSA_NAME
-      && query.range_of_expr (r, len, stmt)
+      && get_range_query (cfun)->range_of_expr (r, len, stmt)
       && !r.varying_p ())
     {
       // The invalid bits are anything outside of [0, MAX_SIZE].
@@ -256,7 +256,7 @@ in_loop_p (gimple *stmt)
 unsigned int
 pass_walloca::execute (function *fun)
 {
-  gimple_ranger ranger;
+  gimple_ranger *ranger = enable_ranger (fun);
   basic_block bb;
   FOR_EACH_BB_FN (bb, fun)
     {
@@ -290,7 +290,7 @@ pass_walloca::execute (function *fun)
 	    continue;
 
 	  class alloca_type_and_limit t
-	    = alloca_call_type (ranger, stmt, is_vla);
+	    = alloca_call_type (stmt, is_vla);
 
 	  unsigned HOST_WIDE_INT adjusted_alloca_limit
 	    = adjusted_warn_limit (false);
@@ -383,6 +383,8 @@ pass_walloca::execute (function *fun)
 	    }
 	}
     }
+  ranger->export_global_ranges ();
+  disable_ranger (fun);
   return 0;
 }
 
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-55.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-55.c
index 25f5b82d9be..8df5cb629ae 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-55.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-55.c
@@ -66,7 +66,7 @@ void warn_ptrdiff_anti_range_add (ptrdiff_t i)
 {
   i |= 1;
 
-  char ca5[5];              // { dg-message "at offset \\\[1, 5]" "pr?????" { xfail *-*-* } }
+  char ca5[5];              // { dg-message "at offset \\\[1, 5]" "pr?????" }
   char *p0 = ca5;           // offset
   char *p1 = p0 + i;        //  1-5
   char *p2 = p1 + i;        //  2-5
@@ -74,7 +74,7 @@ void warn_ptrdiff_anti_range_add (ptrdiff_t i)
   char *p4 = p3 + i;        //  4-5
   char *p5 = p4 + i;        //   5
 
-  memset (p5, 0, 5);        // { dg-warning "writing 5 bytes into a region of size 0" "pr?????" { xfail *-*-* } }
+  memset (p5, 0, 5);        // { dg-warning "writing 5 bytes into a region of size" "pr?????" }
 
   sink (p0, p1, p2, p3, p4, p5);
 }
@@ -83,7 +83,7 @@ void warn_int_anti_range (int i)
 {
   i |= 1;
 
-  char ca5[5];              // { dg-message "at offset \\\[1, 5]" "pr?????" { xfail *-*-* } }
+  char ca5[5];              // { dg-message "at offset \\\[1, 5]" "pr?????" }
   char *p0 = ca5;           // offset
   char *p1 = p0 + i;        //  1-5
   char *p2 = p1 + i;        //  2-5
@@ -91,7 +91,7 @@ void warn_int_anti_range (int i)
   char *p4 = p3 + i;        //  4-5
   char *p5 = p4 + i;        //   5
 
-  memset (p5, 0, 5);        // { dg-warning "writing 5 bytes into a region of size 0" "pr?????" { xfail *-*-* } }
+  memset (p5, 0, 5);        // { dg-warning "writing 5 bytes into a region of size" "pr?????" }
 
   sink (p0, p1, p2, p3, p4, p5);
 }
diff --git a/gcc/testsuite/gcc.dg/pr80776-1.c b/gcc/testsuite/gcc.dg/pr80776-1.c
index af41c0c2ffa..f3a120b6744 100644
--- a/gcc/testsuite/gcc.dg/pr80776-1.c
+++ b/gcc/testsuite/gcc.dg/pr80776-1.c
@@ -17,7 +17,5 @@ Foo (void)
     __builtin_unreachable ();
   if (! (0 <= i && i <= 999999))
     __builtin_unreachable ();
-  /* The correctness bits for [E]VRP cannot handle chained conditionals
-     when deciding to ignore a unreachable branch for setting SSA range info. */
-  sprintf (number, "%d", i); /* { dg-bogus "writing" "" { xfail *-*-* } } */
+  sprintf (number, "%d", i); /* { dg-bogus "writing" "" } */
 }


                 reply	other threads:[~2021-05-26 19:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210526193152.C6B41384783B@sourceware.org \
    --to=aldyh@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).