From patchwork Sat Aug 22 15:26:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 1349694 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: 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=rAO6gmub; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 ozlabs.org (Postfix) with ESMTPS id 4BYj0w3X1bz9sPC for ; Sun, 23 Aug 2020 01:26:54 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ECDB53851C09; Sat, 22 Aug 2020 15:26:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ECDB53851C09 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1598110009; bh=o6+3vSERP06SFzJRTmzFr3b7Y1jK9IJXkU+kulB3Q68=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=rAO6gmub5/4SxZPhOlSsPzpMOhtQr7VZd8XbaJ5JAcH+QP8vsTtf/PPMPAPeSRIwf nQ3TyZPQDtP5TVU/S6uEuhNlF+7UBE+7YfcjIQqdSt1ZSP5zjxjQS6HZ9QyEAv+dr8 o3g+HWHovKrCuzrerkPL/3wAaz+AGYUPFKQ+nRgE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by sourceware.org (Postfix) with ESMTP id 7D8403851C09 for ; Sat, 22 Aug 2020 15:26:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7D8403851C09 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-217-QU4LGiuCOjafbfwcll_FJg-1; Sat, 22 Aug 2020 11:26:42 -0400 X-MC-Unique: QU4LGiuCOjafbfwcll_FJg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB11510055B3 for ; Sat, 22 Aug 2020 15:26:41 +0000 (UTC) Received: from t470.redhat.com (ovpn-113-239.phx2.redhat.com [10.3.113.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80BE66E715; Sat, 22 Aug 2020 15:26:41 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [committed] analyzer: simplify region_model::push_frame Date: Sat, 22 Aug 2020 11:26:39 -0400 Message-Id: <20200822152639.4835-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.2 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_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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@gcc.gnu.org Sender: "Gcc-patches" region_model::push_frame was binding arguments for both the default SSA name for each parameter, and the underlying parameter. Simplify the generated states by only binding the default SSA name if it exists, or the parameter if there is no default SSA name. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to master as 294b6da21bbd8297fe6aee497ac6c8e561637e70. gcc/analyzer/ChangeLog: * region-model.cc (region_model::push_frame): Bind the default SSA name for each parm if it exists, falling back to the parm itself otherwise, rather than doing both. gcc/testsuite/ChangeLog: * gcc.dg/analyzer/malloc-ipa-8-double-free.c: Drop -fanalyzer-verbose-state-changes. --- gcc/analyzer/region-model.cc | 19 +++++++------------ .../analyzer/malloc-ipa-8-double-free.c | 10 +++++----- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index b8a0f9ffd3d..02bbfa54781 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -2353,17 +2353,12 @@ region_model::push_frame (function *fun, const vec *arg_svals, rest of the params as uninitialized. */ if (idx >= arg_svals->length ()) break; + tree parm_lval = iter_parm; + if (tree parm_default_ssa = ssa_default_def (fun, iter_parm)) + parm_lval = parm_default_ssa; + const region *parm_reg = get_lvalue (parm_lval, ctxt); const svalue *arg_sval = (*arg_svals)[idx]; - const region *parm_reg = get_lvalue (iter_parm, ctxt); set_value (parm_reg, arg_sval, ctxt); - - /* Also do it for default SSA name (sharing the same value). */ - tree parm_default_ssa = ssa_default_def (fun, iter_parm); - if (parm_default_ssa) - { - const region *defssa_reg = get_lvalue (parm_default_ssa, ctxt); - set_value (defssa_reg, arg_sval, ctxt); - } } } else @@ -2375,10 +2370,10 @@ region_model::push_frame (function *fun, const vec *arg_svals, for (tree iter_parm = DECL_ARGUMENTS (fndecl); iter_parm; iter_parm = DECL_CHAIN (iter_parm)) { - on_top_level_param (iter_parm, ctxt); - tree parm_default_ssa = ssa_default_def (fun, iter_parm); - if (parm_default_ssa) + if (tree parm_default_ssa = ssa_default_def (fun, iter_parm)) on_top_level_param (parm_default_ssa, ctxt); + else + on_top_level_param (iter_parm, ctxt); } } diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-8-double-free.c b/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-8-double-free.c index cdf5ac18324..580862b0138 100644 --- a/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-8-double-free.c +++ b/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-8-double-free.c @@ -1,6 +1,6 @@ /* Example of a multilevel wrapper around malloc/free, with a double-'free'. */ -/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fanalyzer-checker=malloc -fanalyzer-verbose-state-changes -fdiagnostics-show-caret" } */ +/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fanalyzer-checker=malloc -fdiagnostics-show-caret" } */ /* { dg-enable-nn-line-numbers "" } */ #include @@ -83,7 +83,7 @@ void test (int i) | NN | return malloc (size); | | ~~~~~~~~~~~~~ | | | - | | (6) allocated here (state of '': 'start' -> 'unchecked', NULL origin) + | | (6) allocated here | <------+ | @@ -96,7 +96,7 @@ void test (int i) | NN | if (!result) | | ~ | | | - | | (8) assuming 'result' is non-NULL (state of 'result': 'unchecked' -> 'nonnull', NULL origin) + | | (8) assuming 'result' is non-NULL | | (9) following 'false' branch (when 'result' is non-NULL)... | NN | abort (); | NN | result->i = i; @@ -140,7 +140,7 @@ void test (int i) | NN | free (ptr); | | ~~~~~~~~~~ | | | - | | (16) first 'free' here (state of 'ptr': 'nonnull' -> 'freed', NULL origin) + | | (16) first 'free' here | <------+ | @@ -187,7 +187,7 @@ void test (int i) | NN | free (ptr); | | ~~~~~~~~~~ | | | - | | (23) second 'free' here; first 'free' was at (16) ('ptr' is in state 'freed') + | | (23) second 'free' here; first 'free' was at (16) | { dg-end-multiline-output "" } */