@@ -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,
@@ -1369,7 +1370,8 @@ Expected<BuildMIAction &> GlobalISelEmitter::createAndImportInstructionRenderer(
1369
1370
CopyToPhysRegMIBuilder.addRenderer <CopyPhysRegRenderer>(PhysInput.first );
1370
1371
}
1371
1372
1372
- if (auto Error = importExplicitDefRenderers (InsertPt, M, DstMIBuilder, Dst)
1373
+ if (auto Error = importExplicitDefRenderers (InsertPt, M, DstMIBuilder, Dst,
1374
+ /* IsRoot=*/ true )
1373
1375
.takeError ())
1374
1376
return std::move (Error);
1375
1377
@@ -1398,8 +1400,8 @@ GlobalISelEmitter::createAndImportSubInstructionRenderer(
1398
1400
DstMIBuilder.addRenderer <TempRegRenderer>(TempRegID, true );
1399
1401
1400
1402
// Handle additional (ignored) results.
1401
- InsertPtOrError = importExplicitDefRenderers (std::prev (*InsertPtOrError), M,
1402
- DstMIBuilder, Dst, /* Start =*/ 1 );
1403
+ InsertPtOrError = importExplicitDefRenderers (
1404
+ std::prev (*InsertPtOrError), M, DstMIBuilder, Dst, /* IsRoot =*/ false );
1403
1405
if (auto Error = InsertPtOrError.takeError ())
1404
1406
return std::move (Error);
1405
1407
@@ -1440,16 +1442,16 @@ GlobalISelEmitter::createInstructionRenderer(action_iterator InsertPt,
1440
1442
1441
1443
Expected<action_iterator> GlobalISelEmitter::importExplicitDefRenderers (
1442
1444
action_iterator InsertPt, RuleMatcher &M, BuildMIAction &DstMIBuilder,
1443
- const TreePatternNode &Dst, unsigned Start ) const {
1445
+ const TreePatternNode &Dst, bool IsRoot ) const {
1444
1446
const CodeGenInstruction *DstI = DstMIBuilder.getCGI ();
1445
1447
1446
1448
// Process explicit defs. The caller may have already handled the first def.
1447
- for (unsigned I = Start , E = DstI->Operands .NumDefs ; I != E; ++I) {
1449
+ for (unsigned I = IsRoot ? 0 : 1 , E = DstI->Operands .NumDefs ; I != E; ++I) {
1448
1450
const CGIOperandList::OperandInfo &OpInfo = DstI->Operands [I];
1449
1451
std::string OpName = getMangledRootDefName (OpInfo.Name );
1450
1452
1451
1453
// If the def is used in the source DAG, forward it.
1452
- if (M.hasOperand (OpName)) {
1454
+ if (IsRoot && M.hasOperand (OpName)) {
1453
1455
// CopyRenderer saves a StringRef, so cannot pass OpName itself -
1454
1456
// let's use a string with an appropriate lifetime.
1455
1457
StringRef PermanentRef = M.getOperandMatcher (OpName).getSymbolicName ();
0 commit comments