summaryrefslogtreecommitdiffstats
path: root/llvm/utils
diff options
context:
space:
mode:
authorGalina Kistanova <gkistanova@gmail.com>2017-05-25 01:51:53 +0000
committerGalina Kistanova <gkistanova@gmail.com>2017-05-25 01:51:53 +0000
commit1754fee8646c69fd388dabcbde390a860317297e (patch)
tree1d41ba2ec2a0177ecc92c23032232134d30f103b /llvm/utils
parentbf40f1b6dd61cd84e45903ba1802348ca1b5f962 (diff)
downloadbcm5719-llvm-1754fee8646c69fd388dabcbde390a860317297e.tar.gz
bcm5719-llvm-1754fee8646c69fd388dabcbde390a860317297e.zip
Fixed nondeterminism in RuleMatcher::emit.
llvm-svn: 303829
Diffstat (limited to 'llvm/utils')
-rw-r--r--llvm/utils/TableGen/GlobalISelEmitter.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp
index eaa89eae22a..185119c2ca4 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/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<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
OpenPOWER on IntegriCloud