Fixed nondeterminism in RuleMatcher::emit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303829 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Galina Kistanova 2017-05-25 01:51:53 +00:00
parent c62411d859
commit ebc10e3a25

View File

@ -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<StringRef, 2> 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