[LLVMdev] the PartialSpecialization pass (was Re: Is there a "callback optimization"?)

Kenneth Uildriks kennethuil at gmail.com
Sat Jun 5 07:52:19 PDT 2010


Applied, with minor changes:

1. deleted[std:distance(as, ai)] creates a map entry (with a null
value if the operator[] is not the left-hand-side of an assignment
statement) if one doesn't already exist.  deleted->find returns
deleted.end() if the entry doesn't exist and doesn't change the map.
2. Included a comment to make it easy to find the spot where the
callsite is checked against the specialization.
3. Included a unit test for multiple specializations that checks each
callsite to make sure it calls the right function.

On Fri, Jun 4, 2010 at 2:39 PM, NAKAMURA Takumi <geek4civic at gmail.com> wrote:
> Good morning, Kenneth
>
> FYI,
> Here is my patch for lib/Transforms/IPO/PartialSpecialization.cpp.
> It works with my several applications but it is not widely tested.
>
> The pass had a critical bug, ... when a specialized function is created,
> all callers are modified. Even if a caller is not needed, to be malformed.
> My fix includes to examine each of callers to be modified.
>
> See also the discussion; http://llvm.org/bugs/show_bug.cgi?id=3757
>
>
> Takumi
>
>
> 2010/6/5 Kenneth Uildriks <kennethuil at gmail.com>:
>>> As the number of callsites using the same constant grows, inlining
>>> gets more expensive while specializing does not - the cost of
>>> specializing only grows with the number of unique constants combos
>>> specialized.  So cases where you'd want to specialize but not inline
>>> shouldn't be all that uncommon, and different cost calculations are
>>> needed to set the threshold.
>>>
>>> I didn't see the partial specialization pass in the docs, but I'll
>>> take a look at it now.
>>>
>>
>> Partial specialize is exactly what I need!  Thanks!
>>
>> It has a bug, though... I put in three calls using one function
>> pointer, and three calls using another function pointer, and it
>> created both specializations but changed all the callsites to use the
>> first specialization.  I'll svn update, try again, and file a bug if
>> needed.
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>
>




More information about the llvm-dev mailing list