mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-09 03:56:28 +00:00
CallInst::CreateMalloc() and CallInst::CreateFree() need to create calls with correct calling convention
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86290 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
50591ab1ea
commit
82ebca15a8
@ -524,6 +524,7 @@ static Instruction *createMalloc(Instruction *InsertBefore,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
MCall->setTailCall();
|
MCall->setTailCall();
|
||||||
|
MCall->setCallingConv(MallocF->getCallingConv());
|
||||||
assert(MCall->getType() != Type::getVoidTy(BB->getContext()) &&
|
assert(MCall->getType() != Type::getVoidTy(BB->getContext()) &&
|
||||||
"Malloc has void return type");
|
"Malloc has void return type");
|
||||||
|
|
||||||
@ -572,8 +573,8 @@ static Instruction* createFree(Value* Source, Instruction *InsertBefore,
|
|||||||
const Type *VoidTy = Type::getVoidTy(M->getContext());
|
const Type *VoidTy = Type::getVoidTy(M->getContext());
|
||||||
const Type *IntPtrTy = Type::getInt8PtrTy(M->getContext());
|
const Type *IntPtrTy = Type::getInt8PtrTy(M->getContext());
|
||||||
// prototype free as "void free(void*)"
|
// 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;
|
CallInst* Result = NULL;
|
||||||
Value *PtrCast = Source;
|
Value *PtrCast = Source;
|
||||||
if (InsertBefore) {
|
if (InsertBefore) {
|
||||||
@ -586,6 +587,7 @@ static Instruction* createFree(Value* Source, Instruction *InsertBefore,
|
|||||||
Result = CallInst::Create(FreeFunc, PtrCast, "");
|
Result = CallInst::Create(FreeFunc, PtrCast, "");
|
||||||
}
|
}
|
||||||
Result->setTailCall();
|
Result->setTailCall();
|
||||||
|
Result->setCallingConv(FreeFunc->getCallingConv());
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user