Hi, I am writing a pass for constant propagation using graph restructuring ( code duplication). I am facing following difficulties.. 1) I need to replicate the basic block but without phi function in the replicated block. How can I do this. 2) I need to insert that basic block after and before some particular basic block. Regards Tarun Agrawal -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110417/47207a26/attachment.html>
On Sun, Apr 17, 2011 at 1:32 AM, tarun agrawal <tarun at cse.iitb.ac.in> wrote:> I am writing a pass for constant propagation using graph restructuring ( > code duplication). I am facing following difficulties.. > > 1) I need to replicate the basic block but without phi function in the > replicated block. How can I do this. > > 2) I need to insert that basic block after and before some particular basic > block.This sounds a lot like jump threading, so you might want to take a look at LLVM's lib/Transforms/Scalar/JumpThreading.cpp.
On Sat, Apr 16, 2011 at 4:32 PM, tarun agrawal <tarun at cse.iitb.ac.in> wrote:> Hi, > > I am writing a pass for constant propagation using graph restructuring ( > code duplication). I am facing following difficulties.. > > 1) I need to replicate the basic block but without phi function in the > replicated block. How can I do this. > > 2) I need to insert that basic block after and before some particular basic > block.You probably want to use llvm::CloneBasicBlock from Transforms/Utils/Cloning.h to get a cloned version of a block. BasicBlock::splitBasicBlock might be useful as well. -Eli
The clone llvm:CloneBasicBlock copies the phi function in the replicated basic block from the original basic block. I don't want the copy of phi in relplicated block. For now I am creating .bc file with -O0 option so that it doesn't generate phi function in first place. Is this a good approach or there are some other function available for it. Tarun On Sun, Apr 17, 2011 at 5:22 AM, Eli Friedman <eli.friedman at gmail.com>wrote:> On Sat, Apr 16, 2011 at 4:32 PM, tarun agrawal <tarun at cse.iitb.ac.in> > wrote: > > Hi, > > > > I am writing a pass for constant propagation using graph restructuring ( > > code duplication). I am facing following difficulties.. > > > > 1) I need to replicate the basic block but without phi function in the > > replicated block. How can I do this. > > > > 2) I need to insert that basic block after and before some particular > basic > > block. > > You probably want to use llvm::CloneBasicBlock from > Transforms/Utils/Cloning.h to get a cloned version of a block. > BasicBlock::splitBasicBlock might be useful as well. > > -Eli >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110417/e917db8a/attachment.html>