public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][committed][PR tree-optimization/82123] 02/06 Perform EVRP analysis in sprintf warning pass
@ 2018-02-20 18:52 Jeff Law
  2018-03-16 12:35 ` [testsuite] Require label_values in builtin-unreachable-6.c Tom de Vries
  0 siblings, 1 reply; 2+ messages in thread
From: Jeff Law @ 2018-02-20 18:52 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 554 bytes --]

This is the second patch in the series to fix 82123/81592.  It generates
range information within the sprintf warning pass using the EVRP
analyzer.  We don't use the range information in this patch.

This twiddles one test -- adding the calls into the analyzer from the
sprintf pass causes us to record a range for an object that didn't have
one before and compromises the test.  I just turn off VRP  which is
sufficient to obscure things so that we don't remove the
__builtin_unreachable.


Bootstrapped and regression tested on x86_64-linux-gnu.

Jeff

[-- Attachment #2: P2 --]
[-- Type: text/plain, Size: 3039 bytes --]

	* gimple-ssa-sprintf.c: Include alloc-pool.h, vr-values.h and 
	gimple-ssa-evrp-analyze.h
	(class sprintf_dom_walker): Add after_dom_children member function.
	Add evrp_range_analyzer member.
	(sprintf_dom_walker::before_dom_children): Call into the EVRP
	range analyzer as needed.
	(sprintf_dom_walker::after_dom_children): New member function.

	* gcc.dg/builtin-unreachable-6.c: Turn off VRP.

diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
index a2dd545..545f833 100644
--- a/gcc/gimple-ssa-sprintf.c
+++ b/gcc/gimple-ssa-sprintf.c
@@ -80,6 +80,9 @@ along with GCC; see the file COPYING3.  If not see
 #include "substring-locations.h"
 #include "diagnostic.h"
 #include "domwalk.h"
+#include "alloc-pool.h"
+#include "vr-values.h"
+#include "gimple-ssa-evrp-analyze.h"
 
 /* The likely worst case value of MB_LEN_MAX for the target, large enough
    for UTF-8.  Ideally, this would be obtained by a target hook if it were
@@ -121,10 +124,12 @@ class sprintf_dom_walker : public dom_walker
   ~sprintf_dom_walker () {}
 
   edge before_dom_children (basic_block) FINAL OVERRIDE;
+  void after_dom_children (basic_block) FINAL OVERRIDE;
   bool handle_gimple_call (gimple_stmt_iterator *);
 
   struct call_info;
   bool compute_format_length (call_info &, format_result *);
+  class evrp_range_analyzer evrp_range_analyzer;
 };
 
 class pass_sprintf_length : public gimple_opt_pass
@@ -3456,7 +3461,7 @@ parse_directive (sprintf_dom_walker::call_info &info,
 
 bool
 sprintf_dom_walker::compute_format_length (call_info &info,
-					    format_result *res)
+					   format_result *res)
 {
   if (dump_file)
     {
@@ -4012,11 +4017,15 @@ sprintf_dom_walker::handle_gimple_call (gimple_stmt_iterator *gsi)
 edge
 sprintf_dom_walker::before_dom_children (basic_block bb)
 {
+  evrp_range_analyzer.enter (bb);
   for (gimple_stmt_iterator si = gsi_start_bb (bb); !gsi_end_p (si); )
     {
       /* Iterate over statements, looking for function calls.  */
       gimple *stmt = gsi_stmt (si);
 
+      /* First record ranges generated by this statement.  */
+      evrp_range_analyzer.record_ranges_from_stmt (stmt, false);
+
       if (is_gimple_call (stmt) && handle_gimple_call (&si))
 	/* If handle_gimple_call returns true, the iterator is
 	   already pointing to the next statement.  */
@@ -4027,6 +4036,12 @@ sprintf_dom_walker::before_dom_children (basic_block bb)
   return NULL;
 }
 
+void
+sprintf_dom_walker::after_dom_children (basic_block bb)
+{
+  evrp_range_analyzer.leave (bb);
+}
+
 /* Execute the pass for function FUN.  */
 
 unsigned int
diff --git a/gcc/testsuite/gcc.dg/builtin-unreachable-6.c b/gcc/testsuite/gcc.dg/builtin-unreachable-6.c
index 1915dd1..b0504be 100644
--- a/gcc/testsuite/gcc.dg/builtin-unreachable-6.c
+++ b/gcc/testsuite/gcc.dg/builtin-unreachable-6.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-fab1 -fno-tree-dominator-opts" } */
+/* { dg-options "-O2 -fdump-tree-fab1 -fno-tree-dominator-opts -fno-tree-vrp" } */
 
 void
 foo (int b, int c)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [testsuite] Require label_values in builtin-unreachable-6.c
  2018-02-20 18:52 [PATCH][committed][PR tree-optimization/82123] 02/06 Perform EVRP analysis in sprintf warning pass Jeff Law
@ 2018-03-16 12:35 ` Tom de Vries
  0 siblings, 0 replies; 2+ messages in thread
From: Tom de Vries @ 2018-03-16 12:35 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1113 bytes --]

[ was: Re: [PATCH][committed][PR tree-optimization/82123] 02/06 Perform 
EVRP analysis in sprintf warning pass ]

On 02/20/2018 07:52 PM, Jeff Law wrote:
> This twiddles one test -- adding the calls into the analyzer from the
> sprintf pass causes us to record a range for an object that didn't have
> one before and compromises the test.  I just turn off VRP  which is
> sufficient to obscure things so that we don't remove the
> __builtin_unreachable.
> 

> diff --git a/gcc/testsuite/gcc.dg/builtin-unreachable-6.c b/gcc/testsuite/gcc.dg/builtin-unreachable-6.c
> index 1915dd1..b0504be 100644
> --- a/gcc/testsuite/gcc.dg/builtin-unreachable-6.c
> +++ b/gcc/testsuite/gcc.dg/builtin-unreachable-6.c
> @@ -1,5 +1,5 @@
>   /* { dg-do compile } */
> -/* { dg-options "-O2 -fdump-tree-fab1 -fno-tree-dominator-opts" } */
> +/* { dg-options "-O2 -fdump-tree-fab1 -fno-tree-dominator-opts -fno-tree-vrp" } */
>   
>   void
>   foo (int b, int c)
> 

Preventing vrp triggered "sorry, unimplemented: target cannot support 
label values" on nvptx.

Fixed by requiring the effective target label_values.

Thanks,
- Tom

[-- Attachment #2: 0001-testsuite-Require-label_values-in-builtin-unreachable-6.c.patch --]
[-- Type: text/x-patch, Size: 717 bytes --]

[testsuite] Require label_values in builtin-unreachable-6.c

2018-03-16  Tom de Vries  <tom@codesourcery.com>

	* gcc.dg/builtin-unreachable-6.c: Require effective target label_values.

---
 gcc/testsuite/gcc.dg/builtin-unreachable-6.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/gcc.dg/builtin-unreachable-6.c b/gcc/testsuite/gcc.dg/builtin-unreachable-6.c
index b0504be..4c3b9bb 100644
--- a/gcc/testsuite/gcc.dg/builtin-unreachable-6.c
+++ b/gcc/testsuite/gcc.dg/builtin-unreachable-6.c
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -fdump-tree-fab1 -fno-tree-dominator-opts -fno-tree-vrp" } */
+/* { dg-require-effective-target label_values } */
 
 void
 foo (int b, int c)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-16 11:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-20 18:52 [PATCH][committed][PR tree-optimization/82123] 02/06 Perform EVRP analysis in sprintf warning pass Jeff Law
2018-03-16 12:35 ` [testsuite] Require label_values in builtin-unreachable-6.c Tom de Vries

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).