public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] analyzer: skip constant pool in -fdump-analyzer-untracked [PR testsuite/105085]
@ 2022-03-29 21:54 David Malcolm
  0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2022-03-29 21:54 UTC (permalink / raw)
  To: gcc-patches

In r12-7809-g5f6197d7c197f9 I added -fdump-analyzer-untracked as support
for DejaGnu testing of an optimization of -fanalyzer,
PR analyzer/104954.

PR testsuite/105085 notes testsuite failures of the form:
  FAIL: gcc.dg/analyzer/untracked-1.c (test for excess errors)
  Excess errors:
  cc1: warning: track '*.LC1': yes
where these warnings are emitted on some targets where the test
causes labelled constants to be created in the constant pool.

We probably ought not to be tracking the values of such decls in the
store, given that they're meant to be constant, and I attempted various
fixes to make the "should we track this decl" logic smarter, but given
that we're in stage 4, the simplest fix seems to be for
-fdump-analyzer-untracked to skip such decls in its output, to minimize
test output differences between targets.

Manually tested the affected cases with --target=powerpc64le-linux-gnu.
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to trunk as r12-7905-gc788a0eae0a7144e6f148162512fa2e93a45a035.

gcc/analyzer/ChangeLog:
	PR testsuite/105085
	* region-model-manager.cc (dump_untracked_region): Skip decls in
	the constant pool.

gcc/testsuite/ChangeLog:
	PR testsuite/105085
	* gcc.dg/analyzer/untracked-1.c: Add further test coverage.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
---
 gcc/analyzer/region-model-manager.cc        |  7 ++++++
 gcc/testsuite/gcc.dg/analyzer/untracked-1.c | 26 +++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/gcc/analyzer/region-model-manager.cc b/gcc/analyzer/region-model-manager.cc
index 5ca333a9ed6..56d60768749 100644
--- a/gcc/analyzer/region-model-manager.cc
+++ b/gcc/analyzer/region-model-manager.cc
@@ -1770,6 +1770,13 @@ dump_untracked_region (const decl_region *decl_reg)
   tree decl = decl_reg->get_decl ();
   if (TREE_CODE (decl) != VAR_DECL)
     return;
+  /* For now, don't emit the status of decls in the constant pool, to avoid
+     differences in DejaGnu test results between targets that use these vs
+     those that don't.
+     (Eventually these decls should probably be untracked and we should test
+     for that, but that's not stage 4 material).  */
+  if (DECL_IN_CONSTANT_POOL (decl))
+    return;
   warning_at (DECL_SOURCE_LOCATION (decl), 0,
 	      "track %qD: %s",
 	      decl, (decl_reg->tracked_p () ? "yes" : "no"));
diff --git a/gcc/testsuite/gcc.dg/analyzer/untracked-1.c b/gcc/testsuite/gcc.dg/analyzer/untracked-1.c
index d07c2975670..9f3a639db5c 100644
--- a/gcc/testsuite/gcc.dg/analyzer/untracked-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/untracked-1.c
@@ -1,5 +1,7 @@
 /* { dg-additional-options "-fdump-analyzer-untracked" } */
 
+#include "analyzer-decls.h"
+
 struct st
 {
   const char *m_filename;
@@ -39,6 +41,16 @@ void test_3 (void)
   extern_fn (&s3);
 }
 
+void test_3a (void)
+{
+  struct st s3a = { "foo.c", 42 }; /* { dg-warning "track 's3a': yes" } */
+  __analyzer_eval (s3a.m_filename[0] == 'f'); /* { dg-warning "TRUE" } */
+  __analyzer_eval (s3a.m_line == 42); /* { dg-warning "TRUE" } */
+  extern_fn (&s3a);
+  __analyzer_eval (s3a.m_filename[0] == 'f'); /* { dg-warning "UNKNOWN" } */
+  __analyzer_eval (s3a.m_line == 42); /* { dg-warning "UNKNOWN" } */
+}
+
 extern void called_by_test_4 (int *);
 
 int test_4 (void)
@@ -103,3 +115,17 @@ void test_13 (void)
 {
   extern_fn_char_ptr (__func__); /* { dg-warning "track '__func__': no" } */
 }
+
+char t14_global_unused[100]; /* { dg-warning "track 't14_global_unused': yes" } */
+static char t14_static_unused[100]; /* { dg-warning "track 't14_static_unused': yes" } */
+char t14_global_used[100]; /* { dg-warning "track 't14_global_used': yes" } */
+static char t14_static_used[100]; /* { dg-warning "track 't14_static_used': yes" } */
+void test_14 (void)
+{
+  extern_fn_char_ptr (t14_global_unused);
+  extern_fn_char_ptr (t14_static_unused);
+  extern_fn_char_ptr (t14_global_used);
+  __analyzer_eval (t14_global_used[0] == '\0'); /* { dg-warning "UNKNOWN" } */
+  extern_fn_char_ptr (t14_static_used);
+  __analyzer_eval (t14_static_used[0] == '\0'); /* { dg-warning "UNKNOWN" } */
+}
-- 
2.26.3


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-29 21:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-29 21:54 [committed] analyzer: skip constant pool in -fdump-analyzer-untracked [PR testsuite/105085] David Malcolm

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