newTarget = newGetElementPtr;
bool is_erased = false;
if (dyn_cast<ArrayType>(newType) || dyn_cast<PointerType>(newType)) {
Type* temp_newType = getElementType(newType);
Type* temp_oldType = getElementType(oldType);
is_erased = Transformer::transform(it, newTarget, oldTarget, temp_newType, temp_oldType, alignment);
}
else if (CallInst* callInst = dyn_cast<CallInst>(*it)) {
errs() << "====a call from getElementPtr\n";
BitCastInst *bitCast = new BitCastInst(newTarget, oldGetElementPtr->getType(), "", callInst);
bitCast->dump();
for (unsigned i = 0; i < callInst->getNumOperands(); i++) {
if (callInst->getOperand(i) == oldGetElementPtr)
callInst->setArgOperand(i, bitCast);
}
}
else {
if (newType->getTypeID() != oldType->getTypeID()) {
is_erased = Transformer::transform(it, newTarget, oldTarget, newType, oldType, alignment);
}
else {
// no further changes, but make sure we don't delete instruction!
is_erased = true;
}
}
if (!is_erased) {
erase.push_back(dyn_cast<Instruction>(*it));
}
}
Hi,
We found a problem with the handling of the
callinstruction in this place, where the type of argument to the calling function is changed, but the call instruction is removed in the end.