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

Balaram Makam bmakam at codeaurora.org
Fri Mar 27 04:33:36 PDT 2015


I have a potential solution here:

http://reviews.llvm.org/D8656

 

Is this a reasonable fix?

 

Thanks,

Balaram

 

From: cfe-dev-bounces at cs.uiuc.edu [mailto:cfe-dev-bounces at cs.uiuc.edu] On Behalf Of Balaram Makam
Sent: Wednesday, March 25, 2015 9:18 PM
To: 'Sean Silva'
Cc: 'Clang'
Subject: Re: [cfe-dev] [LLVMdev] [Inliner] passing inline hint to optimizer if it appears explicitly on declaration

 

Thanks Sean.

Cfe-devs, any feedback on the issue described below?

 

From: Sean Silva [mailto:chisophugis at gmail.com] 
Sent: Wednesday, March 25, 2015 8:45 PM
To: Balaram Makam
Cc: Clang
Subject: Re: [LLVMdev] [Inliner] passing inline hint to optimizer if it appears explicitly on declaration

 

This question is probably more fit for cfe-dev (CC'd). I'd guess that it has to do with which declaration we look at when determining the function attributes.

 

On Wed, Mar 25, 2015 at 5:32 PM, Balaram Makam <bmakam at codeaurora.org <mailto:bmakam at codeaurora.org> > wrote:

ping

 

From: Balaram Makam [mailto:bmakam at codeaurora.org <mailto:bmakam at codeaurora.org> ] 
Sent: Wednesday, March 25, 2015 4:43 PM
To: 'llvmdev at cs.uiuc.edu <mailto: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


_______________________________________________
LLVM Developers mailing list
LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu>          http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150327/18772d31/attachment.html>


More information about the cfe-dev mailing list