make this handle redefinition of malloc with different prototype correctly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86525 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-11-09 07:12:01 +00:00
parent 7e606e2e98
commit 47fc9d3366

View File

@ -568,8 +568,7 @@ static Instruction* createFree(Value* Source, Instruction *InsertBefore,
const Type *VoidTy = Type::getVoidTy(M->getContext());
const Type *IntPtrTy = Type::getInt8PtrTy(M->getContext());
// prototype free as "void free(void*)"
Function *FreeFunc = cast<Function>(M->getOrInsertFunction("free", VoidTy,
IntPtrTy, NULL));
Value *FreeFunc = M->getOrInsertFunction("free", VoidTy, IntPtrTy, NULL);
CallInst* Result = NULL;
Value *PtrCast = Source;
if (InsertBefore) {
@ -582,7 +581,8 @@ static Instruction* createFree(Value* Source, Instruction *InsertBefore,
Result = CallInst::Create(FreeFunc, PtrCast, "");
}
Result->setTailCall();
Result->setCallingConv(FreeFunc->getCallingConv());
if (Function *F = dyn_cast<Function>(FreeFunc))
Result->setCallingConv(F->getCallingConv());
return Result;
}