Fixes to c++ backend for new and delete
Don't include declarations of malloc/free in the generated code (get the standard ones from system headers instead). Add a cast to (uint8_t *) before calls to malloc, which C++ requires, since proper malloc returns a void *.
This commit is contained in:
@@ -2114,7 +2114,8 @@ bool CWriter::doInitialization(Module &M) {
|
|||||||
I->getName() == "memset" || I->getName() == "memset_pattern16" ||
|
I->getName() == "memset" || I->getName() == "memset_pattern16" ||
|
||||||
I->getName() == "puts" ||
|
I->getName() == "puts" ||
|
||||||
I->getName() == "printf" || I->getName() == "putchar" ||
|
I->getName() == "printf" || I->getName() == "putchar" ||
|
||||||
I->getName() == "fflush")
|
I->getName() == "fflush" || I->getName() == "malloc" ||
|
||||||
|
I->getName() == "free")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Don't redeclare ispc's own intrinsics
|
// Don't redeclare ispc's own intrinsics
|
||||||
@@ -3437,6 +3438,9 @@ void CWriter::visitCallInst(CallInst &I) {
|
|||||||
Callee = RF;
|
Callee = RF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Callee->getName() == "malloc")
|
||||||
|
Out << "(uint8_t *)";
|
||||||
|
|
||||||
if (NeedsCast) {
|
if (NeedsCast) {
|
||||||
// Ok, just cast the pointer type.
|
// Ok, just cast the pointer type.
|
||||||
Out << "((";
|
Out << "((";
|
||||||
|
|||||||
Reference in New Issue
Block a user