[llvm] r321053 - [TableGen][GlobalISel] Reset the internal map of RuleMatchers just before the emission
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 18 18:57:23 PST 2017
Author: qcolombet
Date: Mon Dec 18 18:57:23 2017
New Revision: 321053
URL: http://llvm.org/viewvc/llvm-project?rev=321053&view=rev
Log:
[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.
Modified:
llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp
Modified: llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp?rev=321053&r1=321052&r2=321053&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp Mon Dec 18 18:57:23 2017
@@ -2346,6 +2346,10 @@ void RuleMatcher::emit(MatchTable &Table
if (Matchers.empty())
llvm_unreachable("Unexpected empty matcher!");
+ // Reset the ID generation so that the emitted IDs match the ones
+ // we set while building the InstructionMatcher and such.
+ clearImplicitMap();
+
// The representation supports rules that require multiple roots such as:
// %ptr(p0) = ...
// %elt0(s32) = G_LOAD %ptr
@@ -3352,9 +3356,6 @@ Expected<RuleMatcher> GlobalISelEmitter:
unsigned TempOpIdx = 0;
auto InsnMatcherOrError =
createAndImportSelDAGMatcher(M, InsnMatcherTemp, Src, TempOpIdx);
- // Reset the ID generation so that the emitted IDs match the ones
- // in the InstructionMatcher and such.
- M.clearImplicitMap();
if (auto Error = InsnMatcherOrError.takeError())
return std::move(Error);
InstructionMatcher &InsnMatcher = InsnMatcherOrError.get();
More information about the llvm-commits
mailing list