1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00

[Tablegen] Optimize isSubsetOf() in AsmMatcherEmitter.cpp. NFC

isSubsetOf() could be very slow if the hierarchy of the RegisterClasses
of the target is very complicated.
This is mainly caused by the fact that isSubset() is called
multiple times over the same SuperClass of a register class
if this ends up being the super class of a register class
from multiple paths.

Differential Revision: https://reviews.llvm.org/D49124

llvm-svn: 337020
This commit is contained in:
Marcello Maggioni 2018-07-13 16:36:14 +00:00
parent 4326077713
commit ef4dbb7d5f

View File

@ -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<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;
}