@@ -406,7 +406,7 @@ class GlobalISelEmitter final : public GlobalISelMatchTableExecutorEmitter {
406
406
407
407
Expected<action_iterator> importExplicitDefRenderers (
408
408
action_iterator InsertPt, RuleMatcher &M, BuildMIAction &DstMIBuilder,
409
- const TreePatternNode &Dst, unsigned Start = 0 ) const ;
409
+ const TreePatternNode &Dst, bool IsRoot ) const ;
410
410
411
411
Expected<action_iterator>
412
412
importExplicitUseRenderers (action_iterator InsertPt, RuleMatcher &M,
@@ -1375,7 +1375,8 @@ Expected<BuildMIAction &> GlobalISelEmitter::createAndImportInstructionRenderer(
1375
1375
CopyToPhysRegMIBuilder.addRenderer <CopyPhysRegRenderer>(PhysInput.first );
1376
1376
}
1377
1377
1378
- if (auto Error = importExplicitDefRenderers (InsertPt, M, DstMIBuilder, Dst)
1378
+ if (auto Error = importExplicitDefRenderers (InsertPt, M, DstMIBuilder, Dst,
1379
+ /* IsRoot=*/ true )
1379
1380
.takeError ())
1380
1381
return std::move (Error);
1381
1382
@@ -1404,8 +1405,8 @@ GlobalISelEmitter::createAndImportSubInstructionRenderer(
1404
1405
DstMIBuilder.addRenderer <TempRegRenderer>(TempRegID, true );
1405
1406
1406
1407
// 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 );
1409
1410
if (auto Error = InsertPtOrError.takeError ())
1410
1411
return std::move (Error);
1411
1412
@@ -1446,16 +1447,16 @@ GlobalISelEmitter::createInstructionRenderer(action_iterator InsertPt,
1446
1447
1447
1448
Expected<action_iterator> GlobalISelEmitter::importExplicitDefRenderers (
1448
1449
action_iterator InsertPt, RuleMatcher &M, BuildMIAction &DstMIBuilder,
1449
- const TreePatternNode &Dst, unsigned Start ) const {
1450
+ const TreePatternNode &Dst, bool IsRoot ) const {
1450
1451
const CodeGenInstruction *DstI = DstMIBuilder.getCGI ();
1451
1452
1452
1453
// 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) {
1454
1455
const CGIOperandList::OperandInfo &OpInfo = DstI->Operands [I];
1455
1456
std::string OpName = getMangledRootDefName (OpInfo.Name );
1456
1457
1457
1458
// If the def is used in the source DAG, forward it.
1458
- if (M.hasOperand (OpName)) {
1459
+ if (IsRoot && M.hasOperand (OpName)) {
1459
1460
// CopyRenderer saves a StringRef, so cannot pass OpName itself -
1460
1461
// let's use a string with an appropriate lifetime.
1461
1462
StringRef PermanentRef = M.getOperandMatcher (OpName).getSymbolicName ();
0 commit comments