[llvm] 3ac8587 - [Attributor] Use getFreedOperand() (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 21 05:26:58 PDT 2022
Author: Nikita Popov
Date: 2022-07-21T14:26:47+02:00
New Revision: 3ac8587a2b7e8f9606f4bdb8c9c72a6bd652534e
URL: https://github.com/llvm/llvm-project/commit/3ac8587a2b7e8f9606f4bdb8c9c72a6bd652534e
DIFF: https://github.com/llvm/llvm-project/commit/3ac8587a2b7e8f9606f4bdb8c9c72a6bd652534e.diff
LOG: [Attributor] Use getFreedOperand() (NFC)
Track which operand is actually freed, to avoid the implicit
assumption that it is the first call argument.
Added:
Modified:
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 0f87d101ae09..6ea8b7cc538d 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -5798,6 +5798,8 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
struct DeallocationInfo {
/// The call that deallocates the memory.
CallBase *const CB;
+ /// The value freed by the call.
+ Value *FreedOp;
/// Flag to indicate if we don't know all objects this deallocation might
/// free.
@@ -5829,8 +5831,8 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
CallBase *CB = dyn_cast<CallBase>(&I);
if (!CB)
return true;
- if (isFreeCall(CB, TLI)) {
- DeallocationInfos[CB] = new (A.Allocator) DeallocationInfo{CB};
+ if (Value *FreedOp = getFreedOperand(CB, TLI)) {
+ DeallocationInfos[CB] = new (A.Allocator) DeallocationInfo{CB, FreedOp};
return true;
}
// To do heap to stack, we need to know that the allocation itself is
@@ -6104,7 +6106,7 @@ ChangeStatus AAHeapToStackFunction::updateImpl(Attributor &A) {
continue;
// Use the non-optimistic version to get the freed object.
- Value *Obj = getUnderlyingObject(DI.CB->getArgOperand(0));
+ Value *Obj = getUnderlyingObject(DI.FreedOp);
if (!Obj) {
LLVM_DEBUG(dbgs() << "[H2S] Unknown underlying object for free!\n");
DI.MightFreeUnknownObjects = true;
More information about the llvm-commits
mailing list