From patchwork Thu Nov 1 19:52:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 196365 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 55F0B2C00D7 for ; Fri, 2 Nov 2012 06:54:48 +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=1352404488; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:From:To:Cc:Subject:Date:Message-Id: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=IgVoXw5dUJ08phnqVdqYHTvZHxY=; b=wWP3TbmpdtTyAn4 w89+/IzxVMdoSwPvmwvRBekBiP0XR7sJYt9DTD066XUBR7Sh2qK9K6M3Zmy1OmpU 2AD7YqZxWx17MwmiavwuZ4470sGjDljPSshCyluc84uOd3stf8/65/Q+bluZEpIu ZgxfE74vTggvecQyKyHGCGgrSp2g= 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:MIME-Version:Content-Type:Content-Transfer-Encoding:X-detected-operating-system:X-Received-From:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=rjIALZCP/e7pr31SlQtujS4x3j/8ESpTgedmWoS2lxJ5wpPhjkB3AFPhIq5Bwd Wi0dQz/dXD2H9gm3pE9oT73BVp/oKroVNqaClPo+jTTKmx2xkKNhmpCw2j7ELVR/ SBYzHDbwdD9Cp0cTzAKnb0/IWDYyUgPZSEWO8RQZw6tcM=; Received: (qmail 21617 invoked by alias); 1 Nov 2012 19:53:25 -0000 Received: (qmail 21575 invoked by uid 22791); 1 Nov 2012 19:53:23 -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, TW_TM 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:53:12 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TU0p0-0004cW-5C for gcc-patches@gcc.gnu.org; Thu, 01 Nov 2012 15:52:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39432) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TU0oz-0004cG-G7 for gcc-patches@gcc.gnu.org; Thu, 01 Nov 2012 15:52:58 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qA1JqueV007119 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 1 Nov 2012 15:52:56 -0400 Received: from localhost (ovpn-116-40.ams2.redhat.com [10.36.116.40]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qA1Jqt4C000343 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 1 Nov 2012 15:52:56 -0400 Received: by localhost (Postfix, from userid 1000) id 1E6B72C010D; Thu, 1 Nov 2012 20:52:48 +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: =?utf8?q?=5BPATCH=2010/13=5D=20Make=20build=5Fcheck=5Fstmt=20accept=20an=20SSA=5FNAME=20for=20its=20base?= Date: Thu, 1 Nov 2012 20:52:43 +0100 Message-Id: <1351799566-31447-11-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> MIME-Version: 1.0 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: dodji This patch makes build_check_stmt accept its memory access parameter to be an SSA name. This is useful for a subsequent patch that will re-use. Tested by running cc1 -fasan on the program below with and without the patch and inspecting the gimple output to see that there is no change. void foo () { char foo[1] = {0}; foo[0] = 1; } gcc/ * asan.c (build_check_stmt): Accept the memory access to be represented by an SSA_NAME. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/asan@192843 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.asan | 5 +++++ gcc/asan.c | 36 +++++++++++++++++++++++------------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/gcc/ChangeLog.asan b/gcc/ChangeLog.asan index 57670f7..9159b3f 100644 --- a/gcc/ChangeLog.asan +++ b/gcc/ChangeLog.asan @@ -1,3 +1,8 @@ +2012-10-26 Dodji Seketeli + + * asan.c (build_check_stmt): Accept the memory access to be + represented by an SSA_NAME. + 2012-10-25 Wei Mi   * varasm.c (assemble_variable): Set asan_protected even diff --git a/gcc/asan.c b/gcc/asan.c index 6715e51..b43f03b 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -397,16 +397,18 @@ asan_init_func (void) #define PROB_VERY_UNLIKELY (REG_BR_PROB_BASE / 2000 - 1) #define PROB_ALWAYS (REG_BR_PROB_BASE) -/* Instrument the memory access instruction BASE. - Insert new statements before ITER. - LOCATION is source code location. - IS_STORE is either 1 (for a store) or 0 (for a load). +/* Instrument the memory access instruction BASE. Insert new + statements before ITER. + + Note that the memory access represented by BASE can be either an + SSA_NAME, or a non-SSA expression. LOCATION is the source code + location. IS_STORE is TRUE for a store, FALSE for a load. SIZE_IN_BYTES is one of 1, 2, 4, 8, 16. */ static void -build_check_stmt (tree base, - gimple_stmt_iterator *iter, - location_t location, bool is_store, int size_in_bytes) +build_check_stmt (tree base, gimple_stmt_iterator *iter, + location_t location, bool is_store, + int size_in_bytes) { gimple_stmt_iterator gsi; basic_block cond_bb, then_bb, else_bb; @@ -417,6 +419,7 @@ build_check_stmt (tree base, tree shadow_type = TREE_TYPE (shadow_ptr_type); tree uintptr_type = build_nonstandard_integer_type (TYPE_PRECISION (TREE_TYPE (base)), 1); + tree base_ssa = base; /* We first need to split the current basic block, and start altering the CFG. This allows us to insert the statements we're about to @@ -462,15 +465,22 @@ build_check_stmt (tree base, 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), - base, NULL_TREE); - gimple_set_location (g, location); - gsi_insert_after (&gsi, g, GSI_NEW_STMT); + + /* BASE can already be an SSA_NAME; in that case, do not create a + new SSA_NAME for it. */ + if (TREE_CODE (base) != SSA_NAME) + { + g = gimple_build_assign_with_ops (TREE_CODE (base), + make_ssa_name (TREE_TYPE (base), NULL), + base, NULL_TREE); + gimple_set_location (g, location); + gsi_insert_after (&gsi, g, GSI_NEW_STMT); + base_ssa = gimple_assign_lhs (g); + } g = gimple_build_assign_with_ops (NOP_EXPR, make_ssa_name (uintptr_type, NULL), - gimple_assign_lhs (g), NULL_TREE); + base_ssa, NULL_TREE); gimple_set_location (g, location); gsi_insert_after (&gsi, g, GSI_NEW_STMT); base_addr = gimple_assign_lhs (g);