Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Inline template function instances #50

Merged
merged 1 commit into from

2 participants

@jpf91
Collaborator

Functions which are marked as DECL_WEAK are not inlined by gcc as
they could be replaced with a completely different implementation
at link time.

We know that our template instances will always be identical so
they should be inlined. The solution is to mark the template
function instance as DECL_DECLARED_INLINE_P as it's also done in
C++.

This also applies to DECL_ONE_ONLY functions as make_decl_one_only
also sets DECL_WEAK.

Related discussion on gcc-list:
http://article.gmane.org/gmane.comp.gcc.devel/130242

@jpf91 jpf91 Inline template function instances
Functions which are marked as DECL_WEAK are not inlined by gcc as
they could be replaced with a completely different implementation
at link time.

We know that our template instances will always be identical so
they should be inlined. The solution is to mark the template
function instance as DECL_DECLARED_INLINE_P as it's also done in
C++.

This also applies to DECL_ONE_ONLY functions as make_decl_one_only
also sets DECL_WEAK.

Related discussion on gcc-list:
http://article.gmane.org/gmane.comp.gcc.devel/130242
15d4663
@ibuclaw
Owner

Looks fine to me.

@ibuclaw ibuclaw merged commit af01eed into from
@jpf91 jpf91 deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 19, 2013
  1. @jpf91

    Inline template function instances

    jpf91 authored
    Functions which are marked as DECL_WEAK are not inlined by gcc as
    they could be replaced with a completely different implementation
    at link time.
    
    We know that our template instances will always be identical so
    they should be inlined. The solution is to mark the template
    function instance as DECL_DECLARED_INLINE_P as it's also done in
    C++.
    
    This also applies to DECL_ONE_ONLY functions as make_decl_one_only
    also sets DECL_WEAK.
    
    Related discussion on gcc-list:
    http://article.gmane.org/gmane.comp.gcc.devel/130242
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 0 deletions.
  1. +4 −0 gcc/d/d-objfile.cc
View
4 gcc/d/d-objfile.cc
@@ -219,6 +219,10 @@ ObjectFile::makeDeclOneOnly (tree decl_tree)
even if the target supports one-only. */
if (!D_DECL_IS_TEMPLATE (decl_tree) || gen.emitTemplates != TEprivate)
{
+ // Necessary to allow DECL_ONE_ONLY or DECL_WEAK functions to be inlined
+ if (TREE_CODE (decl_tree) == FUNCTION_DECL)
+ DECL_DECLARED_INLINE_P (decl_tree) = 1;
+
/* The following makes assumptions about the behavior
of make_decl_one_only */
if (SUPPORTS_ONE_ONLY)
Something went wrong with that request. Please try again.