Jimborean Alexandra
2011-Jun-15 10:20 UTC
[LLVMdev] get LPPassManager to use it in llvm::CloneLoop
Thanks , your suggestion was welcome and CloneLoop works without passing the LPPassManager. However, I reached another problem. When the loop to be cloned has some subloops, the subloops are not properly cloned. Some clones of the clones are created and the CFG between the cloned basic blocks of the subloops is not correctly built. There are clones like for.body.clone, for.body.clone1, for.body.clone2, ... for.body.clone26 without any predecessor and for.body.clone27, for.body.clone28 .. which are included in the CFG. To be sure I did not mess up the code of CloneLoop I checked also the original version of the function (which requires LPPassManager as parameter), but the output is the same. How can I use the CloneLoop function to clone a loop nest? Thank you. Alexandra ________________________________ From: Eli Friedman <eli.friedman at gmail.com> To: Jimborean Alexandra <xinfinity_a at yahoo.com> Cc: llvmdev at cs.uiuc.edu Sent: Mon, May 9, 2011 4:48:29 PM Subject: Re: [LLVMdev] get LPPassManager to use it in llvm::CloneLoop On Mon, May 9, 2011 at 1:06 AM, Jimborean Alexandra <xinfinity_a at yahoo.com> wrote:> Hi, > > I try to write a FunctionPass that, among other tasks, has to clone some > loops from the current function. > How can I obtain the LPPassManager in order to use the CloneLoop function. > In a LoopPass this is a parameter for the runOnLoop, but how can I obtain it > in a FunctionPass? > I tried simply by creating a new instance : > > ValueMap<const Value *, Value* > VMap; > LoopInfo *LI = &getAnalysis<LoopInfo>(); > LPPassManager *LPM = new llvm::LPPassManager(1); > > Loop* nL = llvm::CloneLoop(L, LPM, LI, VMap, this); > > but it segfaults in CloneLoop when trying LPM->insertLoop(..).CloneLoop isn't fundamentally dependent on a LPPassManager, but it looks like you have to pass one in at the moment; you might need to mess with the implementation of llvm::CloneLoop (in CloneLoop.cpp) a bit so that passing in null for the LPM argument works correctly.> Does the CloneLoop function include both loops in the CFG and re-create the > use map between the clones? > Also does it update the phi nodes to use either the original or the cloned > values?CloneLoop essentially puts in a copy of the loop, and doesn't mess with anything outside of the loop. You have to fix up everything else to fit together properly yourself. Note that the "LCSSA" pass helps a lot here, but I don't recall if requiring it from a FunctionPass works properly. -Eli -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110615/ec6ab5cb/attachment.html>
Eli Friedman
2011-Jun-15 20:11 UTC
[LLVMdev] get LPPassManager to use it in llvm::CloneLoop
On Wed, Jun 15, 2011 at 3:20 AM, Jimborean Alexandra <xinfinity_a at yahoo.com> wrote:> Thanks , your suggestion was welcome and CloneLoop works without passing the > LPPassManager. > > However, I reached another problem. When the loop to be cloned has some > subloops, the subloops are not properly cloned. Some clones of the clones > are created and the CFG between the cloned basic blocks of the subloops is > not correctly built. There are clones like for.body.clone, for.body.clone1, > for.body.clone2, ... for.body.clone26 without any predecessor and > for.body.clone27, for.body.clone28 .. which are included in the CFG. > > To be sure I did not mess up the code of CloneLoop I checked also the > original version of the function (which requires LPPassManager as > parameter), but the output is the same. How can I use the CloneLoop function > to clone a loop nest?I would like to point you to a code example, but then I realized nothing in the LLVM codebase actually uses CloneLoop. So I'm not surprised it's broken... sorry about that. For an actually working piece of code that clones a loop, try LoopUnswitch::UnswitchNontrivialCondition in lib/Transforms/Scalar/LoopUnswitch.cpp. -Eli
Duncan Sands
2011-Jun-16 08:10 UTC
[LLVMdev] get LPPassManager to use it in llvm::CloneLoop
Hi Eli,> I would like to point you to a code example, but then I realized > nothing in the LLVM codebase actually uses CloneLoop. So I'm not > surprised it's broken... sorry about that.maybe CloneLoop should be removed then? Ciao, Duncan.
Possibly Parallel Threads
- [LLVMdev] get LPPassManager to use it in llvm::CloneLoop
- [LLVMdev] get LPPassManager to use it in llvm::CloneLoop
- [LLVMdev] get LPPassManager to use it in llvm::CloneLoop
- [LLVMdev] get LPPassManager to use it in llvm::CloneLoop
- How to make ScalarEvolution recompute SCEV values?