diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2012-05-10 17:14:00 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2012-05-10 17:14:00 +0000 |
commit | e54874471cf565bbacdca69c95ae7287badc578f (patch) | |
tree | fd2341972c1f5e8d2ad3ed31ce77eaf10c4e9440 /lib/Transforms/Scalar/DeadStoreElimination.cpp | |
parent | 9777f61bfe36a53757977cd777f2b4e73fc3e8a3 (diff) | |
download | external_llvm-e54874471cf565bbacdca69c95ae7287badc578f.zip external_llvm-e54874471cf565bbacdca69c95ae7287badc578f.tar.gz external_llvm-e54874471cf565bbacdca69c95ae7287badc578f.tar.bz2 |
teach DSE and isInstructionTriviallyDead() about calloc
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156553 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/DeadStoreElimination.cpp')
-rw-r--r-- | lib/Transforms/Scalar/DeadStoreElimination.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/DeadStoreElimination.cpp b/lib/Transforms/Scalar/DeadStoreElimination.cpp index c8c5360..a46e802 100644 --- a/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -282,6 +282,12 @@ static uint64_t getPointerSize(const Value *V, AliasAnalysis &AA) { return C->getZExtValue(); } + if (const CallInst *CI = extractCallocCall(V)) { + if (const ConstantInt *C1 = dyn_cast<ConstantInt>(CI->getArgOperand(0))) + if (const ConstantInt *C2 = dyn_cast<ConstantInt>(CI->getArgOperand(1))) + return (C1->getValue() * C2->getValue()).getZExtValue(); + } + if (TD == 0) return AliasAnalysis::UnknownSize; @@ -704,9 +710,11 @@ bool DSE::handleEndBlock(BasicBlock &BB) { // Okay, so these are dead heap objects, but if the pointer never escapes // then it's leaked by this function anyways. - if (CallInst *CI = extractMallocCall(I)) - if (!PointerMayBeCaptured(CI, true, true)) - DeadStackObjects.insert(CI); + CallInst *CI = extractMallocCall(I); + if (!CI) + CI = extractCallocCall(I); + if (CI && !PointerMayBeCaptured(CI, true, true)) + DeadStackObjects.insert(CI); } // Treat byval arguments the same, stores to them are dead at the end of the @@ -759,6 +767,11 @@ bool DSE::handleEndBlock(BasicBlock &BB) { continue; } + if (CallInst *CI = extractCallocCall(BBI)) { + DeadStackObjects.erase(CI); + continue; + } + if (CallSite CS = cast<Value>(BBI)) { // If this call does not access memory, it can't be loading any of our // pointers. |