[LLVMdev] Inline hints for *compiler clients*

Chris Lattner sabre at nondot.org
Wed Mar 15 14:25:16 PST 2006

On Wed, 15 Mar 2006, Vikram S. Adve wrote:
> On Mar 15, 2006, at 11:15 AM, Chris Lattner wrote:
>> On Wed, 15 Mar 2006, Vikram S. Adve wrote:
>>>> Why can't the compiler pass just call InlineFunction(CallSite) on the 
>>>> callsite it wants inlined?  The only way that can fail is if LLVM cannot 
>>>> ever inline the call (e.g. it uses varargs).
>>> In some cases, that would be fine.  But in other cases:
>>> (1) It cannot "un-inline" any function that was previously inlined.
>> I'm not following.  Why do you want to uninline stuff?  If we had a 'never 
>> inline these functions' list,
> We don't have such a list, at least not so far.  We do have a "used" list but 
> that's presumably used for other things.

Yes, of course.  However, as stated earlier in the thread, that is just 
because noone has done it yet.  If you would like to implement it, go for 
it, I'd be happy to have it in LLVM.

>> a transformation could add any function it wants to this list to prevent 
>> the inliner from inlining it in the future.
>> Aside from that, I don't see what uninlining has to do with inlining 
>> heuristics, can you explain a bit more?
> I'm not sure what there is to explain.  Inlining heuristics control what to 
> inline.  If you're writing a tool, you'd want to run the inliner while 
> influencing what it chooses to inline.

Example please.

>>> (2) It requires writing a driver loop nest to go over all call sites and 
>>> decide what to do.  If all you want is to influence the existing 
>>> heuristics, that seems like too much work.
>> You're talking about something like 5 lines of code, plus the predicate 
>> deciding whether to inline it or not (which you'd need anyway).
> That's 5 more lines than if you simply wanted to influence the inlining 
> heuristics.

And potentially hundreds of lines elsewhere, that are much more complex.

>>> (3) If multiple passes want such control, this would end up duplicating 
>>> the driver code.
>> Again, this is a trivial amount of code.
> I don't agree.

5 lines isn't trivial?

>> Giving passes the ability to modify the heuristics used by the inliner 
>> would significantly dwarf this in both amount of code and complexity.
> Again, I don't agree.  I looked at the getInlineCost(const CallSite& CS) 
> function.  It has a dozen or more embedded constants in it.  If those used 
> symbolic constant indexes into a cost table, any tool could influence the 
> heuristics simply by changing the values in the table, which (it seems to me) 
> would be simple and intuitive.

where would this table live?  Who would maintain it?  When function are 
added and deleted from the program, who updates the table?  Do you propose 
all of the optimizations (which touch functions) the linker, the assembler 
and disassembler, the .ll and .bc formats all be updated to support this 

Again, 5 lines of code is trivial compared to the alternative.

>> What are you really trying to do here?  Can you provide an example?
> I was just trying to help John by following up on his issue.

Without concrete details to discuss, you're just making hypothetical 
arguments.  Please give me an example so I can understand the problem you 
are trying to solve.



More information about the llvm-dev mailing list