Skip to content

Commit 63b6738

Browse files
committed
[variable-name-utils] Convert all DebugVarCarryingInst|VarDeclCarryingInst to the new representation of storing a StringRef.
1 parent 76f67cf commit 63b6738

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

include/swift/SILOptimizer/Utils/VariableNameUtils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ class VariableNameInferrer {
192192

193193
StringRef getName() const { return resultingString; }
194194

195+
SWIFT_DEBUG_DUMP { llvm::dbgs() << getName() << '\n'; }
196+
195197
/// Given a specific SILValue, construct a VariableNameInferrer and use it to
196198
/// attempt to infer an identifier for the value.
197199
static std::optional<Identifier> inferName(SILValue value);

lib/SILOptimizer/Utils/VariableNameUtils.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,15 @@ SILValue VariableNameInferrer::findDebugInfoProvidingValueHelper(
426426
return SILValue();
427427
}
428428

429-
variableNamePath.push_back(allocInst);
429+
variableNamePath.push_back(DebugVarCarryingInst(allocInst).getName());
430430
return allocInst;
431431
}
432432

433+
if (auto *abi = dyn_cast<AllocBoxInst>(searchValue)) {
434+
variableNamePath.push_back(DebugVarCarryingInst(abi).getName());
435+
return abi;
436+
}
437+
433438
// If we have a store_borrow, always look at the dest. We are going to see
434439
// if we can determine if dest is a temporary alloc_stack.
435440
if (auto *sbi = dyn_cast<StoreBorrowInst>(searchValue)) {
@@ -438,7 +443,7 @@ SILValue VariableNameInferrer::findDebugInfoProvidingValueHelper(
438443
}
439444

440445
if (auto *globalAddrInst = dyn_cast<GlobalAddrInst>(searchValue)) {
441-
variableNamePath.push_back(globalAddrInst);
446+
variableNamePath.push_back(VarDeclCarryingInst(globalAddrInst).getName());
442447
return globalAddrInst;
443448
}
444449

@@ -448,7 +453,7 @@ SILValue VariableNameInferrer::findDebugInfoProvidingValueHelper(
448453
}
449454

450455
if (auto *rei = dyn_cast<RefElementAddrInst>(searchValue)) {
451-
variableNamePath.push_back(rei);
456+
variableNamePath.push_back(VarDeclCarryingInst(rei).getName());
452457
searchValue = rei->getOperand();
453458
continue;
454459
}
@@ -662,15 +667,6 @@ void VariableNameInferrer::popSingleVariableName() {
662667

663668
if (std::holds_alternative<SILInstruction *>(next)) {
664669
auto *inst = std::get<SILInstruction *>(next);
665-
if (auto i = DebugVarCarryingInst(inst)) {
666-
resultingString += i.getName();
667-
return;
668-
}
669-
670-
if (auto i = VarDeclCarryingInst(inst)) {
671-
resultingString += i.getName();
672-
return;
673-
}
674670

675671
if (auto f = dyn_cast<FunctionRefBaseInst>(inst)) {
676672
if (auto dc = f->getInitiallyReferencedFunction()->getDeclContext()) {

0 commit comments

Comments
 (0)