From patchwork Sat Oct 6 16:46:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 189746 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 15FEB2C0156 for ; Sun, 7 Oct 2012 03:46:57 +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=1350146818; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=4388AITWFxrAH2iaRhkDyeCqW1M=; b=E7f3AGmjr6ecsqQ 69fl6WOqgCqLvdMb/sN9+/1ECrlHDwbYKzJ3MBFcESoaKBrrS66B44DuOCdXHtcx 7TSogOTqNrH7UN8wMw6a+M+j33WcBFtPp77SFVTS/XzzbeAVUONp7KCvklLHFX7T NmF07aalohYdWaO4VGe/N2F8flqk= 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:Date:From:To:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=CGX4UL8EwKOOFcjpdjo/9KIb8kDpnSPb1OBgnFiRHTLwUXvh3mmxHnoHO3kPN1 pxRB92UCRC7jMn68S9k7ORhhhf1ykEmYzer767kPGMGkaugVEU1qLRGeSzscKNya CCFQBqdizhmY+/hDat/6U9BZAMOaSQHR1mh0K1T2BtvIw=; Received: (qmail 21089 invoked by alias); 6 Oct 2012 16:46:53 -0000 Received: (qmail 21080 invoked by uid 22791); 6 Oct 2012 16:46:52 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 06 Oct 2012 16:46:45 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 90E145417DF; Sat, 6 Oct 2012 18:46:44 +0200 (CEST) Date: Sat, 6 Oct 2012 18:46:44 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Drop V1 plugin API hack Message-ID: <20121006164644.GB5193@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 Hi, this patch removes V1 API hack, making us to require V2 plugin api aware linker to get sane code quality on anything using COMDAT. Given that the V1 API linkers are quite old now, I think it is safe. I added a testcase that should fail with old linker and will update changes.html. The patch also cleans up the code for new symbol table APIs. Nice effect is that inliner is now more aggressive about inlining comdats and thus tramp3d scoes are improved with -flto once again. lto-bootstrapped/regtested x86_64, comitted. Honza PR lto/53831 PR lto/54776 * g++.dg/lto/v1-plugin-api-not-supported.C: New testcase. * lto-streamer-out.c (produce_symtab): Cleanup; drop v1 API hack. Index: testsuite/g++.dg/lto/v1-plugin-api-not-supported.C =================================================================== --- testsuite/g++.dg/lto/v1-plugin-api-not-supported.C (revision 0) +++ testsuite/g++.dg/lto/v1-plugin-api-not-supported.C (revision 0) @@ -0,0 +1,59 @@ +// { dg-lto-do run } +// { dg-require-linker-plugin "" } +// { dg-lto-options {{-O2 -fuse-linker-plugin -fno-early-inlining}} + +extern "C" void abort (void); +extern "C" void linker_error (); + +class A +{ +public: + int data; + virtual int foo (int i) + { + return i + 1; + } +}; + +class B : public A +{ +public: + virtual int foo (int i) + { + return i + 2; + } +}; + +class C : public A +{ +public: + virtual int foo (int i) + { + linker_error (); + return i + 3; + } +}; + + +static int middleman (class A *obj, int i) +{ + return obj->foo (i); +} + +int __attribute__ ((noinline,noclone)) get_input(void) +{ + return 1; +} + +int main (int argc, char *argv[]) +{ + class B b; + if (middleman (&b, get_input ()) != 3) + abort (); + return 0; +} + +/* { dg-final { scan-ipa-dump "Discovered a virtual call to a known target.*B::foo" "cp" } } */ +/* { dg-final { scan-tree-dump-times "OBJ_TYPE_REF" 0 "optimized"} } */ +/* { dg-final { cleanup-ipa-dump "cp" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ Index: lto-streamer-out.c =================================================================== --- lto-streamer-out.c (revision 192154) +++ lto-streamer-out.c (working copy) @@ -1285,11 +1287,9 @@ produce_symtab (struct output_block *ob) struct streamer_tree_cache_d *cache = ob->writer_cache; char *section_name = lto_get_section_name (LTO_section_symtab, NULL, NULL); struct pointer_set_t *seen; - struct cgraph_node *node; - struct varpool_node *vnode; struct lto_output_stream stream; lto_symtab_encoder_t encoder = ob->decl_state->symtab_node_encoder; - int i; + lto_symtab_encoder_iterator lsei; lto_begin_section (section_name, false); free (section_name); @@ -1297,78 +1297,26 @@ produce_symtab (struct output_block *ob) seen = pointer_set_create (); memset (&stream, 0, sizeof (stream)); - /* Write all functions. - First write all defined functions and then write all used functions. - This is done so only to handle duplicated symbols in cgraph. */ - for (i = 0; i < lto_symtab_encoder_size (encoder); i++) + /* Write the symbol table. + First write everything defined and then all declarations. + This is neccesary to handle cases where we have duplicated symbols. */ + for (lsei = lsei_start (encoder); + !lsei_end_p (lsei); lsei_next (&lsei)) { - if (!symtab_function_p (lto_symtab_encoder_deref (encoder, i))) - continue; - node = cgraph (lto_symtab_encoder_deref (encoder, i)); - if (DECL_EXTERNAL (node->symbol.decl)) - continue; - if (DECL_COMDAT (node->symbol.decl) - && cgraph_comdat_can_be_unshared_p (node)) - continue; - if ((node->alias && !node->thunk.alias) || node->global.inlined_to) + symtab_node node = lsei_node (lsei); + + if (!symtab_real_symbol_p (node) || DECL_EXTERNAL (node->symbol.decl)) continue; write_symbol (cache, &stream, node->symbol.decl, seen, false); } - for (i = 0; i < lto_symtab_encoder_size (encoder); i++) + for (lsei = lsei_start (encoder); + !lsei_end_p (lsei); lsei_next (&lsei)) { - if (!symtab_function_p (lto_symtab_encoder_deref (encoder, i))) - continue; - node = cgraph (lto_symtab_encoder_deref (encoder, i)); - if (!DECL_EXTERNAL (node->symbol.decl)) - continue; - /* We keep around unused extern inlines in order to be able to inline - them indirectly or via vtables. Do not output them to symbol - table: they end up being undefined and just consume space. */ - if (!node->symbol.address_taken && !node->callers) - continue; - if (DECL_COMDAT (node->symbol.decl) - && cgraph_comdat_can_be_unshared_p (node)) - continue; - if ((node->alias && !node->thunk.alias) || node->global.inlined_to) - continue; - write_symbol (cache, &stream, node->symbol.decl, seen, false); - } + symtab_node node = lsei_node (lsei); - /* Write all variables. */ - for (i = 0; i < lto_symtab_encoder_size (encoder); i++) - { - if (!symtab_variable_p (lto_symtab_encoder_deref (encoder, i))) - continue; - vnode = varpool (lto_symtab_encoder_deref (encoder, i)); - if (DECL_EXTERNAL (vnode->symbol.decl)) - continue; - /* COMDAT virtual tables can be unshared. Do not declare them - in the LTO symbol table to prevent linker from forcing them - into the output. */ - if (DECL_COMDAT (vnode->symbol.decl) - && !vnode->symbol.force_output - && vnode->finalized - && DECL_VIRTUAL_P (vnode->symbol.decl)) - continue; - if (vnode->alias && !vnode->alias_of) - continue; - write_symbol (cache, &stream, vnode->symbol.decl, seen, false); - } - for (i = 0; i < lto_symtab_encoder_size (encoder); i++) - { - if (!symtab_variable_p (lto_symtab_encoder_deref (encoder, i))) - continue; - vnode = varpool (lto_symtab_encoder_deref (encoder, i)); - if (!DECL_EXTERNAL (vnode->symbol.decl)) + if (!symtab_real_symbol_p (node) || !DECL_EXTERNAL (node->symbol.decl)) continue; - if (DECL_COMDAT (vnode->symbol.decl) - && !vnode->symbol.force_output - && vnode->finalized - && DECL_VIRTUAL_P (vnode->symbol.decl)) - continue; - if (vnode->alias && !vnode->alias_of) - continue; - write_symbol (cache, &stream, vnode->symbol.decl, seen, false); + write_symbol (cache, &stream, node->symbol.decl, seen, false); } lto_write_stream (&stream);