From patchwork Thu Oct 18 12:58:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 192313 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id C95AC2C0093 for ; Thu, 18 Oct 2012 23:59:04 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1351169945; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=6gnf1L5WVG08sKnCUpfO vbheXPc=; b=h1efvLEUvvV1Ef4WMu6+iQ0RjRHmHBLNTWIcHZe+d2Z3KsTZRYHH Zd7Ta7x3UPdlci1hYt10kOjiB046+feE2MX3knIF26wbDKSmXwRM6ePvfAzJKnLC 8a3zbTB4t8zHQM0HkkeMF+k50cSvUotLAb4+fO7epMxo5HjqcNdcXOo= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To:MIME-Version:Content-Type:Content-Disposition:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=eib4nQg7OpYeTTJ5CQqAaBZZX+A0BdAAsIrd1i94g1PoQ62YYLRBDWFHAXf2fn M3vtuGzNoiPu77+VhiywIT38ZCjLY+9U0gNaJnMnVjH/eziT4o647SNNrKGG2F/R 0Ik2iC+KVvUU9TwzHVGWc1LdReVxBr3KfOup24kfew2QI=; Received: (qmail 17772 invoked by alias); 18 Oct 2012 12:58:53 -0000 Received: (qmail 17738 invoked by uid 22791); 18 Oct 2012 12:58:52 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 18 Oct 2012 12:58:43 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9ICwguF010861 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 18 Oct 2012 08:58:42 -0400 Received: from zalov.redhat.com (vpn1-5-50.ams2.redhat.com [10.36.5.50]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9ICwe9N024615 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 18 Oct 2012 08:58:42 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id q9ICweUm022202; Thu, 18 Oct 2012 14:58:40 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id q9ICwdg7022201; Thu, 18 Oct 2012 14:58:39 +0200 Date: Thu, 18 Oct 2012 14:58:39 +0200 From: Jakub Jelinek To: Diego Novillo , Dodji Seketeli , Xinliang David Li Cc: gcc-patches@gcc.gnu.org Subject: [asan] Fix some asan ICEs Message-ID: <20121018125839.GY584@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 Hi! Dodji reported to me an ICE about NOTE_INSN_BASIC_BLOCK in a middle of a bb. The following patch (cfgexpand.c hunk) fixes that. I then run asan cc1/cc1plus with -O2 -fasan on a portion of cc1files and got other ICEs, which is the reason for the two asan.c changes - one was that base wasn't unshared, so we could hit tree sharing verification failures, and the other issue is that cgraph_build_static_cdtor can call ggc_collect, so holding trees around in automatic variables across it doesn't work very well. I'd have to build too many trees again, so I think easiest is to add a new GTY root. Ok for asan? 2012-10-18 Jakub Jelinek * asan.c (build_check_stmt): Unshare base. * asan.c (asan_ctor_statements): New variable. (asan_finish_file): Use asan_ctor_statements instead of ctor_statements. * cfgexpand.c (gimple_expand_cfg): If return_label is followed by NOTE_INSN_BASIC_BLOCK, emit var_ret_seq after the note instead of before it. Jakub --- gcc/asan.c.jj 2012-10-17 20:43:00.000000000 +0200 +++ gcc/asan.c 2012-10-18 14:20:23.837423900 +0200 @@ -459,6 +459,8 @@ build_check_stmt (tree base, set_immediate_dominator (CDI_DOMINATORS, else_bb, cond_bb); } + base = unshare_expr (base); + gsi = gsi_last_bb (cond_bb); g = gimple_build_assign_with_ops (TREE_CODE (base), make_ssa_name (TREE_TYPE (base), NULL), @@ -748,6 +750,10 @@ asan_add_global (tree decl, tree type, V CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, init); } +/* Needs to be GTY(()), because cgraph_build_static_cdtor may + invoke ggc_collect. */ +static GTY(()) tree asan_ctor_statements; + /* Module-level instrumentation. - Insert __asan_init() into the list of CTORs. - TODO: insert redzones around globals. @@ -756,12 +762,11 @@ asan_add_global (tree decl, tree type, V void asan_finish_file (void) { - tree ctor_statements = NULL_TREE; struct varpool_node *vnode; unsigned HOST_WIDE_INT gcount = 0; append_to_statement_list (build_call_expr (asan_init_func (), 0), - &ctor_statements); + &asan_ctor_statements); FOR_EACH_DEFINED_VARIABLE (vnode) if (asan_protect_global (vnode->symbol.decl)) ++gcount; @@ -799,7 +805,7 @@ asan_finish_file (void) append_to_statement_list (build_call_expr (decl, 2, build_fold_addr_expr (var), build_int_cst (uptr, gcount)), - &ctor_statements); + &asan_ctor_statements); decl = build_fn_decl ("__asan_unregister_globals", type); TREE_NOTHROW (decl) = 1; @@ -810,7 +816,7 @@ asan_finish_file (void) cgraph_build_static_cdtor ('D', dtor_statements, MAX_RESERVED_INIT_PRIORITY - 1); } - cgraph_build_static_cdtor ('I', ctor_statements, + cgraph_build_static_cdtor ('I', asan_ctor_statements, MAX_RESERVED_INIT_PRIORITY - 1); } --- gcc/cfgexpand.c.jj 2012-10-17 20:41:02.000000000 +0200 +++ gcc/cfgexpand.c 2012-10-18 13:01:06.084479343 +0200 @@ -4615,7 +4615,12 @@ gimple_expand_cfg (void) insn_locations_finalize (); if (var_ret_seq) - emit_insn_after (var_ret_seq, return_label); + { + rtx after = return_label; + if (NEXT_INSN (after) && NOTE_INSN_BASIC_BLOCK_P (NEXT_INSN (after))) + after = NEXT_INSN (after); + emit_insn_after (var_ret_seq, after); + } /* Zap the tree EH table. */ set_eh_throw_stmt_table (cfun, NULL);