Skip to content

Bug where function calls are removed #4

Description

@BrookeFrank

Hi,
We found a problem with the handling of the call instruction in this place, where the type of argument to the calling function is changed, but the call instruction is removed in the end.

    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));
    }
  }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions