[llvm] 3736a49 - [IPO] Use std::array for AccessKind2Accesses (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 23 15:48:03 PDT 2022
Author: Kazu Hirata
Date: 2022-07-23T15:47:53-07:00
New Revision: 3736a498d48c1a41de5a3a3966477c9ce627088d
URL: https://github.com/llvm/llvm-project/commit/3736a498d48c1a41de5a3a3966477c9ce627088d
DIFF: https://github.com/llvm/llvm-project/commit/3736a498d48c1a41de5a3a3966477c9ce627088d.diff
LOG: [IPO] Use std::array for AccessKind2Accesses (NFC)
Switching to std:array allow us to use fill.
While I am at it, this patch also converts one for loop to a
range-based one.
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 45a0115ae982c..660ff3ee95636 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -7513,16 +7513,15 @@ struct AAMemoryLocationImpl : public AAMemoryLocation {
AAMemoryLocationImpl(const IRPosition &IRP, Attributor &A)
: AAMemoryLocation(IRP, A), Allocator(A.Allocator) {
- for (unsigned u = 0; u < llvm::CTLog2<VALID_STATE>(); ++u)
- AccessKind2Accesses[u] = nullptr;
+ AccessKind2Accesses.fill(nullptr);
}
~AAMemoryLocationImpl() {
// The AccessSets are allocated via a BumpPtrAllocator, we call
// the destructor manually.
- for (unsigned u = 0; u < llvm::CTLog2<VALID_STATE>(); ++u)
- if (AccessKind2Accesses[u])
- AccessKind2Accesses[u]->~AccessSet();
+ for (AccessSet *AS : AccessKind2Accesses)
+ if (AS)
+ AS->~AccessSet();
}
/// See AbstractAttribute::initialize(...).
@@ -7690,7 +7689,7 @@ struct AAMemoryLocationImpl : public AAMemoryLocation {
/// Mapping from *single* memory location kinds, e.g., LOCAL_MEM with the
/// value of NO_LOCAL_MEM, to the accesses encountered for this memory kind.
using AccessSet = SmallSet<AccessInfo, 2, AccessInfo>;
- AccessSet *AccessKind2Accesses[llvm::CTLog2<VALID_STATE>()];
+ std::array<AccessSet *, llvm::CTLog2<VALID_STATE>()> AccessKind2Accesses;
/// Categorize the pointer arguments of CB that might access memory in
/// AccessedLoc and update the state and access map accordingly.
More information about the llvm-commits
mailing list