@@ -1495,29 +1495,7 @@ void VPSlotTracker::assignName(const VPValue *V) {
1495
1495
1496
1496
// Use the name of the underlying Value, wrapped in "ir<>", and versioned by
1497
1497
// appending ".Number" to the name if there are multiple uses.
1498
- std::string Name;
1499
- if (UV) {
1500
- raw_string_ostream S (Name);
1501
- if (MST) {
1502
- UV->printAsOperand (S, false , *MST);
1503
- } else if (isa<Instruction>(UV) && !UV->hasName ()) {
1504
- // Lazily create the ModuleSlotTracker when we first hit an unnamed
1505
- // instruction
1506
- auto *IUV = cast<Instruction>(UV);
1507
- // This check is required to support unit tests with incomplete IR.
1508
- if (IUV->getParent ()) {
1509
- MST = std::make_unique<ModuleSlotTracker>(IUV->getModule ());
1510
- MST->incorporateFunction (*IUV->getFunction ());
1511
- } else {
1512
- MST = std::make_unique<ModuleSlotTracker>(nullptr );
1513
- }
1514
- UV->printAsOperand (S, false , *MST);
1515
- } else {
1516
- UV->printAsOperand (S, false );
1517
- }
1518
- } else
1519
- Name = VPI->getName ();
1520
-
1498
+ std::string Name = getName (V);
1521
1499
assert (!Name.empty () && " Name cannot be empty." );
1522
1500
StringRef Prefix = UV ? " ir<" : " vp<%" ;
1523
1501
std::string BaseName = (Twine (Prefix) + Name + Twine (" >" )).str ();
@@ -1562,6 +1540,34 @@ void VPSlotTracker::assignNames(const VPBasicBlock *VPBB) {
1562
1540
assignName (Def);
1563
1541
}
1564
1542
1543
+ std::string VPSlotTracker::getName (const VPValue *V) {
1544
+ auto *UV = V->getUnderlyingValue ();
1545
+ auto *VPI = dyn_cast_or_null<VPInstruction>(V->getDefiningRecipe ());
1546
+ if (!UV)
1547
+ return VPI->getName ().str ();
1548
+
1549
+ std::string Name;
1550
+ raw_string_ostream S (Name);
1551
+ if (MST) {
1552
+ UV->printAsOperand (S, false , *MST);
1553
+ } else if (isa<Instruction>(UV) && !UV->hasName ()) {
1554
+ // Lazily create the ModuleSlotTracker when we first hit an unnamed
1555
+ // instruction
1556
+ auto *IUV = cast<Instruction>(UV);
1557
+ // This check is required to support unit tests with incomplete IR.
1558
+ if (IUV->getParent ()) {
1559
+ MST = std::make_unique<ModuleSlotTracker>(IUV->getModule ());
1560
+ MST->incorporateFunction (*IUV->getFunction ());
1561
+ } else {
1562
+ MST = std::make_unique<ModuleSlotTracker>(nullptr );
1563
+ }
1564
+ UV->printAsOperand (S, false , *MST);
1565
+ } else {
1566
+ UV->printAsOperand (S, false );
1567
+ }
1568
+ return Name;
1569
+ }
1570
+
1565
1571
std::string VPSlotTracker::getOrCreateName (const VPValue *V) const {
1566
1572
std::string Name = VPValue2Name.lookup (V);
1567
1573
if (!Name.empty ())
0 commit comments