Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug where function calls are removed #4

Open
BrookeFrank opened this issue Sep 7, 2024 · 0 comments
Open

Bug where function calls are removed #4

BrookeFrank opened this issue Sep 7, 2024 · 0 comments

Comments

@BrookeFrank
Copy link

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));
    }
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant