From patchwork Mon May 23 16:28:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 625309 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rD3rz4FCPz9sXR for ; Tue, 24 May 2016 02:29:05 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=teKZHCUa; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=LkKx1JW+y3CSobXi4vyZnFJ0QFSZT81Cc6bvGXEXTbUJDacAth IhBf/jHm1XXvO8L6jAvQ8iZUj6eTZI5OwAByQ8i7OjoZaff/XAg90Dxgf1u6XELV F2FM9Ku0wHG71HvVQzvVqMgYvPaNUojaiZYXokwwBKiNjJGZR9AnqTDVg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=HR4mZRNDv2GNA1odnSmvpiWOaIM=; b=teKZHCUa1D0XyvNoIajx +RKUrqXK7SzXXlQfCm2tsawQTmdzxr8ob+gcCGK8x/UK8yTOLcix28KNKWh5OAax 2ioCXCopVJKCkVp9WtGfPatVr4Cygj12OFDxEF3iha3qNfUEwJeiTlGx1FP0QiPE /H6lcYFMtQQeoWh1w+63qjw= Received: (qmail 19375 invoked by alias); 23 May 2016 16:28:58 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 19361 invoked by uid 89); 23 May 2016 16:28:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1402 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Mon, 23 May 2016 16:28:38 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7A618AABC for ; Mon, 23 May 2016 16:28:35 +0000 (UTC) Date: Mon, 23 May 2016 18:28:35 +0200 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka Subject: [PR 71234] Avoid valgrind warning in ipa-cp Message-ID: <20160523162835.GD2962@virgil.suse.cz> Mail-Followup-To: GCC Patches , Jan Hubicka MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.6.0 (2016-04-01) X-IsSubscribed: yes Hi, ipa_find_agg_cst_for_param can leave from_global_constant as it is when it returns NULL. It's user ipa_get_indirect_edge_target_1 then reads that uninitialized value when it tests whether it should NULLify the result itself, which was caught by valgrind. Fixed by the patch below, which checks whether ipa_find_agg_cst_for_param returned non-NULL before loading from_global_constant. I decided to address it here rather than in ipa_find_agg_cst_for_param because that would require a check that from_global_constant in not NULL there and because it is consistent with how by_ref is returned in other functions in ipa-prop. Bootstrapped and tested on x86_64-linux, I will go ahead and commit it as obvious. Martin 2016-05-23 Martin Jambor PR ipa/71234 * ipa-cp.c (ipa_get_indirect_edge_target_1): Only check value of from_global_constant if t is not NULL. --- gcc/ipa-cp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 8caa973..4b7f6bb 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -2027,7 +2027,8 @@ ipa_get_indirect_edge_target_1 (struct cgraph_edge *ie, ie->indirect_info->offset, ie->indirect_info->by_ref, &from_global_constant); - if (!from_global_constant + if (t + && !from_global_constant && !ie->indirect_info->guaranteed_unmodified) t = NULL_TREE; }