[LLVMdev] How to insert basic block in a loop

marwayusuf@feng.bu.edu.eg marwayusuf at feng.BU.edu.eg
Tue Jun 16 07:22:56 PDT 2015


Thanks a million. Now I managed to insert the block into the loop using the mentioned function. However I have another issue now. I've inserted a block (named foo) in the start of the loop. I want to make the predecessors of the the previous start block (for.cond) to jump to foo instead, and foo jumps to for.cond. Predecessors of for.cond are entry and for.inc. When I run my pass, only for.inc is changed, entry is not. Here is code:


          pred_iterator PI = pred_begin(loopCond), PE = pred_end(loopCond);
          while (PI != PE) {
            if((*PI)!=foo){
              BasicBlock::iterator it = (*PI)->end();
              it--;
              BranchInst *bi = dyn_cast<BranchInst>(it);
              bi->setSuccessor(0, foo);
            }
            PI++;
          }

I guessed that the problem is that entry block is not part of the loop, and this is a loop pass. So, if this is this the problem, how can I overcome? And if not, what could be the problem?



Regards,
Marwa Yusuf
Teaching Assistant - Computer Engineering Department
Faculty of Engineering - Benha University
E-JUST PhD Student
Computer Science & Engineering Dept.
________________________________
From: Philip Reames <listmail at philipreames.com>
Sent: Friday, June 12, 2015 11:55 PM
To: marwayusuf at feng.bu.edu.eg
Cc: llvmdev at cs.uiuc.edu
Subject: Re: [LLVMdev] How to insert basic block in a loop

Given lack of context in your question, it's hard to figure out what you're asking, but as a guess, I'd suggest you look at addBasicBlockToLoop on LoopBase in LoopInfo.h

Philip

On 06/12/2015 01:53 PM, marwayusuf at feng.bu.edu.eg<mailto:marwayusuf at feng.bu.edu.eg> wrote:

Dear All

I'm making a transformation pass that inserts a new basic block at the start of a loop. However when I try to change predecessor/successor relations, it does not consider the new block in the loop at all. So I got that just inserting a loop in a function before another loop is not enough. So how exactly to do this job?


Regards,
Marwa Yusuf
Teaching Assistant - Computer Engineering Department
Faculty of Engineering - Benha University
E-JUST PhD Student
Computer Science & Engineering Dept.



_______________________________________________
LLVM Developers mailing list
LLVMdev at cs.uiuc.edu<mailto: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/20150616/e3d3e973/attachment.html>


More information about the llvm-dev mailing list