From patchwork Wed Oct 7 05:53:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 1377780 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=suse.de 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 4C5k6X6p5pz9sSG for ; Wed, 7 Oct 2020 16:53:54 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EFFC0385780A; Wed, 7 Oct 2020 05:53:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id E107C3857C40 for ; Wed, 7 Oct 2020 05:53:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E107C3857C40 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 89048B21C for ; Wed, 7 Oct 2020 05:53:46 +0000 (UTC) Date: Wed, 7 Oct 2020 07:53:44 +0200 From: Tom de Vries To: gcc-patches@gcc.gnu.org Subject: [PATCH][tree-ssa-loop-ch] Add missing NULL test for dump_file Message-ID: <20201007055343.GA28730@delia> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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: , Cc: Richard Biener Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi, If we change gimple_can_duplicate_bb_p to return false instead of true, we run into a segfault in ch_base::copy_headers due to using dump_file while it's NULL: ... if (!gimple_duplicate_sese_region (entry, exit, bbs, n_bbs, copied_bbs, true)) { fprintf (dump_file, "Duplication failed.\n"); continue; } ... Fix this by adding the missing dump_file != NULL test. Tested by rebuilding lto1 and rerunning the failing test-case. [ Not committing this as obvious because I'm not sure about the (dump_flags & TDF_DETAILS) bit. ] OK for trunk? Thanks, - Tom [tree-ssa-loop-ch] Add missing NULL test for dump_file gcc/ChangeLog: 2020-10-07 Tom de Vries * tree-ssa-loop-ch.c (ch_base::copy_headers): Add missing NULL test for dump_file. --- gcc/tree-ssa-loop-ch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/tree-ssa-loop-ch.c b/gcc/tree-ssa-loop-ch.c index b86acf7c39d..1f3d9321a55 100644 --- a/gcc/tree-ssa-loop-ch.c +++ b/gcc/tree-ssa-loop-ch.c @@ -425,7 +425,8 @@ ch_base::copy_headers (function *fun) if (!gimple_duplicate_sese_region (entry, exit, bbs, n_bbs, copied_bbs, true)) { - fprintf (dump_file, "Duplication failed.\n"); + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, "Duplication failed.\n"); continue; } copied.safe_push (std::make_pair (entry, loop));