}
}
MCall->setTailCall();
+ MCall->setCallingConv(MallocF->getCallingConv());
assert(MCall->getType() != Type::getVoidTy(BB->getContext()) &&
"Malloc has void return type");
const Type *VoidTy = Type::getVoidTy(M->getContext());
const Type *IntPtrTy = Type::getInt8PtrTy(M->getContext());
// prototype free as "void free(void*)"
- Constant *FreeFunc = M->getOrInsertFunction("free", VoidTy, IntPtrTy, NULL);
-
+ Function *FreeFunc = cast<Function>(M->getOrInsertFunction("free", VoidTy,
+ IntPtrTy, NULL));
CallInst* Result = NULL;
Value *PtrCast = Source;
if (InsertBefore) {
Result = CallInst::Create(FreeFunc, PtrCast, "");
}
Result->setTailCall();
+ Result->setCallingConv(FreeFunc->getCallingConv());
return Result;
}