Skip to content

Commit d18bb24

Browse files
committed
[Attributor][NFC] Do not create temporary maps during lookup
The AAMap.lookup() call created a temporary value if the key was not present. Since the value was another map it was not free to create it. Instead of a lookup we now use find and compare the result against the end iterator explicitly. The result is the same but we never need to create a temporary map.
1 parent e5d666d commit d18bb24

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/include/llvm/Transforms/IPO/Attributor.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,9 +1195,11 @@ struct Attributor {
11951195

11961196
// Lookup the abstract attribute of type AAType. If found, return it after
11971197
// registering a dependence of QueryingAA on the one returned attribute.
1198-
const auto &KindToAbstractAttributeMap = AAMap.lookup(IRP);
1198+
auto KindToAbstractAttributeMapIt = AAMap.find(IRP);
1199+
if ( KindToAbstractAttributeMapIt == AAMap.end())
1200+
return nullptr;
11991201
if (AAType *AA = static_cast<AAType *>(
1200-
KindToAbstractAttributeMap.lookup(&AAType::ID))) {
1202+
KindToAbstractAttributeMapIt->second.lookup(&AAType::ID))) {
12011203
// Do not register a dependence on an attribute with an invalid state.
12021204
if (TrackDependence && AA->getState().isValidState())
12031205
recordDependence(*AA, const_cast<AbstractAttribute &>(*QueryingAA),

0 commit comments

Comments
 (0)