From patchwork Fri Jul 6 13:30:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 940503 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-481126-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ITT2v5rQ"; 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 41MbGB1VCnz9s4c for ; Fri, 6 Jul 2018 23:30:57 +1000 (AEST) 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:subject:message-id:mime-version:content-type; q=dns; s= default; b=ZFDEzjahcbQIkIerZr1/1ivUiiZOcB0myjwclCl73A9z+Us52vuwE 5DIyEzDVx9+oNEpUdG4YaQ6mrfFZ90ZTqURwXK3aii64yGr48iNreiwZ4g99FeiX fKAToJJ8BXVcSIKpXJLHiXi8MlKGuG4wfR652fnBV0Aa/t0WlSwTMs= 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:subject:message-id:mime-version:content-type; s= default; bh=9mHr8cgdRJQ6Mdlkzt33gMcvgdo=; b=ITT2v5rQ6TkWMgbub6L7 3+sbqClqrYlVMBsbpVDxm3Dn4+5Y+MOwdlivk7m4fmg1xLmOpTbOtTjSQeV00v+w zTlUzsYqSSuaYG+TCcZWVBQLBiz6cb7JQ161pjNenlZkgXaFhGH3+SgXi1VNnck9 qzy16EaGm1WYniZ/GV55Fto= Received: (qmail 12582 invoked by alias); 6 Jul 2018 13:30:49 -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 12452 invoked by uid 89); 6 Jul 2018 13:30:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Jul 2018 13:30:28 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B23ACAFF7 for ; Fri, 6 Jul 2018 13:30:23 +0000 (UTC) Date: Fri, 6 Jul 2018 15:30:26 +0200 From: Tom de Vries To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix sigsegv on -fdump-tree-all-enumerate_locals Message-ID: <20180706133026.7ue6songbxnx3i3m@delia> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170912 (1.9.0) X-IsSubscribed: yes Hi, this patch fixes a sigsegv when using -fdump-tree-all-enumerate_locals, by handling cfun->cfg == NULL conservatively in dump_enumerated_decls. OK for trunk? Thanks, - Tom Fix sigsegv on -fdump-tree-all-enumerate_locals 2018-07-06 Tom de Vries * tree-dfa.c (dump_enumerated_decls): Handle cfun->cfg == NULL. * gcc.misc-tests/options.exp (check_for_all_options): Clean up dump files. (get_dump_flags): New proc. (toplevel): Test all dump flags. --- gcc/testsuite/gcc.misc-tests/options.exp | 38 ++++++++++++++++++++++++++++++++ gcc/tree-dfa.c | 3 +++ 2 files changed, 41 insertions(+) diff --git a/gcc/testsuite/gcc.misc-tests/options.exp b/gcc/testsuite/gcc.misc-tests/options.exp index 693b40df1fd..faeae705c08 100644 --- a/gcc/testsuite/gcc.misc-tests/options.exp +++ b/gcc/testsuite/gcc.misc-tests/options.exp @@ -52,6 +52,10 @@ proc check_for_all_options {language gcc_options compiler_pattern as_pattern ld_ } set gcc_output [gcc_target_compile $filename.c $filename.x executable $gcc_options] remote_file build delete $filename.c $filename.x $filename.gcno + set dumpfiles [glob -nocomplain $filename.c.*] + foreach dumpfile $dumpfiles { + remote_file build delete $dumpfile + } if {![regexp -- "/${compiler}(\\.exe)? -quiet.*$compiler_pattern" $gcc_output]} { fail "$test (compiler options)" @@ -70,4 +74,38 @@ proc check_for_all_options {language gcc_options compiler_pattern as_pattern ld_ check_for_all_options c {--coverage} {-fprofile-arcs -ftest-coverage} {} {-lgcov} +proc get_dump_flags {} { + set res [list] + + global srcdir + set file "$srcdir/../dumpfile.c" + + set a [open $file] + set lines [split [read $a] "\n"] + close $a + + set domatch 0 + foreach line $lines { + if { [regexp "dump_options.* =" $line] } { + set domatch 1 + } elseif { [regexp "^\};" $line] } { + set domatch 0 + } + if { $domatch } { + if { [regexp "\"(.*)\"" $line match submatch] } { + lappend res $submatch + } + } + } + + return $res +} + +foreach flag [get_dump_flags] { + check_for_all_options c -fdump-tree-all-$flag {} {} {} + check_for_all_options c -fdump-ipa-all-$flag {} {} {} + check_for_all_options c -fdump-rtl-all-$flag {} {} {} + check_for_all_options c -fdump-lang-all-$flag {} {} {} +} + gcc_parallel_test_enable 1 diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c index 00aa75f47ab..ee2ff2958db 100644 --- a/gcc/tree-dfa.c +++ b/gcc/tree-dfa.c @@ -992,6 +992,9 @@ dump_enumerated_decls_push (tree *tp, int *walk_subtrees, void *data) void dump_enumerated_decls (FILE *file, dump_flags_t flags) { + if (!cfun->cfg) + return; + basic_block bb; struct walk_stmt_info wi; auto_vec decl_list;