From patchwork Thu Apr 4 23:26:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joern Rennecke X-Patchwork-Id: 1077832 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-498870-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="CJENqXg4"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=embecosm.com header.i=@embecosm.com header.b="RT80Qzw+"; dkim-atps=neutral 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 44Zzc8645jz9sPK for ; Fri, 5 Apr 2019 10:26:46 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=WRl8OdlaHs8S/FDyljFIAQIhRJz4W0uJlCRRLSss5uwxML AmqjDvwk3bBc/3b1MjDaufVKNoHzNgATdUIqfGXyzl71p+1/xMR2G4/BPWWslwqe jxl9xAOJHvq+WzukG42Oh7M4Myo9yxpDuDqYwA+C9FnzCx6Ht6rMhywA1h3Hs= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=C5ADAiXD5FuDHKi2WCa+yfvT0KM=; b=CJENqXg4xg1/PO0+30b7 f3+KjMz1gPxewWwFUtN7DSgMoUV55LNXThaBd4f4votOPt0UV5iQOntiU7iQn34K o5qtY9uVuE2CSFX//Uw939P/eUYy0rmtXG6BHt+Na4KOly+B2o/mQtAAPh5M0si6 PA/xbsuuiEX5LJXYaP4qxvU= Received: (qmail 18637 invoked by alias); 4 Apr 2019 23:26:39 -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 18629 invoked by uid 89); 4 Apr 2019 23:26:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-ot1-f44.google.com Received: from mail-ot1-f44.google.com (HELO mail-ot1-f44.google.com) (209.85.210.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 Apr 2019 23:26:37 +0000 Received: by mail-ot1-f44.google.com with SMTP id e5so3957215otk.12 for ; Thu, 04 Apr 2019 16:26:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=mime-version:from:date:message-id:subject:to; bh=v9b739IJZAhJqowG4ZjW/e10FG/FaNXln64Htt954tg=; b=RT80Qzw+smHI1TqI0GtMmHe8m44Fcw/PN1rMfLUNSeFamleKrUXGfpYkPTh7hyC53J FtPo0PKGKwHPhKbQpf5ak6QZLk3tmBycn4CR3ZmF2z6jswt09I+P/u4aHf9c/oVc6KSm 4Jfm8Fesvn8sKLcgpGUrPqYsWVHvyWBrxdO5iKfUwVg8tl3aEzAzDWtTVU6vGwz9bVpX Q00/gnrAwUcWHHdiDaEAi+29tqwaGCeaihYNLlq9QO/cVjiiTyZFqyZwRKuWmV4Qh9sD HG2Z5kC6AnNIMUglEOXLE8KIR9ytHQWdeOSou2NIm53F5vI3f41fL5K3p1Ba4ha6J1i3 pDmQ== MIME-Version: 1.0 From: Joern Rennecke Date: Thu, 4 Apr 2019 23:26:24 +0000 Message-ID: Subject: RFA: Fix uninitialized memory use in sched_macro_fuse_insns To: GCC Patches sched_macro_fuse_insns uses the value in condreg1 without checking the return value of targetm.fixed_condition_code_regs. As this variables is not initialized anywhere, this leads to constructing cc_reg_1 with an undefined value, and then using that in reg_referenced_p, if TARGET_FIXED_CONDITION_CODE_REGS has the default value as defined in target.def (hook_bool_uintp_uintp_false). The attached patch fixes this by checking the return value of targetm.fixed_condition_code_regs. Bootstrapped & regtested on x86_64-pc-linux-gnu . 2019-04-04 Joern Rennecke * sched-deps.c (sched_macro_fuse_insns): Check return value of targetm.fixed_condition_code_regs. Index: sched-deps.c =================================================================== --- sched-deps.c (revision 270146) +++ sched-deps.c (working copy) @@ -2857,14 +2857,16 @@ sched_macro_fuse_insns (rtx_insn *insn) { unsigned int condreg1, condreg2; rtx cc_reg_1; - targetm.fixed_condition_code_regs (&condreg1, &condreg2); - cc_reg_1 = gen_rtx_REG (CCmode, condreg1); - if (reg_referenced_p (cc_reg_1, PATTERN (insn)) - && modified_in_p (cc_reg_1, prev)) + if (targetm.fixed_condition_code_regs (&condreg1, &condreg2)) { - if (targetm.sched.macro_fusion_pair_p (prev, insn)) - SCHED_GROUP_P (insn) = 1; - return; + cc_reg_1 = gen_rtx_REG (CCmode, condreg1); + if (reg_referenced_p (cc_reg_1, PATTERN (insn)) + && modified_in_p (cc_reg_1, prev)) + { + if (targetm.sched.macro_fusion_pair_p (prev, insn)) + SCHED_GROUP_P (insn) = 1; + return; + } } }