Hi, I have some questions regarding outlining (extracting piece of code into a function): 1. Is there an outlining pass in llvm (IR)? I've found out CodeExtractor pass, but I'm not sure it's exactly the same idea. 2. How do I set the function name? And another question: Where do I control the execution of my pass? I'm writing a pass that first works on loops, than on a function (outlined from the loop) and then again on loops. How can I do that? Thanks and happy new year, Tehila. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141231/f424e3b4/attachment.html>
On 12/31/2014 12:49 PM, Tehila Mayzels wrote:> > Hi, > > I have some questions regarding outlining (extracting piece of code > into a function): > > 1.Is there an outlining pass in llvm (IR)? I've found out > CodeExtractor pass, but I'm not sure it’s exactly the same idea. >To my knowledge, there is not an existing outlining pass in tree. Most of the functionality to write one could probably be found in various places, but the profitability heuristics are entirely missing. One reasonable starting point might be the MergeFunctions pass.> > 2.How do I set the function name? > > And another question: > > Where do I control the execution of my pass? I'm writing a pass that > first works on loops, than on a function (outlined from the loop) and > then again on loops. > > How can I do that? >This ordering isn't a natural thing to express in LLVM's pass structure. You'll probably need to use a Module pass since that's the only type allowed to modify other functions. (A loop pass will not work for this.)> Thanks and happy new year, > > Tehila. > > > > _______________________________________________ > LLVM Developers mailing list > 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/llvm-dev/attachments/20150102/cf308c30/attachment.html>
Hi, On Fri, Jan 02, 2015 at 12:15:18PM -0800, Philip Reames wrote:> On 12/31/2014 12:49 PM, Tehila Mayzels wrote: > > Hi, > > I have some questions regarding outlining (extracting piece of code into a > function): > 1. Is there an outlining pass in llvm (IR)? I've found out CodeExtractor > pass, but I'm not sure it’s exactly the same idea. > To my knowledge, there is not an existing outlining pass in tree. Most of the > functionality to write one could probably be found in various places, but the > profitability heuristics are entirely missing. One reasonable starting point > might be the MergeFunctions pass.Appart from this, the CodeExtractor class is the basic block you're looking for.> 2. How do I set the function name?That's the `twine' parameter in the Create call. Function inherits from Value, so the setName method works fine too.> And another question: > Where do I control the execution of my pass? I'm writing a pass that > first works on loops, than on a function (outlined from the loop) and > then again on loops. > How can I do that? > This ordering isn't a natural thing to express in LLVM's pass structure. > You'll probably need to use a Module pass since that's the only type allowed to > modify other functions. (A loop pass will not work for this.)Another way to do this would be to mark the outlined functions with a specific metadata, and process only these one in the function pass. hop,
Hi Tehila, You can try to use function outlining implemented in clang. It is based on class CapturedStmt. You can try it with the the following construct: #pragma clang __debug captured <Code to be outlined> Implementation is in clang/lib/Parse/ParsePragma.cpp, StmtResult Parser::HandlePragmaCaptured() Best regards, Alexey Bataev ============Software Engineer Intel Compiler Team Intel Corp. 31.12.2014 23:49, Tehila Mayzels пишет:> > Hi, > > I have some questions regarding outlining (extracting piece of code > into a function): > > 1.Is there an outlining pass in llvm (IR)? I've found out > CodeExtractor pass, but I'm not sure it’s exactly the same idea. > > 2.How do I set the function name? > > And another question: > > Where do I control the execution of my pass? I'm writing a pass that > first works on loops, than on a function (outlined from the loop) and > then again on loops. > > How can I do that? > > Thanks and happy new year, > > Tehila. >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150113/3047bcb5/attachment.html>
Hi Alexey, Thanks a lot. I'll try it. Tehila. From: Bataev, Alexey [mailto:a.bataev at hotmail.com] Sent: Tuesday, January 13, 2015 7:07 AM To: Tehila Mayzels; llvmdev at cs.uiuc.edu Subject: Re: [LLVMdev] outlining in llvm Hi Tehila, You can try to use function outlining implemented in clang. It is based on class CapturedStmt. You can try it with the the following construct: #pragma clang __debug captured <Code to be outlined> Implementation is in clang/lib/Parse/ParsePragma.cpp, StmtResult Parser::HandlePragmaCaptured() Best regards, Alexey Bataev ============Software Engineer Intel Compiler Team Intel Corp. 31.12.2014 23:49, Tehila Mayzels пишет: Hi, I have some questions regarding outlining (extracting piece of code into a function): 1. Is there an outlining pass in llvm (IR)? I've found out CodeExtractor pass, but I'm not sure it’s exactly the same idea. 2. How do I set the function name? And another question: Where do I control the execution of my pass? I'm writing a pass that first works on loops, than on a function (outlined from the loop) and then again on loops. How can I do that? Thanks and happy new year, Tehila. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150113/28651eef/attachment.html>
Hi Tehila, You can use CodeExtractor to do function outlining. It provide you facility to extract following to a function: 1) single block 2) Series of block 3) Region node 4) Loop First it identify input and output to outlined function. Then it does actual outlining on the specified blocks. It sets input and output to functions as parameter. Also it take cares of adding a callsite. Hope this helps you. Regards, Ashutosh From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Tehila Mayzels Sent: Thursday, January 01, 2015 2:19 AM To: llvmdev at cs.uiuc.edu Subject: [LLVMdev] outlining in llvm Hi, I have some questions regarding outlining (extracting piece of code into a function): 1. Is there an outlining pass in llvm (IR)? I've found out CodeExtractor pass, but I'm not sure it's exactly the same idea. 2. How do I set the function name? And another question: Where do I control the execution of my pass? I'm writing a pass that first works on loops, than on a function (outlined from the loop) and then again on loops. How can I do that? Thanks and happy new year, Tehila. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150128/3ab25776/attachment.html>