From patchwork Tue Mar 29 21:54:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 1610875 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=FTauvdXL; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KSjzb5pc3z9s0w for ; Wed, 30 Mar 2022 08:55:22 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BA56E3858405 for ; Tue, 29 Mar 2022 21:55:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA56E3858405 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1648590918; bh=4esUXbUc2sJMtK12F7fkX0IG56stgYZlEDNJ356btT0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=FTauvdXLFBmUU/a07kavw73zjKDe5TVuIi6Gn7oBv8OBTANyR+cpUG028TuAbtAoT PWFE8WH/zm7zFy5hl45I5reQOkdnAjcPySHuK1a+SLxOb1BRf9cDR6tbHdfH+noJyj TFi2MLXWZH1mUST0lMrSJezfiyi5/nKKJVG9CMEM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id A6DF73858C50 for ; Tue, 29 Mar 2022 21:54:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A6DF73858C50 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-212-skgSbVxkNuCISAJuwTShLg-1; Tue, 29 Mar 2022 17:54:31 -0400 X-MC-Unique: skgSbVxkNuCISAJuwTShLg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0EE0285A5BE for ; Tue, 29 Mar 2022 21:54:31 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.2.17.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id E1AC31121314; Tue, 29 Mar 2022 21:54:30 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [committed] analyzer: skip constant pool in -fdump-analyzer-untracked [PR testsuite/105085] Date: Tue, 29 Mar 2022 17:54:27 -0400 Message-Id: <20220329215427.17571-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: David Malcolm via Gcc-patches From: David Malcolm Reply-To: David Malcolm Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "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 --- 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" } */ +}