[llvm] 4308fdf - [Attributor] Remove more non-deterministic behavior and debug output
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 17 15:42:59 PDT 2022
Author: Johannes Doerfert
Date: 2022-03-17T17:42:32-05:00
New Revision: 4308fdf83b6cb0659a5dc4deb248d07892d269cd
URL: https://github.com/llvm/llvm-project/commit/4308fdf83b6cb0659a5dc4deb248d07892d269cd
DIFF: https://github.com/llvm/llvm-project/commit/4308fdf83b6cb0659a5dc4deb248d07892d269cd.diff
LOG: [Attributor] Remove more non-deterministic behavior and debug output
Added:
Modified:
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 4b020dedc70de..76704f817d650 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -3095,8 +3095,12 @@ raw_ostream &llvm::operator<<(raw_ostream &OS,
OS << " [" << Acc.getKind() << "] " << *Acc.getRemoteInst();
if (Acc.getLocalInst() != Acc.getRemoteInst())
OS << " via " << *Acc.getLocalInst();
- if (Acc.getContent().hasValue())
- OS << " [" << *Acc.getContent() << "]";
+ if (Acc.getContent().hasValue()) {
+ if (*Acc.getContent())
+ OS << " [" << **Acc.getContent() << "]";
+ else
+ OS << " [ <unknown> ]";
+ }
return OS;
}
///}
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index a2d50093aeb86..79e8a1688a2cf 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -11,6 +11,7 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/ADT/SetVector.h"
#include "llvm/Transforms/IPO/Attributor.h"
#include "llvm/ADT/APInt.h"
@@ -5844,7 +5845,7 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
bool HasPotentiallyFreeingUnknownUses = false;
/// The set of free calls that use this allocation.
- SmallPtrSet<CallBase *, 1> PotentialFreeCalls{};
+ SmallSetVector<CallBase *, 1> PotentialFreeCalls{};
};
struct DeallocationInfo {
@@ -5856,7 +5857,7 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
bool MightFreeUnknownObjects = false;
/// The set of allocation calls that are potentially freed.
- SmallPtrSet<CallBase *, 1> PotentialAllocationCalls{};
+ SmallSetVector<CallBase *, 1> PotentialAllocationCalls{};
};
AAHeapToStackFunction(const IRPosition &IRP, Attributor &A)
@@ -5866,9 +5867,9 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
// Ensure we call the destructor so we release any memory allocated in the
// sets.
for (auto &It : AllocationInfos)
- It.getSecond()->~AllocationInfo();
+ It.second->~AllocationInfo();
for (auto &It : DeallocationInfos)
- It.getSecond()->~DeallocationInfo();
+ It.second->~DeallocationInfo();
}
void initialize(Attributor &A) override {
@@ -5942,7 +5943,8 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
bool isAssumedHeapToStack(const CallBase &CB) const override {
if (isValidState())
- if (AllocationInfo *AI = AllocationInfos.lookup(&CB))
+ if (AllocationInfo *AI =
+ AllocationInfos.lookup(const_cast<CallBase *>(&CB)))
return AI->Status != AllocationInfo::INVALID;
return false;
}
@@ -6091,11 +6093,11 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
/// Collection of all malloc-like calls in a function with associated
/// information.
- DenseMap<CallBase *, AllocationInfo *> AllocationInfos;
+ MapVector<CallBase *, AllocationInfo *> AllocationInfos;
/// Collection of all free-like calls in a function with associated
/// information.
- DenseMap<CallBase *, DeallocationInfo *> DeallocationInfos;
+ MapVector<CallBase *, DeallocationInfo *> DeallocationInfos;
ChangeStatus updateImpl(Attributor &A) override;
};
@@ -9866,10 +9868,10 @@ struct AAFunctionReachabilityFunction : public AAFunctionReachability {
/// Used to answer if a call base inside this function can reach a specific
/// function.
- DenseMap<const CallBase *, QueryResolver> CBQueries;
+ MapVector<const CallBase *, QueryResolver> CBQueries;
/// This is for instruction queries than scan "forward".
- DenseMap<const Instruction *, QueryResolver> InstQueries;
+ MapVector<const Instruction *, QueryResolver> InstQueries;
};
} // namespace
More information about the llvm-commits
mailing list