[PATCH] D103556: [Attributor] Allow lookupAAFor to return null on invalid state

Joseph Huber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 4 09:29:40 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG8bb713207d2c: [Attributor] Allow lookupAAFor to return null on invalid state (authored by jhuber6).

Changed prior to commit:
  https://reviews.llvm.org/D103556?vs=349396&id=349896#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103556/new/

https://reviews.llvm.org/D103556

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


Index: llvm/include/llvm/Transforms/IPO/Attributor.h
===================================================================
--- llvm/include/llvm/Transforms/IPO/Attributor.h
+++ llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -1137,7 +1137,8 @@
     if (!shouldPropagateCallBaseContext(IRP))
       IRP = IRP.stripCallBaseContext();
 
-    if (AAType *AAPtr = lookupAAFor<AAType>(IRP, QueryingAA, DepClass)) {
+    if (AAType *AAPtr = lookupAAFor<AAType>(IRP, QueryingAA, DepClass,
+                                            /* AllowInvalidState */ true)) {
       if (ForceUpdate && Phase == AttributorPhase::UPDATE)
         updateAA(*AAPtr);
       return *AAPtr;
@@ -1218,12 +1219,13 @@
                                     DepClassTy::NONE);
   }
 
-  /// Return the attribute of \p AAType for \p IRP if existing. This also allows
-  /// non-AA users lookup.
+  /// Return the attribute of \p AAType for \p IRP if existing and valid. This
+  /// also allows non-AA users lookup.
   template <typename AAType>
   AAType *lookupAAFor(const IRPosition &IRP,
                       const AbstractAttribute *QueryingAA = nullptr,
-                      DepClassTy DepClass = DepClassTy::OPTIONAL) {
+                      DepClassTy DepClass = DepClassTy::OPTIONAL,
+                      bool AllowInvalidState = false) {
     static_assert(std::is_base_of<AbstractAttribute, AAType>::value,
                   "Cannot query an attribute with a type not derived from "
                   "'AbstractAttribute'!");
@@ -1240,6 +1242,10 @@
         AA->getState().isValidState())
       recordDependence(*AA, const_cast<AbstractAttribute &>(*QueryingAA),
                        DepClass);
+
+    // Return nullptr if this attribute has an invalid state.
+    if (!AllowInvalidState && !AA->getState().isValidState())
+      return nullptr;
     return AA;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103556.349896.patch
Type: text/x-patch
Size: 1861 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210604/abfe9470/attachment.bin>


More information about the llvm-commits mailing list