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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to