Skip to content

Commit 63a328c

Browse files
author
Quentin Colombet
committed
[TableGen][GlobalISel] Reset the internal map of RuleMatchers just before the emission
Between the creation of the last InstructionMatcher and the first emission of the related Rule, we need to clear the internal map of IDs. We used to do that right after the creation of the main InstructionMatcher when building the rule and although that worked, this is fragile because if for some reason some later code decides to create more InstructionMatcher before the final call to emit, then the IDs would be completely messed up. Move that to the beginning of "emit" so that the IDs are guarantee to be consistent. NFC. llvm-svn: 321053
1 parent 8516b7f commit 63a328c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

llvm/utils/TableGen/GlobalISelEmitter.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2346,6 +2346,10 @@ void RuleMatcher::emit(MatchTable &Table) {
23462346
if (Matchers.empty())
23472347
llvm_unreachable("Unexpected empty matcher!");
23482348

2349+
// Reset the ID generation so that the emitted IDs match the ones
2350+
// we set while building the InstructionMatcher and such.
2351+
clearImplicitMap();
2352+
23492353
// The representation supports rules that require multiple roots such as:
23502354
// %ptr(p0) = ...
23512355
// %elt0(s32) = G_LOAD %ptr
@@ -3352,9 +3356,6 @@ Expected<RuleMatcher> GlobalISelEmitter::runOnPattern(const PatternToMatch &P) {
33523356
unsigned TempOpIdx = 0;
33533357
auto InsnMatcherOrError =
33543358
createAndImportSelDAGMatcher(M, InsnMatcherTemp, Src, TempOpIdx);
3355-
// Reset the ID generation so that the emitted IDs match the ones
3356-
// in the InstructionMatcher and such.
3357-
M.clearImplicitMap();
33583359
if (auto Error = InsnMatcherOrError.takeError())
33593360
return std::move(Error);
33603361
InstructionMatcher &InsnMatcher = InsnMatcherOrError.get();

0 commit comments

Comments
 (0)