[LLVMdev] insertions with inst_iterators?

ret val retval386 at gmail.com
Mon Aug 29 17:50:13 PDT 2011


I insert a function call to a function I generate right before when I
find something "interesting", a assignment on a function pointer or a
call on a function pointer. So I don't think its anything inherit with
my algorithm, just my use of iterators.

I attached the main body of my loop incase anyone feels like taking a
look. When it runs it prints "here"(line 138) endlessly.

Thanks again

On Mon, Aug 29, 2011 at 7:25 PM, David Blaikie <dblaikie at gmail.com> wrote:
>
>> When I'm iterating through I only directly add BitCastInsts and a
>> single CallInst(Im assuming the functions I also created are
>> elsewhere). Unfortunately it doesnt look like theres is a good way to
>> convert between the the iterator I and a CallInst *. Am I missing
>> something?
>
> I'm not entirely sure how this relates to my explanation/suggestion.
> How does your algorithm work? If you, say, add an extra CallInst every time
> you see a call, then you're going to loop infinitely (inserting calls on the
> calls you just inserted, etc) unless you make sure you skip over everything
> you insert... that would be an algorithmic bug in your code, nothing to do
> with iterator invalidation semantics.
> Once you've got that figured out, we can see what kind of loop you'll need
> to write/how to deal with iterator invalidation.
> - David



More information about the llvm-dev mailing list