[InstCombine] Use getFreedOperand() (NFC)
authorNikita Popov <npopov@redhat.com>
Thu, 21 Jul 2022 12:33:55 +0000 (14:33 +0200)
committerNikita Popov <npopov@redhat.com>
Thu, 21 Jul 2022 12:33:55 +0000 (14:33 +0200)
Use getFreedOperand() instead of isFreeCall() to remove the
implicit assumption that any pointer operand to a free function
is the operand being freed. This won't actually matter until we
handle allockind(free).

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

index cae7358..f401a1e 100644 (file)
@@ -2801,7 +2801,8 @@ static bool isAllocSiteRemovable(Instruction *AI,
           continue;
         }
 
-        if (isFreeCall(I, &TLI) && getAllocationFamily(I, &TLI) == Family) {
+        if (getFreedOperand(cast<CallBase>(I), &TLI) == PI &&
+            getAllocationFamily(I, &TLI) == Family) {
           assert(Family);
           Users.emplace_back(I);
           continue;