[LLVMbugs] [Bug 4884] New: function attributes of template methods of template classes are ignored

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Fri Sep 4 05:35:43 PDT 2009


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

           Summary: function attributes of template methods of template
                    classes are ignored
           Product: tools
           Version: 2.6
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: llvm-g++
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: torvald at se.inf.tu-dresden.de
                CC: llvmbugs at cs.uiuc.edu


test case:

template<typename X> X bar(X x) __attribute__((noinline));
template<typename X> X bar(X x) { return x + 1; }

template <typename S> class Bar {
public:
  S s;
  Bar() : s(1) {}
  template<typename X> X bar(X x) __attribute__((noinline));
};

template <typename S>
template<typename X> X Bar<S>::bar(X x) { return x + 1 + s; }

int test()
{
  int a = bar((int)1);
  Bar<int> bar;
  int b = bar.bar((int)1);
  return a + b;
}


llvm-g++ -emit-llvm -o foo.bc foo.cpp -O3 -c yields:

efine i32 @_Z4testv() nounwind {
entry:
  %0 = tail call i32 @_Z3barIiET_S0_(i32 1) nounwind ; <i32> [#uses=1]
  %1 = add nsw i32 %0, 3                          ; <i32> [#uses=1]
  ret i32 %1
}

define linkonce_odr i32 @_Z3barIiET_S0_(i32 %x) nounwind readnone noinline {
entry:
  %0 = add nsw i32 %x, 1                          ; <i32> [#uses=1]
  ret i32 %0
}

Bar<S>::bar isn't marked as noinline. Likewise, there is no compiler warning
when using non-existing function attributes. It does seem to work for the
template function, though.


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list