From patchwork Thu Nov 1 19:52:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 196364 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 C9F0E2C0172 for ; Fri, 2 Nov 2012 06:54:30 +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=1352404471; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:From:To:Cc:Subject:Date:Message-Id: In-Reply-To:References:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=aHpRwjaHD3e6eszz0InWgqUHVl8=; b=MQ9EqjiQ4rxZxou gjaUq++Wyj99zv4xrEZy+zqwjhNDre64xhE96paIsLV5hFDhvybOC7QgOxB2e36/ Cme46mq/SGFtNj7m6tqNv1HLFiQ7Dy72l9iIl8Q+CgKSPwyEss8MyJRo1nWQDmKc wWl8JlLbW+3fAhtByDHEjlY4tto0= 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:Received:From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:X-detected-operating-system:X-Received-From:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=IDWTE/nghkwr23WBef2q7ajBWBkqp7vqfER+sTYCwVQ43jcU+2hO+PwmLWXFYh 9v/nWLijcrQYktzSL0XC1h0VTdzlP1zWnp13zDiuPXMTjl9ypAdzvXS6iPqReWCb HyOdxxPF6XcF0ou6kEGhE6eQWrgk09gfWatM+Esw8f8FY=; Received: (qmail 21244 invoked by alias); 1 Nov 2012 19:53:17 -0000 Received: (qmail 21009 invoked by uid 22791); 1 Nov 2012 19:53:12 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, TW_SV X-Spam-Check-By: sourceware.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 01 Nov 2012 19:52:55 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TU0ov-0004as-6H for gcc-patches@gcc.gnu.org; Thu, 01 Nov 2012 15:52:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39624) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TU0ou-0004aF-Si for gcc-patches@gcc.gnu.org; Thu, 01 Nov 2012 15:52:53 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qA1Jqpl2024527 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 1 Nov 2012 15:52:51 -0400 Received: from localhost (ovpn-116-40.ams2.redhat.com [10.36.116.40]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qA1Jqn0T005301 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 1 Nov 2012 15:52:51 -0400 Received: by localhost (Postfix, from userid 1000) id E107C2C010A; Thu, 1 Nov 2012 20:52:47 +0100 (CET) From: dodji@redhat.com To: gcc-patches@gcc.gnu.org Cc: dnovillo@google.com, jakub@redhat.com, wmi@google.com, davidxl@google.com, konstantin.s.serebryany@gmail.com Subject: [PATCH 08/13] Fix a couple of ICEs. Date: Thu, 1 Nov 2012 20:52:41 +0100 Message-Id: <1351799566-31447-9-git-send-email-dodji@redhat.com> In-Reply-To: <1351799566-31447-1-git-send-email-dodji@redhat.com> References: <1351799566-31447-1-git-send-email-dodji@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 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 From: jakub After the previous patches uncovered the fact a NOTE_INSN_BASIC_BLOCK could show up in the middle of a basic block and thus violating an important invariant. THe cfgexpand.c hunk fixes that. Then it appeared that we could get tree sharing violation if build_check_stmt doesn't unshare its base memory parameter before building an ssa name for it. The last hunk fixes a crash that happens because cgraph_build_static_cdtor can call ggc_collect so holding trees around in automatic (thus visited by the gc marker routines) could lead to these tree behind free-ed underneath us. So the patch adds new gc roots for these trees. * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/asan@192567 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.asan | 12 ++++++++++++ gcc/asan.c | 13 +++++++++---- gcc/cfgexpand.c | 8 +++++++- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/gcc/ChangeLog.asan b/gcc/ChangeLog.asan index 971de42..3da0a0b 100644 --- a/gcc/ChangeLog.asan +++ b/gcc/ChangeLog.asan @@ -1,3 +1,15 @@ +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. + 2012-10-17 Jakub Jelinek * varasm.c: Include asan.h. diff --git a/gcc/asan.c b/gcc/asan.c index c435d35..6715e51 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -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, VEC(constructor_elt, gc) *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, VEC(constructor_elt, gc) *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 +804,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 +815,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); } diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 67cf902..16fd0fb 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -4638,7 +4638,13 @@ gimple_expand_cfg (void) insn_locations_finalize (); if (var_ret_seq) - emit_insn_after (var_ret_seq, return_label); + { + rtx after = return_label; + rtx next = NEXT_INSN (after); + if (next && NOTE_INSN_BASIC_BLOCK_P (next)) + after = next; + emit_insn_after (var_ret_seq, after); + } /* Zap the tree EH table. */ set_eh_throw_stmt_table (cfun, NULL);