mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-29 22:50:47 +00:00
Add C++ global operator {new,new[],delete,delete[]}(unsigned {int,long}) to the
memory builtins as equivalent to malloc/free. This is different from any attribute we have. For example, you can delete the allocators when their result is unused, but you can't collapse two calls to the same function, even if no global/memory state has changed in between. The noalias return states that the result does not alias any other pointer, but instcombine optimizes malloc() as though the result is non-null for the purpose of eliminating unused pointers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127673 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d158fba3e4
commit
42e72ca3d0
@ -35,7 +35,11 @@ static bool isMallocCall(const CallInst *CI) {
|
||||
return false;
|
||||
|
||||
Function *Callee = CI->getCalledFunction();
|
||||
if (Callee == 0 || !Callee->isDeclaration() || Callee->getName() != "malloc")
|
||||
if (Callee == 0 || !Callee->isDeclaration())
|
||||
return false;
|
||||
if (Callee->getName() != "malloc" &&
|
||||
Callee->getName() != "_Znwj" && Callee->getName() != "_Znwm" &&
|
||||
Callee->getName() != "_Znaj" && Callee->getName() != "_Znam")
|
||||
return false;
|
||||
|
||||
// Check malloc prototype.
|
||||
@ -189,7 +193,12 @@ const CallInst *llvm::isFreeCall(const Value *I) {
|
||||
if (!CI)
|
||||
return 0;
|
||||
Function *Callee = CI->getCalledFunction();
|
||||
if (Callee == 0 || !Callee->isDeclaration() || Callee->getName() != "free")
|
||||
if (Callee == 0 || !Callee->isDeclaration())
|
||||
return 0;
|
||||
|
||||
if (Callee->getName() != "free" &&
|
||||
Callee->getName() != "_Zdlj" && Callee->getName() != "_Zdlm" &&
|
||||
Callee->getName() != "_Zdaj" && Callee->getName() != "_Zdam")
|
||||
return 0;
|
||||
|
||||
// Check free prototype.
|
||||
|
Loading…
Reference in New Issue
Block a user