From patchwork Thu Nov 5 14:27:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1395035 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=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz 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 ozlabs.org (Postfix) with ESMTPS id 4CRm7l6kgQz9sRR for ; Fri, 6 Nov 2020 01:27:28 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C7494384A02F; Thu, 5 Nov 2020 14:27:25 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 55ACA3858C27 for ; Thu, 5 Nov 2020 14:27:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 55ACA3858C27 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 D166F282592; Thu, 5 Nov 2020 15:27:17 +0100 (CET) Date: Thu, 5 Nov 2020 15:27:17 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix uninitialized memory use in ipa-modref Message-ID: <20201105142717.GA84582@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-15.6 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-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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi, this patch fixes two uninitialized memory uses in ipa-modref. First is harmless because the values are never used, but they will make valgrind unhapy. Second is an actual bug: while breaking the patch in half I forgot to initialize errno at stream in time. Bootstrapped/regtested x86_64-linux, comitted. * ipa-modref.c (parm_map_for_arg): Initialize parm_offset and parm_offset_knonw. (read_section): Set writes_errno to false. diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c index b40f3da3ba2..9df3d2bcf2d 100644 --- a/gcc/ipa-modref.c +++ b/gcc/ipa-modref.c @@ -525,6 +525,9 @@ parm_map_for_arg (gimple *stmt, int i) poly_int64 offset; struct modref_parm_map parm_map; + parm_map.parm_offset_known = false; + parm_map.parm_offset = 0; + offset_known = unadjusted_ptr_and_unit_offset (op, &op, &offset); if (TREE_CODE (op) == SSA_NAME && SSA_NAME_IS_DEFAULT_DEF (op) @@ -1533,10 +1536,12 @@ read_section (struct lto_file_decl_data *file_data, const char *data, modref_summary_lto *modref_sum_lto = summaries_lto ? summaries_lto->get_create (node) : NULL; - if (optimization_summaries) modref_sum = optimization_summaries->get_create (node); + if (modref_sum) + modref_sum->writes_errno = false; + gcc_assert (!modref_sum || (!modref_sum->loads && !modref_sum->stores)); gcc_assert (!modref_sum_lto || (!modref_sum_lto->loads