[LLVMdev] [Inliner] passing inline hint to optimizer if it appears explicitly on declaration

Balaram Makam bmakam at codeaurora.org
Wed Mar 25 17:32:53 PDT 2015


ping

 

From: Balaram Makam [mailto:bmakam at codeaurora.org] 
Sent: Wednesday, March 25, 2015 4:43 PM
To: 'llvmdev at cs.uiuc.edu'
Subject: [Inliner] passing inline hint to optimizer if it appears explicitly
on declaration

 

All,

 

I explicitly pass inline hint to the function declaration of foo<int>::add()
as in the following example:

 

#cat example.cpp

template <class T> class foo {

  public:

    T* tp;

    int elem;

    int maxelem;

    T* add();

};

 

template <class T> inline T* foo <T>::add()

{

  if (elem!=maxelem)

    elem++;

  return tp+elem-1;

}

 

typedef foo <int> intboundart;

 

class bar

{

  void addtobound(intboundart& boundarp);

};

 

void bar::addtobound(intboundart& barp)

{

  barp.add();

}

 

Yet the IR passed into optimizer doesn't contain inlinehint attribute:

#clang -cc1 -emit-llvm -o - example.cpp

 

<snip>

; Function Attrs: nounwind

define linkonce_odr i32* @_ZN3fooIiE3addEv(%class.foo* %this) #0 comdat
align 2 {

<snip>

 

Clang will pass inline hint to optimizer only if I declare explicitly in the
class like this:

 

template <class T> class foo {

  public:

    T* tp;

    int elem;

    int maxelem;

    inline T* add();

};

 

Isn't this a clang bug? Any pointers on how to fix this?

 

Thanks,

Balaram

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150325/fb3f7974/attachment.html>


More information about the llvm-dev mailing list