[LLVMbugs] [Bug 16976] New: function attributes on member function definitions are ignored after explicit template class declaration

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Aug 22 14:22:59 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16976

            Bug ID: 16976
           Summary: function attributes on member function definitions are
                    ignored after explicit template class declaration
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: st at quanttec.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

When clang generates the code for an explicit template class instantiation it
ignores the attributes on member functions that are defined out-of-line after
the explicit instantiation declaration.

For example, when clang compiles the following code

  #include <stdlib.h>

  template <typename T>
  class Test {
  public:
    void inlinef();

    void noinlinef();
  };

  extern template struct Test<char>;

  template <typename T>
  __attribute__((always_inline)) 
  void Test<T>::inlinef() {}

  template <typename T>
  __attribute__((noinline)) 
  void Test<T>::noinlinef() {}

  template class Test<char>;

it generates the following IR for the two member functions 

  ; Function Attrs: nounwind readnone ssp uwtable
  define weak_odr void @_ZN4TestIcE7inlinefEv(%class.Test* nocapture %this) #0
align 2 {
  entry:
    ret void
  }

  ; Function Attrs: nounwind readnone ssp uwtable
  define weak_odr void @_ZN4TestIcE9noinlinefEv(%class.Test* nocapture %this)
#0 align 2 {
  entry:
    ret void
  }

If the attributes are moved to the member function declarations or if the
explicit instantiation declaration is moved to after the function definitions
(immediately before the explicit instantiation definition), the IR function
definitions get correctly annotated with the respective attributes.

This issue can lead to difficult to diagnose performance problems.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130822/a6a1589c/attachment.html>


More information about the llvm-bugs mailing list