From patchwork Fri Dec 20 15:11:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 1214187 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=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-516373-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="dlHrFvSC"; 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 47fXJs4v51z9sP6 for ; Sat, 21 Dec 2019 02:11:41 +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:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=AQP2LP0EF3yyewWqemEWZCatgNBMJUKaC0CbEXye4vOsSVqMYC weUAOZntlgr/sxohn1BJGfWLyey/vhNufko+F1FUPUFl/da8RVpegX02FuunYD20 9uGRW/Nw3a8HtbKTuBcfftntxW3ISedeVI7slsAoYel91BHI70Q57xqOc= 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:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=fh5RjOzgFI+x4dbY+gCIMBDeZCo=; b=dlHrFvSCdBj4UiiFXkfk VqQc9FWqpEfz3L0OQQnqoOUY6qnEddFQhzhYPA7rP4PzczjKIEmRwwfbQbJFwE/X Q/FjwF1nLSbRTkS/Zq/q39aTeRgM3/MKLuTZvYQlGq/oD9Yszh6YnJXKY8npEnYa zPbsKUd1fnGTegp5wDTTw+o= Received: (qmail 74983 invoked by alias); 20 Dec 2019 15:11:33 -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 74975 invoked by uid 89); 20 Dec 2019 15:11:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1632, mjamborsusecz, U*mjambor, mjambor@suse.cz 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 ESMTP; Fri, 20 Dec 2019 15:11:32 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7608FAF41; Fri, 20 Dec 2019 15:11:30 +0000 (UTC) From: Martin Jambor To: GCC Patches Cc: Jan Hubicka , Jan Hubicka Subject: [PATCH] Avoid segfault when doing IPA-VRP but not IPA-CP (PR 93015) User-Agent: Notmuch/0.29.2 (https://notmuchmail.org) Emacs/26.3 (x86_64-suse-linux-gnu) Date: Fri, 20 Dec 2019 16:11:29 +0100 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi, PR 93015 testcase - an empty main function compiled with -O0 -fipa-vrp -flto - shows that IPA-VRA can segfault when trying to access results of an analysis that has not been performed because of zero optimization level, -fno-ipa-cp etc. Rather than adding another chain of opt_for_fn() the patch fixes it by what IPA-CP-BITS does, which is simply checking that info of a node is not NULL. Bootstrapped and tested on x86_64-linux. OK for trunk? Thanks, Martin 2019-12-20 Martin Jambor PR ipa/93015 * ipa-cp.c (ipcp_store_vr_results): Check that info exists testsuite/ * gcc.dg/lto/pr93015_0.c: New test. --- gcc/ipa-cp.c | 2 +- gcc/testsuite/gcc.dg/lto/pr93015_0.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/lto/pr93015_0.c diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 243b064ee2c..329e259ede3 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -5661,7 +5661,7 @@ ipcp_store_vr_results (void) ipa_node_params *info = IPA_NODE_REF (node); bool found_useful_result = false; - if (!opt_for_fn (node->decl, flag_ipa_vrp)) + if (!info || !opt_for_fn (node->decl, flag_ipa_vrp)) { if (dump_file) fprintf (dump_file, "Not considering %s for VR discovery " diff --git a/gcc/testsuite/gcc.dg/lto/pr93015_0.c b/gcc/testsuite/gcc.dg/lto/pr93015_0.c new file mode 100644 index 00000000000..d084b5ad1e2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr93015_0.c @@ -0,0 +1,6 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options { { -O0 -fipa-vrp -flto } } } */ + +int main() { + +}