From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19641 invoked by alias); 24 Oct 2012 16:15:07 -0000 Received: (qmail 19501 invoked by uid 22791); 24 Oct 2012 16:15:01 -0000 X-SWARE-Spam-Status: No, hits=-6.7 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; Wed, 24 Oct 2012 16:14:58 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9OGEwVN032760 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 24 Oct 2012 12:14:58 -0400 Received: from zalov.redhat.com (vpn1-5-133.ams2.redhat.com [10.36.5.133]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q9OGEuxa005036 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 24 Oct 2012 12:14:57 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id q9OGEtWK007076; Wed, 24 Oct 2012 18:14:56 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id q9OGEtw6007075; Wed, 24 Oct 2012 18:14:55 +0200 Date: Wed, 24 Oct 2012 16:46:00 -0000 From: Jakub Jelinek To: Dodji Seketeli Cc: GCC Patches , Diego Novillo , Xinliang David Li , Wei Mi Subject: Re: [PATCH 3/3] [asan] Instrument built-in memory access function calls Message-ID: <20121024161455.GI1752@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <87liex8hjt.fsf@redhat.com> <8762618ha6.fsf@redhat.com> <20121023160323.GU1752@tucnak.redhat.com> <87bofr6h2c.fsf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87bofr6h2c.fsf@redhat.com> 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-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2012-10/txt/msg02183.txt.bz2 On Wed, Oct 24, 2012 at 05:11:23PM +0200, Dodji Seketeli wrote: > If I write exactly what you wrote here, I am getting an error for e.g: > > void > bar () > { > char bar[1] = {0}; > int n = 0; > > __builtin_memset (bar, 0, n); > } I see, the problem is that build_check_stmt is initially called on an iterator in empty bb. Your solution is fine. > > On the other side, you IMHO want to handle here also __atomic_* and > > __sync_* builtins (not by using instrument_mem_region_access, but > > just instrument_derefs > > Updated in the patch below. case BUILT_IN_ATOMIC_ALWAYS_LOCK_FREE: case BUILT_IN_ATOMIC_IS_LOCK_FREE: I think don't touch the memory at all (or not necessarily), and IMHO you don't want to handle the BUILT_IN_*_N variants either, those are just FE builtins that are lowered to the corresponding _{1,2,4,8,16} variants. > @@ -661,13 +702,477 @@ instrument_derefs (gimple_stmt_iterator *iter, tree t, > int volatilep = 0, unsignedp = 0; > get_inner_reference (t, &bitsize, &bitpos, &offset, > &mode, &unsignedp, &volatilep, false); > - if (bitpos != 0 || bitsize != size_in_bytes * BITS_PER_UNIT) > + if (bitpos % BITS_PER_UNIT || bitsize != size_in_bytes * BITS_PER_UNIT) > return; Shouldn't that be bitpos % (size_in_bytes * BITS_PER_UNIT) ? 1 byte or 2 byte access at bitpos 80 is fine, but 4 byte access is not. Jakub