@@ -406,7 +406,7 @@ class GlobalISelEmitter final : public GlobalISelMatchTableExecutorEmitter {
406406
407407 Expected<action_iterator> importExplicitDefRenderers (
408408 action_iterator InsertPt, RuleMatcher &M, BuildMIAction &DstMIBuilder,
409- const TreePatternNode &Dst, unsigned Start = 0 ) const ;
409+ const TreePatternNode &Dst, bool IsRoot ) const ;
410410
411411 Expected<action_iterator>
412412 importExplicitUseRenderers (action_iterator InsertPt, RuleMatcher &M,
@@ -1375,7 +1375,8 @@ Expected<BuildMIAction &> GlobalISelEmitter::createAndImportInstructionRenderer(
13751375 CopyToPhysRegMIBuilder.addRenderer <CopyPhysRegRenderer>(PhysInput.first );
13761376 }
13771377
1378- if (auto Error = importExplicitDefRenderers (InsertPt, M, DstMIBuilder, Dst)
1378+ if (auto Error = importExplicitDefRenderers (InsertPt, M, DstMIBuilder, Dst,
1379+ /* IsRoot=*/ true )
13791380 .takeError ())
13801381 return std::move (Error);
13811382
@@ -1404,8 +1405,8 @@ GlobalISelEmitter::createAndImportSubInstructionRenderer(
14041405 DstMIBuilder.addRenderer <TempRegRenderer>(TempRegID, true );
14051406
14061407 // Handle additional (ignored) results.
1407- InsertPtOrError = importExplicitDefRenderers (std::prev (*InsertPtOrError), M,
1408- DstMIBuilder, Dst, /* Start =*/ 1 );
1408+ InsertPtOrError = importExplicitDefRenderers (
1409+ std::prev (*InsertPtOrError), M, DstMIBuilder, Dst, /* IsRoot =*/ false );
14091410 if (auto Error = InsertPtOrError.takeError ())
14101411 return std::move (Error);
14111412
@@ -1446,16 +1447,16 @@ GlobalISelEmitter::createInstructionRenderer(action_iterator InsertPt,
14461447
14471448Expected<action_iterator> GlobalISelEmitter::importExplicitDefRenderers (
14481449 action_iterator InsertPt, RuleMatcher &M, BuildMIAction &DstMIBuilder,
1449- const TreePatternNode &Dst, unsigned Start ) const {
1450+ const TreePatternNode &Dst, bool IsRoot ) const {
14501451 const CodeGenInstruction *DstI = DstMIBuilder.getCGI ();
14511452
14521453 // Process explicit defs. The caller may have already handled the first def.
1453- for (unsigned I = Start , E = DstI->Operands .NumDefs ; I != E; ++I) {
1454+ for (unsigned I = IsRoot ? 0 : 1 , E = DstI->Operands .NumDefs ; I != E; ++I) {
14541455 const CGIOperandList::OperandInfo &OpInfo = DstI->Operands [I];
14551456 std::string OpName = getMangledRootDefName (OpInfo.Name );
14561457
14571458 // If the def is used in the source DAG, forward it.
1458- if (M.hasOperand (OpName)) {
1459+ if (IsRoot && M.hasOperand (OpName)) {
14591460 // CopyRenderer saves a StringRef, so cannot pass OpName itself -
14601461 // let's use a string with an appropriate lifetime.
14611462 StringRef PermanentRef = M.getOperandMatcher (OpName).getSymbolicName ();
0 commit comments