Reputation: 400
In a Function iterator loop when i put the following code
for(BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE; ++BI)
{
if(isa<StoreInst>(&(*BI)) )
{
if(i==0)
{
Value *Two = ConstantInt::get(Type::getInt32Ty(Context), 2);
Value *Three = ConstantInt::get(Type::getInt32Ty(Context), 3);
Instruction *Add = BinaryOperator::Create(Instruction::Add, Two, Three,"addresult",(Instruction*)BI);
i=1;
}
}
}
then i am getting error(while applying this pass on the following input.bc file it is input.ll of that input.bc file
define void @_Z3minv() #0 {
entry:
%k = alloca i32, align 4
%i = alloca i32, align 4
%j = alloca i32, align 4
store i32 10, i32* %i, align 4
store i32 5, i32* %j, align 4
%0 = load i32* %i, align 4
%1 = load i32* %j, align 4
%add = add nsw i32 %0, %1
store i32 %add, i32* %k, align 4
ret void}
with the command opt -load ../Release+Asserts/lib/Testing.so -insert (insert is my pass name) I am getting:- while deleting i32 use still stuck around after Def is destroyed : %addresult =add i32 2, 3
can anyone please explain what is happening here .
Upvotes: 0
Views: 681
Reputation: 618
Usually I get these when something is not fully attached to a module. Either the created instructions are not in a block or a block is not in a function or a function is not in a module. Basically it was not reachable when deleting.
Upvotes: 1