Skip to content

Commit 8d66a39

Browse files
committed
Count implicit defs as well as explicit ones in the GlobalISel TableGen emitter.
NumDefs only counts the number of registers in (outs), not any implicit defs specified with Defs = [...]
1 parent 7b65971 commit 8d66a39

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

llvm/utils/TableGen/GlobalISelEmitter.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,7 +2023,10 @@ Expected<RuleMatcher> GlobalISelEmitter::runOnPattern(const PatternToMatch &P) {
20232023
auto &DstI = Target.getInstruction(DstOp);
20242024
StringRef DstIName = DstI.TheDef->getName();
20252025

2026-
unsigned DstNumDefs = DstI.Operands.NumDefs,
2026+
// Count both implicit and explicit defs in the dst instruction.
2027+
// This avoids errors importing patterns that have inherent implicit defs.
2028+
unsigned DstExpDefs = DstI.Operands.NumDefs,
2029+
DstNumDefs = DstI.ImplicitDefs.size() + DstExpDefs,
20272030
SrcNumDefs = Src.getExtTypes().size();
20282031
if (DstNumDefs < SrcNumDefs) {
20292032
if (DstNumDefs != 0)
@@ -2045,7 +2048,7 @@ Expected<RuleMatcher> GlobalISelEmitter::runOnPattern(const PatternToMatch &P) {
20452048
// The root of the match also has constraints on the register bank so that it
20462049
// matches the result instruction.
20472050
unsigned OpIdx = 0;
2048-
unsigned N = std::min(DstNumDefs, SrcNumDefs);
2051+
unsigned N = std::min(DstExpDefs, SrcNumDefs);
20492052
for (unsigned I = 0; I < N; ++I) {
20502053
const TypeSetByHwMode &VTy = Src.getExtType(I);
20512054

0 commit comments

Comments
 (0)