Skip to content

Commit fc5b332

Browse files
committed
Move code a separate function
1 parent 588ae00 commit fc5b332

File tree

2 files changed

+30
-23
lines changed

2 files changed

+30
-23
lines changed

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,29 +1495,7 @@ void VPSlotTracker::assignName(const VPValue *V) {
14951495

14961496
// Use the name of the underlying Value, wrapped in "ir<>", and versioned by
14971497
// 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);
15211499
assert(!Name.empty() && "Name cannot be empty.");
15221500
StringRef Prefix = UV ? "ir<" : "vp<%";
15231501
std::string BaseName = (Twine(Prefix) + Name + Twine(">")).str();
@@ -1562,6 +1540,34 @@ void VPSlotTracker::assignNames(const VPBasicBlock *VPBB) {
15621540
assignName(Def);
15631541
}
15641542

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+
15651571
std::string VPSlotTracker::getOrCreateName(const VPValue *V) const {
15661572
std::string Name = VPValue2Name.lookup(V);
15671573
if (!Name.empty())

llvm/lib/Transforms/Vectorize/VPlanHelpers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ class VPSlotTracker {
395395
void assignName(const VPValue *V);
396396
void assignNames(const VPlan &Plan);
397397
void assignNames(const VPBasicBlock *VPBB);
398+
std::string getName(const VPValue *V);
398399

399400
public:
400401
VPSlotTracker(const VPlan *Plan = nullptr) {

0 commit comments

Comments
 (0)