[PATCH] D49124: [Tablegen] Optimize isSubsetOf() in AsmMatcherEmitter.cpp

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 13 09:41:31 PDT 2018


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL337020: [Tablegen] Optimize isSubsetOf() in AsmMatcherEmitter.cpp. NFC (authored by mggm, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D49124?vs=154759&id=155413#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49124

Files:
  llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp


Index: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
===================================================================
--- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
+++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
@@ -273,9 +273,17 @@
       return true;
 
     // ... or if any of its super classes are a subset of RHS.
-    for (const ClassInfo *CI : SuperClasses)
-      if (CI->isSubsetOf(RHS))
+    SmallVector<const ClassInfo *, 16> Worklist(SuperClasses.begin(),
+                                                SuperClasses.end());
+    SmallPtrSet<const ClassInfo *, 16> Visited;
+    while (!Worklist.empty()) {
+      auto *CI = Worklist.pop_back_val();
+      if (CI == &RHS)
         return true;
+      for (auto *Super : CI->SuperClasses)
+        if (Visited.insert(Super).second)
+          Worklist.push_back(Super);
+    }
 
     return false;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49124.155413.patch
Type: text/x-patch
Size: 881 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180713/0eaefb5c/attachment.bin>


More information about the llvm-commits mailing list