diff options
author | Philip Reames <listmail@philipreames.com> | 2022-01-10 09:50:01 -0800 |
---|---|---|
committer | Philip Reames <listmail@philipreames.com> | 2022-01-10 15:43:39 -0800 |
commit | 5265ac72c6686d73edcf5de37b019b64c814d00c (patch) | |
tree | 44b8376e7aad9a6250d9a6c3184d2830330b69b9 /llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | |
parent | 38b30eb2b218ad481855d5c691ef4501711ca3a6 (diff) | |
download | llvm-5265ac72c6686d73edcf5de37b019b64c814d00c.zip llvm-5265ac72c6686d73edcf5de37b019b64c814d00c.tar.gz llvm-5265ac72c6686d73edcf5de37b019b64c814d00c.tar.bz2 |
[MemoryBuiltin] Add an API for checking if an unused allocation can be removed [NFC]
Not all allocation functions are removable if unused. An example of a non-removable allocation would be a direct call to the replaceable global allocation function in C++. An example of a removable one - at least according to historical practice - would be malloc.
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index 7904242..22c736f 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -2761,7 +2761,8 @@ Instruction *InstCombinerImpl::visitCallBase(CallBase &Call) { Call, Builder.CreateBitOrPointerCast(ReturnedArg, CallTy)); } - if (isAllocLikeFn(&Call, &TLI)) + if (isAllocationFn(&Call, &TLI) && + isAllocRemovable(&cast<CallBase>(Call), &TLI)) return visitAllocSite(Call); // Handle intrinsics which can be used in both call and invoke context. |