commit | 1d9b973fd7e60e4149678a03aac762551c846f13 | [log] [tgz] |
---|---|---|
author | Duncan Sands <baldrick@free.fr> | Thu May 27 19:09:06 2010 +0000 |
committer | Duncan Sands <baldrick@free.fr> | Thu May 27 19:09:06 2010 +0000 |
tree | e002a3d6cf5b6a3049d504b189c0052caa5049e6 | |
parent | 084fb0ea3246300aa81dd2561ce4d84401b74792 [diff] [blame] |
Teach instCombine to remove malloc+free if malloc's only uses are comparisons to null. Patch by Matti Niemenmaa. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104871 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/InstCombine/InstCombineCalls.cpp b/lib/Transforms/InstCombine/InstCombineCalls.cpp index 38e7b6e..08a6ff4 100644 --- a/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -250,6 +250,8 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { if (isFreeCall(&CI)) return visitFree(CI); + if (isMalloc(&CI)) + return visitMalloc(CI); // If the caller function is nounwind, mark the call as nounwind, even if the // callee isn't.