Skip to content

Commit 6de2735

Browse files
committed
[TableGen][GlobalISel] Use MapVector to stabilize iteration order after D153757
StringMap iteration order is not guaranteed to be deterministic (https://llvm.org/docs/ProgrammersManual.html#llvm-adt-stringmap-h).
1 parent 8da7abb commit 6de2735

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

llvm/utils/TableGen/GlobalISelCombinerMatchTableEmitter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "GlobalISelMatchTableExecutorEmitter.h"
2121
#include "SubtargetFeatureInfo.h"
2222
#include "llvm/ADT/Hashing.h"
23+
#include "llvm/ADT/MapVector.h"
2324
#include "llvm/ADT/Statistic.h"
2425
#include "llvm/ADT/StringSet.h"
2526
#include "llvm/Support/CommandLine.h"
@@ -552,7 +553,7 @@ class CombineRuleBuilder {
552553
/// Set by findRoots.
553554
Pattern *MatchRoot = nullptr;
554555

555-
StringMap<OperandTableEntry> OperandTable;
556+
MapVector<StringRef, OperandTableEntry> OperandTable;
556557
SmallVector<MatchDataInfo, 2> MatchDatas;
557558
};
558559

@@ -640,9 +641,8 @@ void CombineRuleBuilder::print(raw_ostream &OS) const {
640641
OS << "<empty>)\n";
641642
else {
642643
OS << "\n";
643-
for (const auto &Entry : OperandTable) {
644-
OS << " [" << Entry.getKey();
645-
auto &Val = Entry.getValue();
644+
for (const auto &[Key, Val] : OperandTable) {
645+
OS << " [" << Key;
646646
if (const auto *P = Val.MatchPat)
647647
OS << " match_pat:" << P->getName();
648648
if (const auto *P = Val.ApplyPat)
@@ -1106,7 +1106,7 @@ bool CombineRuleBuilder::emitInstructionMatchPattern(
11061106

11071107
unsigned OpIdx = 0;
11081108
for (auto &O : P.operands()) {
1109-
auto &OpTableEntry = OperandTable.at(O.Name);
1109+
auto &OpTableEntry = OperandTable.find(O.Name)->second;
11101110

11111111
OperandMatcher &OM =
11121112
IM.addOperand(OpIdx++, O.Name, AllocatedTemporariesBaseID++);

0 commit comments

Comments
 (0)