[LLVMdev] insert ICmpInst/BranchIns in Pass?

ret val retval386 at gmail.com
Wed Oct 12 06:11:00 PDT 2011

All I really see from this change is that I somehow created a infinite
loop. Arn't these implemented as linked lists? Shouldn't they be
stable? I am very confused. I also can't seem to find a example where
much is being add.

Thank you

On Tue, Oct 11, 2011 at 10:36 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> On Tue, Oct 11, 2011 at 7:22 PM, ret val <retval386 at gmail.com> wrote:
>> In a pass I would like to insert a ICmpInst/BranchInst pair to check
>> if 2 GlobalVariables are equal or not. If they are not I would like to
>> call a function. I've tried splitting the current block and then
>> inserting before the existing instructions, but for some reason this
>> seems to ruin the iterator(i). What is the correct way todo something
>> like this?
>> void checkShadowPtr(Module &M, Function &F, inst_iterator i,
>> GlobalVariable *shadow, Value *val) {
> inst_iterator is hiding iterators which aren't going to stay
> consistent across this kind of change.  I'd suggest explicitly using
> Function::iterator and BasicBlock::iterator to keep track of where you
> are in the function; that should make it obvious what is going wrong.
> -Eli

More information about the llvm-dev mailing list