diff --git a/utils/TableGen/AsmMatcherEmitter.cpp b/utils/TableGen/AsmMatcherEmitter.cpp index 7318c6d109e..e808661b7a5 100644 --- a/utils/TableGen/AsmMatcherEmitter.cpp +++ b/utils/TableGen/AsmMatcherEmitter.cpp @@ -273,9 +273,17 @@ public: return true; // ... or if any of its super classes are a subset of RHS. - for (const ClassInfo *CI : SuperClasses) - if (CI->isSubsetOf(RHS)) + SmallVector Worklist(SuperClasses.begin(), + SuperClasses.end()); + SmallPtrSet 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; }