[llvm] 14cb0bd - [Attributor][NFC] Replace the nested AAMap with a key pair
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Sun May 3 20:13:07 PDT 2020
Author: Johannes Doerfert
Date: 2020-05-03T22:10:47-05:00
New Revision: 14cb0bdf2b6ca0b7befbb07fe9f73dad5786f59b
URL: https://github.com/llvm/llvm-project/commit/14cb0bdf2b6ca0b7befbb07fe9f73dad5786f59b
DIFF: https://github.com/llvm/llvm-project/commit/14cb0bdf2b6ca0b7befbb07fe9f73dad5786f59b.diff
LOG: [Attributor][NFC] Replace the nested AAMap with a key pair
No functional change is intended.
---
Single run of the Attributor module and then CGSCC pass (oldPM)
for SPASS/clause.c (~10k LLVM-IR loc):
Before:
```
calls to allocation functions: 512375 (362871/s)
temporary memory allocations: 98746 (69933/s)
peak heap memory consumption: 22.54MB
peak RSS (including heaptrack overhead): 106.78MB
total memory leaked: 269.10KB
```
After:
```
calls to allocation functions: 509833 (338534/s)
temporary memory allocations: 98902 (65671/s)
peak heap memory consumption: 18.71MB
peak RSS (including heaptrack overhead): 103.00MB
total memory leaked: 269.10KB
```
Difference:
```
calls to allocation functions: -2542 (-27042/s)
temporary memory allocations: 156 (1659/s)
peak heap memory consumption: -3.83MB
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B
```
Added:
Modified:
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/Transforms/IPO/Attributor.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index 6c58e2de3844..42675f89070b 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -885,12 +885,10 @@ struct Attributor {
// Put the attribute in the lookup map structure and the container we use to
// keep track of all attributes.
const IRPosition &IRP = AA.getIRPosition();
- Kind2AAMapTy *&Kind2AA = AAMap[IRP];
- if (!Kind2AA)
- Kind2AA = new (Allocator) Kind2AAMapTy();
+ AbstractAttribute *&AAPtr = AAMap[{&AAType::ID, IRP}];
- assert(!(*Kind2AA)[&AAType::ID] && "Attribute already in map!");
- (*Kind2AA)[&AAType::ID] = &AA;
+ assert(!AAPtr && "Attribute already in map!");
+ AAPtr = &AA;
AllAbstractAttributes.push_back(&AA);
return AA;
@@ -1278,13 +1276,11 @@ struct Attributor {
// Lookup the abstract attribute of type AAType. If found, return it after
// registering a dependence of QueryingAA on the one returned attribute.
- Kind2AAMapTy *Kind2AA = AAMap.lookup(IRP);
- if (!Kind2AA)
+ AbstractAttribute *AAPtr = AAMap.lookup({&AAType::ID, IRP});
+ if (!AAPtr)
return nullptr;
- AAType *AA = static_cast<AAType *>((*Kind2AA)[&AAType::ID]);
- if (!AA)
- return nullptr;
+ AAType *AA = static_cast<AAType *>(AAPtr);
// Do not register a dependence on an attribute with an invalid state.
if (TrackDependence && AA->getState().isValidState())
@@ -1309,9 +1305,8 @@ struct Attributor {
/// on the outer level, and the addresses of the static member (AAType::ID) on
/// the inner level.
///{
- using Kind2AAMapTy =
- SmallDenseMap<const char *, AbstractAttribute *, /*InlineBuckets=*/32>;
- DenseMap<IRPosition, Kind2AAMapTy *> AAMap;
+ using AAMapKeyTy = std::pair<const char *, IRPosition>;
+ DenseMap<AAMapKeyTy, AbstractAttribute *> AAMap;
///}
/// A map from abstract attributes to the ones that queried them through calls
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index b8602538076b..71595a8e2341 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -493,11 +493,6 @@ Attributor::~Attributor() {
for (AbstractAttribute *AA : AllAbstractAttributes)
AA->~AbstractAttribute();
- // The Kind2AAMap objects are allocated via a BumpPtrAllocator, we call
- // the destructor manually.
- for (auto &It : AAMap)
- It.getSecond()->~Kind2AAMapTy();
-
// The QueryMapValueTy objects are allocated via a BumpPtrAllocator, we call
// the destructor manually.
for (auto &It : QueryMap)
More information about the llvm-commits
mailing list