mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-24 04:09:45 +00:00
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:
parent
c62411d859
commit
ebc10e3a25
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user