[LLVMdev] Fwd: Improper Function::iterator increment

Pranav Kant pranav913 at gmail.com
Sun Feb 8 11:23:08 PST 2015


So, you mean to say that the above implementation is correct and should
work fine.

I initially thought that the above way is not the correct way anymore since
3.5.0 might have changed few things.

Anyways here is my dirty code I have written for my research project that I
took the above snippet from :

https://github.com/pranavk/spatial-computing/blob/master/waves.cpp#L105


On Sun, Feb 8, 2015 at 10:25 PM, David Blaikie <dblaikie at gmail.com> wrote:

> This may be difficult yo reproduce or debug without a more complete
> (though preferably minimal) test case.
> On Feb 8, 2015 8:31 AM, "Pranav Kant" <pranav913 at gmail.com> wrote:
>
>> 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/
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>
>>


-- 
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/20150209/19e3b44c/attachment.html>


More information about the llvm-dev mailing list