[llvm] d18bb24 - [Attributor][NFC] Do not create temporary maps during lookup

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 16 00:34:06 PDT 2020


Author: Johannes Doerfert
Date: 2020-04-16T02:32:31-05:00
New Revision: d18bb247492face84966f6c1c32e479e5e026f1d

URL: https://github.com/llvm/llvm-project/commit/d18bb247492face84966f6c1c32e479e5e026f1d
DIFF: https://github.com/llvm/llvm-project/commit/d18bb247492face84966f6c1c32e479e5e026f1d.diff

LOG: [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.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index a4b0c6a605e7..2363a74d211b 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -1195,9 +1195,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.
-    const auto &KindToAbstractAttributeMap = AAMap.lookup(IRP);
+    auto KindToAbstractAttributeMapIt = AAMap.find(IRP);
+    if ( KindToAbstractAttributeMapIt == AAMap.end())
+      return nullptr;
     if (AAType *AA = static_cast<AAType *>(
-            KindToAbstractAttributeMap.lookup(&AAType::ID))) {
+            KindToAbstractAttributeMapIt->second.lookup(&AAType::ID))) {
       // Do not register a dependence on an attribute with an invalid state.
       if (TrackDependence && AA->getState().isValidState())
         recordDependence(*AA, const_cast<AbstractAttribute &>(*QueryingAA),


        


More information about the llvm-commits mailing list