llvm.org GIT mirror llvm / 4a3935c
A dead malloc, a free(NULL) and a free(undef) are all trivially dead instructions. This doesn't introduce any optimizations we weren't doing before (except potentially due to pass ordering issues), now passes will eliminate them sooner as part of their own cleanups. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142787 91177308-0d34-0410-b5e6-96231b3b80d8 Nick Lewycky 8 years ago
2 changed file(s) with 9 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
2727 #include "llvm/Analysis/DIBuilder.h"
2828 #include "llvm/Analysis/Dominators.h"
2929 #include "llvm/Analysis/InstructionSimplify.h"
30 #include "llvm/Analysis/MemoryBuiltins.h"
3031 #include "llvm/Analysis/ProfileInfo.h"
3132 #include "llvm/Analysis/ValueTracking.h"
3233 #include "llvm/Target/TargetData.h"
256257 II->getIntrinsicID() == Intrinsic::lifetime_end)
257258 return isa(II->getArgOperand(1));
258259 }
260
261 if (extractMallocCall(I)) return true;
262
263 if (CallInst *CI = isFreeCall(I))
264 if (Constant *C = dyn_cast(CI->getArgOperand(0)))
265 return C->isNullValue() || isa(C);
266
259267 return false;
260268 }
261269
256256 ret void
257257 }
258258 ; CHECK: @test20
259 ; CHECK-NOT: store
260 ; CHECK: ret void
259 ; CHECK-NEXT: ret void