From: Galina Kistanova Date: Thu, 25 May 2017 01:51:53 +0000 (+0000) Subject: Fixed nondeterminism in RuleMatcher::emit. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ebc10e3a25607724b47b92f770835357fad18273;p=llvm Fixed nondeterminism in RuleMatcher::emit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303829 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/TableGen/GlobalISelEmitter.cpp b/utils/TableGen/GlobalISelEmitter.cpp index eaa89eae22a..185119c2ca4 100644 --- a/utils/TableGen/GlobalISelEmitter.cpp +++ b/utils/TableGen/GlobalISelEmitter.cpp @@ -1147,14 +1147,21 @@ void RuleMatcher::emit(raw_ostream &OS, // We must also check if it's safe to fold the matched instructions. if (InsnVariableNames.size() >= 2) { + // Invert the map to create stable ordering (by var names) + SmallVector Names; for (const auto &Pair : InsnVariableNames) { // Skip the root node since it isn't moving anywhere. Everything else is // sinking to meet it. if (Pair.first == Matchers.front().get()) continue; + Names.push_back(Pair.second); + } + std::sort(Names.begin(), Names.end()); + + for (const auto &Name : Names) { // Reject the difficult cases until we have a more accurate check. - OS << " if (!isObviouslySafeToFold(" << Pair.second + OS << " if (!isObviouslySafeToFold(" << Name << ")) return false;\n"; // FIXME: Emit checks to determine it's _actually_ safe to fold and/or