[LLVMdev] get LPPassManager to use it in llvm::CloneLoop
Jimborean Alexandra
xinfinity_a at yahoo.com
Wed Jun 15 03:20:53 PDT 2011
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>
More information about the llvm-dev
mailing list