From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id BB54B38618EE; Sun, 15 Nov 2020 18:07:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BB54B38618EE Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=none smtp.mailfrom=hubicka@kam.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 2FEC528390D; Sun, 15 Nov 2020 19:07:10 +0100 (CET) Date: Sun, 15 Nov 2020 19:07:10 +0100 From: Jan Hubicka To: Andreas Schwab Cc: gcc@gcc.gnu.org, Richard Biener , gcc-patches@gcc.gnu.org Subject: Re: Detect EAF flags in ipa-modref Message-ID: <20201115180710.GA86620@kam.mff.cuni.cz> References: <20201110125418.GB53229@kam.mff.cuni.cz> <20201110143143.GA91644@kam.mff.cuni.cz> <87361ahph7.fsf@linux-m68k.org> <20201115111254.GB45304@kam.mff.cuni.cz> <20201115123307.GC45304@kam.mff.cuni.cz> <20201115130351.GD45304@kam.mff.cuni.cz> <87k0umvbo2.fsf@igel.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87k0umvbo2.fsf@igel.home> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-15.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 18:07:15 -0000 > See PR97840. Thanks, this is a false positive where we fail to discover that pointed-to type is empty on non-x86_64 targets. This is triggered by better alias analysis caused by non-escape discovery. While this is not a full fix (I hope someone with more experience on C++ types and warnings will set up) I think it may be useful to avoid warning on unused parameter. Bootstrapped/regtested x86_64-linux, OK? PR middle-end/97840 * tree-ssa-uninit.c (maybe_warn_pass_by_reference): Update prototype; silence warning on EAF_UNUSED parameters. (warn_uninitialized_vars): Update. diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c index f23514395e0..1e074793b02 100644 --- a/gcc/tree-ssa-uninit.c +++ b/gcc/tree-ssa-uninit.c @@ -443,7 +443,7 @@ maybe_warn_operand (ao_ref &ref, gimple *stmt, tree lhs, tree rhs, access implying read access to those objects. */ static void -maybe_warn_pass_by_reference (gimple *stmt, wlimits &wlims) +maybe_warn_pass_by_reference (gcall *stmt, wlimits &wlims) { if (!wlims.wmaybe_uninit) return; @@ -501,6 +501,10 @@ maybe_warn_pass_by_reference (gimple *stmt, wlimits &wlims) && !TYPE_READONLY (TREE_TYPE (argtype))) continue; + /* Ignore args we are not going to read from. */ + if (gimple_call_arg_flags (stmt, argno - 1) & EAF_UNUSED) + continue; + if (save_always_executed && access->mode == access_read_only) /* Attribute read_only arguments imply read access. */ wlims.always_executed = true; @@ -639,8 +643,8 @@ warn_uninitialized_vars (bool wmaybe_uninit) if (gimple_vdef (stmt)) wlims.vdef_cnt++; - if (is_gimple_call (stmt)) - maybe_warn_pass_by_reference (stmt, wlims); + if (gcall *call = dyn_cast (stmt)) + maybe_warn_pass_by_reference (call, wlims); else if (gimple_assign_load_p (stmt) && gimple_has_location (stmt)) {