From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22625 invoked by alias); 19 May 2014 08:52:58 -0000 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 Received: (qmail 22610 invoked by uid 89); 19 May 2014 08:52:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f171.google.com Received: from mail-wi0-f171.google.com (HELO mail-wi0-f171.google.com) (209.85.212.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 19 May 2014 08:52:55 +0000 Received: by mail-wi0-f171.google.com with SMTP id cc10so1078467wib.10 for ; Mon, 19 May 2014 01:52:52 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.194.82.170 with SMTP id j10mr1434389wjy.63.1400489572143; Mon, 19 May 2014 01:52:52 -0700 (PDT) Received: by 10.194.119.193 with HTTP; Mon, 19 May 2014 01:52:52 -0700 (PDT) In-Reply-To: <20140516191242.GA10833@kam.mff.cuni.cz> References: <20140516180442.GI20755@kam.mff.cuni.cz> <20140516191242.GA10833@kam.mff.cuni.cz> Date: Mon, 19 May 2014 08:52:00 -0000 Message-ID: Subject: Re: [C++ patch] Reduce vtable alignment From: Richard Biener To: Jan Hubicka Cc: GCC Patches , Jason Merrill Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-05/txt/msg01450.txt.bz2 On Fri, May 16, 2014 at 9:12 PM, Jan Hubicka wrote: > Hi, > this patch makes also the rtti type info for A in the testcase: > > struct A > { > virtual void foo(void) {}; > virtual void foo2(void) {}; > virtual void foo3(void) {}; > virtual void foo4(void) {}; > virtual void foo5(void) {}; > } a; > > aligned only to the ABI requirement (8) instead of being bumped up to 16 bytes > by the following code in i386.c: > /* x86-64 ABI requires arrays greater than 16 bytes to be aligned > to 16byte boundary. */ > if (TARGET_64BIT) > { > if ((opt ? AGGREGATE_TYPE_P (type) : TREE_CODE (type) == ARRAY_TYPE) > && TYPE_SIZE (type) > && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST > && wi::geu_p (TYPE_SIZE (type), 128) > && align < 128) > return 128; > } > > Here the variable is first run through align_variable and that decides to add > optional alignment. We really want only ABI required alignment here. > Does the following patch look resonable? Hmm, but if the optimizers or the target can rely on DATA_ABI_ALIGNMENT then we can't really lower it. Because we can make the vtable escape to another unit that sees it as just an array of pointers? So this looks unsafe to me. (same may apply to the idea of having TARGET_VTABLE_ENTRY_ALIGN at all, if that possibly conflicts with ABI alignment requirements present otherwise). Richard. > * rtti.c: Include tm_p.h > (emit_tinfo_decl): Align type infos only as required by the target ABI. > > Index: rtti.c > =================================================================== > --- rtti.c (revision 210521) > +++ rtti.c (working copy) > @@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. > #include "coretypes.h" > #include "tm.h" > #include "tree.h" > +#include "tm_p.h" > #include "stringpool.h" > #include "stor-layout.h" > #include "cp-tree.h" > @@ -1596,6 +1597,12 @@ emit_tinfo_decl (tree decl) > DECL_INITIAL (decl) = init; > mark_used (decl); > cp_finish_decl (decl, init, false, NULL_TREE, 0); > + /* Avoid targets optionally bumping up the alignment to improve > + vector instruction accesses, tinfo are never accessed this way. */ > +#ifdef DATA_ABI_ALIGNMENT > + DECL_ALIGN (decl) = DATA_ABI_ALIGNMENT (decl, TYPE_ALIGN (TREE_TYPE (decl))); > + DECL_USER_ALIGN (decl) = true; > +#endif > return true; > } > else