[LLVMdev] insertions with inst_iterators?

ret val retval386 at gmail.com
Mon Aug 29 12:38:41 PDT 2011


I am looping through all instructions in a Function and depending on
what I found I may or may not insert code. Despite the fact that I'm
only actually inserting *before* instruction I have a infinite loop
when I do something like below. For awhile it was simple enough to
just increment i enough times but now I need something better.

for(inst_iterator i = inst_begin(F); i != inst_end(F); ++i) {
        ...
        // possible insertions of unknown size
        ...
}

I tried storing the storing the initial iterator and reverting back to
it(along with storing the next element) and I am still left with a
infinite loop. I see some discussion online about weather insertions
with iterators in C++ is allowed period, so what is the correct way to
do something like this in LLVM? This must be a common problem.

Thank you




More information about the llvm-dev mailing list