From patchwork Thu Feb 6 22:19:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriraman Tallam X-Patchwork-Id: 317556 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B16EE2C0099 for ; Fri, 7 Feb 2014 09:19:21 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:content-type; q=dns; s=default; b=PxoEPxnUfP9bKGui8S6X7 R7XVBRTkYqROxBaN2ubgDInk7PprOU7jy1dMDFEkKRC52h1Sp5AwPH1kdHdomdxQ cXGT5WfAQQCGY5hvq13nRA++9O9xS06ctZwCbGrQ1JD6DJa3316JIBYxlm4sQ6LW FDS/Xth7VY2Lz2wjjmZxd4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:content-type; s=default; bh=LXkABenxo/cenMFKTV+Kj/fb66s =; b=rqqhpaB7gRJVBNHK5oIVpAUpT2D4fHkcvgz1ArBZC/8dookY/47tX14XJUS UFTLJQl++lLbMoZ9Yw7YUV5/I+reYNJ82lR/n/GJFpi4NCzLkXZ/K28OSDV4MEm7 ObW8dBvlCxykTJ9hOxcvT+oGKbWn90H5yTm0bjSEg7SfRarU= Received: (qmail 4305 invoked by alias); 6 Feb 2014 22:19:15 -0000 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 Received: (qmail 4294 invoked by uid 89); 6 Feb 2014 22:19:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-vc0-f175.google.com Received: from mail-vc0-f175.google.com (HELO mail-vc0-f175.google.com) (209.85.220.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 06 Feb 2014 22:19:13 +0000 Received: by mail-vc0-f175.google.com with SMTP id ij19so1956340vcb.6 for ; Thu, 06 Feb 2014 14:19:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=7+M8Qhg5nQsj8y4k5F4jONkPIPzUmK7tVOmxjLr2DE8=; b=e+hu3CwR5BjyLMiRIkIXbfnhxe7DfZjGHTfAJi500h5UmKTQVYdbe7CnGVKZppRu76 xpuYkTxIT6DeD1P7oC0+KtMvGeH5sOJLaugr/ZA4i1bA0dK3F7wQU5UA9jSXeFoNkYC0 F/eEAoey5tiFRrzUTYVj/tmmMCTD2DNz3iYg17uvP18Umlz+as2U/XpXD+5xyE0jBmBa wfF8lDMjtaI5cXQh1/fEy26LcmUn57RXyEdLZ/EqenkQyd08+FFBuURvmKuVcebLVwv5 BDM9ujimWeNAWDjaZ5kKJig56gfBNdVGpA7/ydUjSmNGK8O9gKN41jT2hvINMZ9wU0P9 NksA== X-Gm-Message-State: ALoCoQnHuBenqfeuNXOZ6zjbtjNb/VdTyB2LOwnqMh4QQBJidf7LSLRdfH1V5ZD5Xcvcu8flzhxWOBKHoLDpp2MuuzbdwCsWMgkH2FQ9so4eeCgL14EnjOXvvOR9JgntpxFCASU3a+l3OPrHw23VFRthyOuqzy3jyfvSxybYUG4WWRIzx/pNLBQ/FmIASnOjPOLfKXCGp0O4FeMaBmLHNdTAp0/t6OxEoA== MIME-Version: 1.0 X-Received: by 10.220.98.204 with SMTP id r12mr1054746vcn.48.1391725151438; Thu, 06 Feb 2014 14:19:11 -0800 (PST) Received: by 10.52.32.233 with HTTP; Thu, 6 Feb 2014 14:19:11 -0800 (PST) In-Reply-To: References: Date: Thu, 6 Feb 2014 14:19:11 -0800 Message-ID: Subject: Re: [google gcc-4_8][patch] Thunk section names From: Sriraman Tallam To: GCC Patches , Teresa Johnson , David Li X-IsSubscribed: yes Patch attached. On Thu, Feb 6, 2014 at 2:18 PM, Sriraman Tallam wrote: > I sent the following patch for review for trunk commit here. Details here: > http://gcc.gnu.org/ml/gcc-patches/2014-02/msg00328.html > > This is important for function layout for the following reason. > Without this patch, the thunk's section name is the same as the original > function's section name for which the thunk is created. This affects function > layout as it is not possible to figure out the thunk section from the name > alone. With this patch, the thunk's section name is suffixed with the mangled > name of the thunk and this solves the problem. > > Is this patch ok for google/gcc-4_8? > > Sri I sent the following patch for review for trunk commit here. Details here: http://gcc.gnu.org/ml/gcc-patches/2014-02/msg00328.html This is important for function layout for the following reason. Without this patch, the thunk's section name is the same as the original function's section name for which the thunk is created. This affects function layout as it is not possible to figure out the thunk section from the name alone. With this patch, the thunk's section name is suffixed with the mangled name of the thunk and this solves the problem. Is this patch ok for google/gcc-4_8? Index: cp/method.c =================================================================== --- cp/method.c (revision 207581) +++ cp/method.c (working copy) @@ -360,8 +360,10 @@ use_thunk (tree thunk_fndecl, bool emit_p) { resolve_unique_section (thunk_fndecl, 0, flag_function_sections); - /* Output the thunk into the same section as function. */ - DECL_SECTION_NAME (thunk_fndecl) = DECL_SECTION_NAME (function); + /* Output the thunk into the same section as function if function reordering + is not switched on. */ + if (!flag_reorder_functions) + DECL_SECTION_NAME (thunk_fndecl) = DECL_SECTION_NAME (function); } } Index: testsuite/g++.dg/thunk_section_name.C =================================================================== --- testsuite/g++.dg/thunk_section_name.C (revision 0) +++ testsuite/g++.dg/thunk_section_name.C (revision 0) @@ -0,0 +1,30 @@ +/* { dg-require-named-sections "" } */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-reorder-blocks-and-partition -ffunction-sections" } */ + +class base_class_1 +{ +public: + virtual void vfn () {} +}; + +class base_class_2 +{ +public: + virtual void vfn () {} +}; + +class need_thunk_class : public base_class_1, public base_class_2 +{ +public: + virtual void vfn () {} +}; + +int main (int argc, char *argv[]) +{ + base_class_1 *c = new need_thunk_class (); + c->vfn(); + return 0; +} + +/* { dg-final { scan-assembler "\.text\._ZThn8_N16need_thunk_class3vfnEv" } } */