File tree Expand file tree Collapse file tree 2 files changed +18
-12
lines changed
llvm/lib/Transforms/Vectorize Expand file tree Collapse file tree 2 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -1441,10 +1441,23 @@ void VPSlotTracker::assignName(const VPValue *V) {
1441
1441
std::string Name;
1442
1442
if (UV) {
1443
1443
raw_string_ostream S (Name);
1444
- if (MST)
1444
+ if (MST) {
1445
1445
UV->printAsOperand (S, false , *MST);
1446
- else
1446
+ } else if (isa<Instruction>(UV) && !UV->hasName ()) {
1447
+ // Lazily create the ModuleSlotTracker when we first hit an unnamed
1448
+ // instruction
1449
+ auto *IUV = cast<Instruction>(UV);
1450
+ // This check is required to support unit tests with incomplete IR.
1451
+ if (IUV->getParent ()) {
1452
+ MST = std::make_unique<ModuleSlotTracker>(IUV->getModule ());
1453
+ MST->incorporateFunction (*IUV->getFunction ());
1454
+ } else {
1455
+ MST = std::make_unique<ModuleSlotTracker>(nullptr );
1456
+ }
1457
+ UV->printAsOperand (S, false , *MST);
1458
+ } else {
1447
1459
UV->printAsOperand (S, false );
1460
+ }
1448
1461
} else
1449
1462
Name = VPI->getName ();
1450
1463
Original file line number Diff line number Diff line change @@ -383,7 +383,8 @@ class VPSlotTracker {
383
383
// / Number to assign to the next VPValue without underlying value.
384
384
unsigned NextSlot = 0 ;
385
385
386
- // / Cache slot indexes to avoid recomputing them on each printAsOperand call.
386
+ // / Lazily created ModuleSlotTracker, used only when unnamed IR instructions
387
+ // / require slot tracking.
387
388
std::unique_ptr<ModuleSlotTracker> MST;
388
389
389
390
void assignName (const VPValue *V);
@@ -392,16 +393,8 @@ class VPSlotTracker {
392
393
393
394
public:
394
395
VPSlotTracker (const VPlan *Plan = nullptr ) {
395
- if (Plan) {
396
- // This check is required to support unit tests with incomplete IR.
397
- if (Function *F =
398
- Plan->getScalarHeader ()->getIRBasicBlock ()->getParent ()) {
399
- Module *M = F->getParent ();
400
- MST = std::make_unique<ModuleSlotTracker>(M);
401
- MST->incorporateFunction (*F);
402
- }
396
+ if (Plan)
403
397
assignNames (*Plan);
404
- }
405
398
}
406
399
407
400
// / Returns the name assigned to \p V, if there is one, otherwise try to
You can’t perform that action at this time.
0 commit comments