NAKAMURA Takumi
2010-Jun-04 19:39 UTC
[LLVMdev] the PartialSpecialization pass (was Re: Is there a "callback optimization"?)
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 >-------------- next part -------------- A non-text attachment was scrubbed... Name: PartialSpecialization.diff Type: application/octet-stream Size: 3484 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100605/29f39cd6/attachment.obj>
Kenneth Uildriks
2010-Jun-05 14:52 UTC
[LLVMdev] the PartialSpecialization pass (was Re: Is there a "callback optimization"?)
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 >> >
NAKAMURA Takumi
2010-Jun-08 11:53 UTC
[LLVMdev] the PartialSpecialization pass (was Re: Is there a "callback optimization"?)
Good evening, Kenneth. Thank you to apply (and rewrite my naive code better) and to file the issue to http://llvm.org/bugs/show_bug.cgi?id=7304 I have checked r105528 at this morning. I think the pass must be still cleaned up and rewritten. There are my two proposals for enhancement. 1) To separate Specialization(and rewriting callsites) to other module. It would be better if new module were available from other passes. 2) To separate methods discovering interests. Various (optional) heuristics would be helpful. Also I will help to contribute above someday. I had been afraid to read the discussion http://llvm.org/bugs/show_bug.cgi?id=3757 I was doubtful then whether the patch might be valueless and useless :p arigato gozaimasu, Takumi 2010/6/5 Kenneth Uildriks <kennethuil at gmail.com>:> 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
Maybe Matching Threads
- [LLVMdev] the PartialSpecialization pass (was Re: Is there a "callback optimization"?)
- [LLVMdev] the PartialSpecialization pass (was Re: Is there a "callback optimization"?)
- [LLVMdev] Possible typo in LoopUnrollPass.cpp
- [LLVMdev] list of LLVM optimization passes
- [LLVMdev] list of LLVM optimization passes