[LLVMdev] Fwd: Improper Function::iterator increment

Pranav Kant pranav913 at gmail.com
Sun Feb 8 08:28:29 PST 2015


void Wave::init (const Function &F){
    Function::const_iterator ie = F.end();
    outs() << ie << "\n\n";
    for (Function::const_iterator I = F.begin(), IE = F.end(); I != IE;
I++, K++){
       outs() << I << "\n";
       // some manipulation with I
    }
}

I used the above shown function in my pass in LLVM 3.4.2 and it used to
work fine but when I am compiling this pass with 3.5.0, this is a never
ending loop. Can someone please suggest me what can be wrong here ?

Upon some debugging, I found out that const_iterator I never becomes equal
to IE, rather it goes past IE when incremented and hence loop never ends.

Following is the output upon executing above code.

0x2e08248 <- address of ie
0x2e16630 <- address of I initially
0x2e08250 <- incremented I
0x2e165e0
0x2e16630
0x2e08250
0x2e165e0
0x2e16630
0x2e08250



-- 
Regards,
Pranav Kant,
Department of Computer Science
National Institute of Technology Hamirpur
http://pricked.in/



-- 
Regards,
Pranav Kant,
Department of Computer Science
National Institute of Technology Hamirpur
http://pricked.in/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150208/064c1e7a/attachment.html>


More information about the llvm-dev mailing list