Hi I have the followed code for which I am writing a loop pass. int main() { int i = 0; for (i=0; i<20; i++) { printf ("hello world %d\n", i); } return 0; } In the function runOnLoop, I have the following instruction PHINode *indv = NULL; indv = L->getCanonicalInductionVariable(); However, when I check indv is always set to NULL. Since the code has a canonical induction variable, I was expecting the endv to start pointing to the induction var phi node. Please let me what I'm missing here Thanks Malveeka -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110521/b305df61/attachment.html>
Hi, What does your LLVM IR look like. Are you sure the loop hasnt been optimized away? Arushi On Sat, May 21, 2011 at 5:52 PM, Malveeka Tewari <mtewari at eng.ucsd.edu>wrote:> Hi > > I have the followed code for which I am writing a loop pass. > > int main() { > int i = 0; > for (i=0; i<20; i++) { > printf ("hello world %d\n", i); > } > return 0; > } > > In the function runOnLoop, I have the following instruction > PHINode *indv = NULL; > indv = L->getCanonicalInductionVariable(); > > However, when I check indv is always set to NULL. > Since the code has a canonical induction variable, I was expecting the endv > to start pointing to the induction var phi node. > > Please let me what I'm missing here > > Thanks > Malveeka > > _______________________________________________ > 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/20110521/ad997fae/attachment.html>
Also, make sure you're running the necessary transform passes as well, I've run into this testing my analysis on unoptimized code. There are various loop/induction variable passes, and offhand I think things like -mem2reg help too. Good luck! ~Will On Sat, May 21, 2011 at 8:45 PM, Arushi Aggarwal <arushi987 at gmail.com> wrote:> Hi, > What does your LLVM IR look like. Are you sure the loop hasnt been optimized > away? > Arushi > > On Sat, May 21, 2011 at 5:52 PM, Malveeka Tewari <mtewari at eng.ucsd.edu> > wrote: >> >> Hi >> I have the followed code for which I am writing a loop pass. >> int main() { >> int i = 0; >> for (i=0; i<20; i++) { >> printf ("hello world %d\n", i); >> } >> return 0; >> } >> In the function runOnLoop, I have the following instruction >> PHINode *indv = NULL; >> indv = L->getCanonicalInductionVariable(); >> However, when I check indv is always set to NULL. >> Since the code has a canonical induction variable, I was expecting the >> endv to start pointing to the induction var phi node. >> Please let me what I'm missing here >> Thanks >> Malveeka >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >
Are you running IndVarSimplify prior to when you're asking for the inductive variable? The comment for that method (and for other inductive-like queries in LoopInfo), hints that you should run IndVarSimplify (-indvars). On Sat, May 21, 2011 at 4:52 PM, Malveeka Tewari <mtewari at eng.ucsd.edu> wrote:> Hi > I have the followed code for which I am writing a loop pass. > int main() { > int i = 0; > for (i=0; i<20; i++) { > printf ("hello world %d\n", i); > } > return 0; > } > In the function runOnLoop, I have the following instruction > PHINode *indv = NULL; > indv = L->getCanonicalInductionVariable(); > However, when I check indv is always set to NULL. > Since the code has a canonical induction variable, I was expecting the endv > to start pointing to the induction var phi node. > Please let me what I'm missing here > Thanks > Malveeka > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >
Forwarding to list :) ~Will ---------- Forwarded message ---------- From: Malveeka Tewari <mtewari at eng.ucsd.edu> Date: Sun, May 22, 2011 at 12:38 AM Subject: Re: [LLVMdev] getCanonicalInductionVariable To: willdtz at gmail.com Adding -mem2reg fixed the problem ! Thanks a lot! Malveeka On Sat, May 21, 2011 at 9:47 PM, Will Dietz <willdtz at gmail.com> wrote:> > Also, make sure you're running the necessary transform passes as well, > I've run into this testing my analysis on unoptimized code. > > There are various loop/induction variable passes, and offhand I think > things like -mem2reg help too. > > Good luck! > > ~Will > > On Sat, May 21, 2011 at 8:45 PM, Arushi Aggarwal <arushi987 at gmail.com> wrote: > > Hi, > > What does your LLVM IR look like. Are you sure the loop hasnt been optimized > > away? > > Arushi > > > > On Sat, May 21, 2011 at 5:52 PM, Malveeka Tewari <mtewari at eng.ucsd.edu> > > wrote: > >> > >> Hi > >> I have the followed code for which I am writing a loop pass. > >> int main() { > >> int i = 0; > >> for (i=0; i<20; i++) { > >> printf ("hello world %d\n", i); > >> } > >> return 0; > >> } > >> In the function runOnLoop, I have the following instruction > >> PHINode *indv = NULL; > >> indv = L->getCanonicalInductionVariable(); > >> However, when I check indv is always set to NULL. > >> Since the code has a canonical induction variable, I was expecting the > >> endv to start pointing to the induction var phi node. > >> Please let me what I'm missing here > >> Thanks > >> Malveeka > >> _______________________________________________ > >> LLVM Developers mailing list > >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >> > > > > > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > >