[PATCH] D123054: InstructionCombining: merge realloc and free handling

Augie Fackler via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 4 10:46:00 PDT 2022


durin42 created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
durin42 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

As best I can tell, all this code _actually_ cares about is that it's a
function from an allocator family, not that it's specifically realloc or
free (which are the only options anyway). We can check for the allocator
family instead of looking at "is realloc like" and "is free like"
separately. The downside is that we need to add the free() codepath to
the work list, but since it returns nothing that should be
inconsequential in terms of cost.

Depends on D123053 <https://reviews.llvm.org/D123053>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123054

Files:
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp


Index: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -2744,15 +2744,7 @@
           continue;
         }
 
-        if (isFreeCall(I, &TLI) && getAllocationFamily(I, &TLI) == Family) {
-          assert(Family);
-          Users.emplace_back(I);
-          continue;
-        }
-
-        if (isReallocLikeFn(I, &TLI) &&
-            getAllocationFamily(I, &TLI) == Family) {
-          assert(Family);
+        if (Family && getAllocationFamily(I, &TLI) == Family) {
           Users.emplace_back(I);
           Worklist.push_back(I);
           continue;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123054.420237.patch
Type: text/x-patch
Size: 761 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220404/880056bc/attachment.bin>


More information about the llvm-commits mailing list