mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-22 10:29:35 +00:00
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:
parent
7e606e2e98
commit
47fc9d3366
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user