[LLVMdev] <badref> showed up when duplicating a list of dependent instructions
Duncan Sands
baldrick at free.fr
Mon May 9 08:13:26 PDT 2011
Hi Chuck,
> std::vector<Instruction *>::iterator p;
> Instruction * pi = PREVIOUS_POSITION;
> BasicBlock * pb = PREVIOUS_POSITION->getParent();
>
> for(p = coll.begin(); p != coll.end(); ++p){
> Instruction * CurI = * p;
> Instruction * CloneI = CurI->clone();
clone doesn't know have any magical way of knowing that it should update the
instruction's operands to point to the clone you created earlier. For example,
consider
%l = load i32* @ins_h, align 4
%s = shl i32 %l, 5
You clone %l, getting:
%lc = load i32* @ins_h, align 4
You clone %s, getting:
%sc = shl i32 %l, 5
But %sc still has %l as an operand. You want it to have %lc as an
operand, which requires doing more.
Ciao, Duncan.
> CloneI->setName(CurI->getName());
> errs() << *CloneI << "\n";
> pb->getInstList().insertAfter(pi, CloneI); // Inserts newInst after pi in pb
>
> // adjust pi: point to the newly inserted inst:
> pi = CurI;
>
> }//end of for loop on p
>
>
> However, I got the following errors:
>
> --- Insert New (cloned) Instructions: ...
> <badref> = load i32* @strstart, align 4
> <badref> = add i32<badref>, 2
> <badref> = load i32* @ins_h, align 4
> <badref> = getelementptr inbounds [65536 x i8]* @window, i32 0, i32<badref>
> <badref> = shl i32<badref>, 5
> <badref> = load i8*<badref>, align 1
> %.masked = and i32<badref>, 32736
> <badref> = zext i8<badref> to i32
> <badref> = xor i32<badref>, %.masked
> %.sum73 = or i32<badref>, 32768
> <badref> = getelementptr inbounds [65536 x i16]* @prev, i32 0, i32 %.sum73
> %take_addr2 = getelementptr i16*<badref>
> <badref> = bitcast i16* %take_addr2 to i8*
> call void @bkp_memory(i8*<badref>, i32 2)
> Instruction does not dominate all uses!
> %95 = add i32 %93, 2
> %90 = getelementptr inbounds [65536 x i8]* @window, i32 0, i32 %95
> Instruction does not dominate all uses!
> %97 = getelementptr inbounds [65536 x i8]* @window, i32 0, i32 %95
> %92 = load i8* %97, align 1
> Instruction does not dominate all uses!
> %.masked = and i32 %91, 32736
> %101 = xor i32 %100, %.masked
> Broken module found, compilation aborted!
>
>
> What am I doing wrong here?
> Does the<badref> sound alarm to anyone?
> What is the right approach I should take here?
>
>
> Thank you very much
>
> Chuck
>
>
>
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list