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