From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21385 invoked by alias); 11 Oct 2012 17:31:38 -0000 Received: (qmail 21377 invoked by uid 22791); 11 Oct 2012 17:31:36 -0000 X-SWARE-Spam-Status: No, hits=-7.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_VZ,TW_XF,TW_ZB 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, 11 Oct 2012 17:31:32 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9BHVWXS025984 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 11 Oct 2012 13:31:32 -0400 Received: from zalov.redhat.com (vpn1-4-98.ams2.redhat.com [10.36.4.98]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q9BHVUlm024523 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 11 Oct 2012 13:31:31 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id q9BHVTGO011732; Thu, 11 Oct 2012 19:31:29 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id q9BHVTeg011731; Thu, 11 Oct 2012 19:31:29 +0200 Date: Thu, 11 Oct 2012 17:32:00 -0000 From: Jakub Jelinek To: Diego Novillo Cc: Dodji Seketeli , gcc-patches@gcc.gnu.org, Wei Mi Subject: Re: [asan] Emit GIMPLE directly, small cleanups Message-ID: <20121011173129.GF584@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <20121011163847.GE584@tucnak.redhat.com> <5076FE77.1060806@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5076FE77.1060806@google.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/msg01135.txt.bz2 On Thu, Oct 11, 2012 at 01:14:31PM -0400, Diego Novillo wrote: > On 2012-10-11 12:38 , Jakub Jelinek wrote: > > >- gimple_seq seq, stmts; > >- tree shadow_type = size_in_bytes == 16 ? > >- short_integer_type_node : char_type_node; > >- tree shadow_ptr_type = build_pointer_type (shadow_type); > >- tree uintptr_type = lang_hooks.types.type_for_mode (ptr_mode, > >- /*unsignedp=*/true); > >+ tree shadow_ptr_type = shadow_ptr_types[size_in_bytes == 16]; > > Add '? 1 : 0' in the array index expression. Ok. > > /* Build > >- (base_addr >> ASAN_SHADOW_SHIFT) | targetm.asan_shadow_offset (). */ > >+ (base_addr >> ASAN_SHADOW_SHIFT) + targetm.asan_shadow_offset (). */ > > Hm, I wonder if this is a documentation problem or we're generating > bad runtime code. Wei, you tested the runtime and it was working > with the GCC generated code, right? The asan web pages document |, the old tree-asan.c emitted +, I've changed it to BIT_IOR_EXPR, but that resulted in worse assembly, and I believe at least for the current x86_64 and i686 address ranges and shadow offset values it actually doesn't matter. On x86_64 stack is like 0x7ffff6e00000, shifted down by 3 is still smaller than 1L << 44 that is ored or added to it. And the negative half of the address space is used by the kernel, nothing is mapped into it (besides vsyscall page) and neither | nor + of 1L << 44 to it would work well. On i386, | and + works the same for all addresses, as 0xffffffffU >> 3 is still smaller than 1 << 29. The reason why + generates better code on x86_64/i686 is that one can use e.g. movzbl (%r1, %r2), %r3 instead of orq %r2, %r1; movzb (%r1), %r3. > >+ if (shadow_ptr_types[0] == NULL_TREE) > >+ { > >+ alias_set_type set = new_alias_set (); > >+ shadow_ptr_types[0] > >+ = build_distinct_type_copy (unsigned_char_type_node); > >+ TYPE_ALIAS_SET (shadow_ptr_types[0]) = set; > >+ shadow_ptr_types[0] = build_pointer_type (shadow_ptr_types[0]); > >+ shadow_ptr_types[1] > >+ = build_distinct_type_copy (short_unsigned_type_node); > >+ TYPE_ALIAS_SET (shadow_ptr_types[1]) = set; > >+ shadow_ptr_types[1] = build_pointer_type (shadow_ptr_types[1]); > >+ } > > Move this to an initialization function, please. Okay. Jakub