Skip to content

Commit 0bc6ece

Browse files
committed
[DebugInfo] [SILGen] Always use emitDebugDescription (NFCI)
1 parent f3d4969 commit 0bc6ece

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

docs/HowToUpdateDebugInfo.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ be dereferenced.
133133
debug_value %0 : $*T, var, name "value", expr op_deref
134134
```
135135

136-
SILGen can use `SILBuilder::createDebugValue` and
137-
`SILBuilder::createDebugValueAddr` to create debug values, respectively without
138-
and with an op_deref, or use `SILBuilder::emitDebugDescription` which will
139-
automatically choose the correct one depending on the type of the SSA value. As
140-
there are no pointers in Swift, this should always do the right thing.
136+
SILGen should always use `SILBuilder::emitDebugDescription` to create debug
137+
values, which will automatically add an op_deref depending on the type of the
138+
SSA value. As there are no pointers in Swift, this will always do the right
139+
thing. In SIL passes, use `SILBuilder::createDebugValue` to create debug values,
140+
or `SILBuilder::createDebugValueAddr` to add an op_deref.
141141

142142
> [!Warning]
143143
> At the optimizer level, Swift `Unsafe*Pointer` types can be simplified

include/swift/SIL/SILBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ class SILBuilder {
10851085
}
10861086

10871087
/// Create a debug_value according to the type of \p src
1088-
SILInstruction *emitDebugDescription(SILLocation Loc, SILValue src,
1088+
DebugValueInst *emitDebugDescription(SILLocation Loc, SILValue src,
10891089
SILDebugVariable Var) {
10901090
if (src->getType().isAddress())
10911091
return createDebugValueAddr(Loc, src, Var);

lib/SILGen/SILGenConstructor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ void SILGenFunction::emitClassConstructorInitializer(ConstructorDecl *ctor) {
11631163
SILLocation PrologueLoc(selfDecl);
11641164
PrologueLoc.markAsPrologue();
11651165
SILDebugVariable DbgVar(selfDecl->isLet(), ++ArgNo);
1166-
B.createDebugValue(PrologueLoc, selfArg.getValue(), DbgVar);
1166+
B.emitDebugDescription(PrologueLoc, selfArg.getValue(), DbgVar);
11671167
}
11681168

11691169
if (selfClassDecl->isRootDefaultActor() && !isDelegating) {
@@ -1719,7 +1719,7 @@ void SILGenFunction::emitIVarInitializer(SILDeclRef ivarInitializer) {
17191719
PrologueLoc.markAsPrologue();
17201720
// Hard-code self as argument number 1.
17211721
SILDebugVariable DbgVar(selfDecl->isLet(), 1);
1722-
B.createDebugValue(PrologueLoc, selfArg, DbgVar);
1722+
B.emitDebugDescription(PrologueLoc, selfArg, DbgVar);
17231723
selfArg = B.createMarkUninitialized(selfDecl, selfArg,
17241724
MarkUninitializedInst::RootSelf);
17251725
assert(selfTy.hasReferenceSemantics() && "can't emit a value type ctor here");

lib/SILGen/SILGenProlog.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ SILValue SILGenFunction::emitSelfDeclForDestructor(VarDecl *selfDecl) {
7777
VarLocs[selfDecl] = VarLoc::get(selfValue);
7878
SILLocation PrologueLoc(selfDecl);
7979
PrologueLoc.markAsPrologue();
80-
B.createDebugValue(PrologueLoc, selfValue, dv);
80+
B.emitDebugDescription(PrologueLoc, selfValue, dv);
8181
return selfValue;
8282
}
8383

@@ -697,7 +697,7 @@ class ArgumentInitHelper {
697697
"all paths or manually turn it off");
698698
};
699699
auto completeUpdate = [&](ManagedValue value) -> void {
700-
SGF.B.createDebugValue(loc, value.getValue(), varinfo);
700+
SGF.B.emitDebugDescription(loc, value.getValue(), varinfo);
701701
SGF.VarLocs[pd] = SILGenFunction::VarLoc::get(value.getValue());
702702
calledCompletedUpdate = true;
703703
};
@@ -950,7 +950,7 @@ class ArgumentInitHelper {
950950
}
951951

952952
DebugValueInst *debugInst
953-
= SGF.B.createDebugValueAddr(loc, debugOperand, varinfo);
953+
= SGF.B.emitDebugDescription(loc, debugOperand, varinfo);
954954

955955
if (argrv.getValue() != debugOperand) {
956956
if (auto valueInst =
@@ -1001,9 +1001,9 @@ class ArgumentInitHelper {
10011001
// Emit debug information for the argument.
10021002
SILDebugVariable DebugVar(PD->isLet(), ArgNo);
10031003
if (argrv.getType().isAddress())
1004-
SGF.B.createDebugValueAddr(loc, argrv.getValue(), DebugVar);
1004+
SGF.B.emitDebugDescription(loc, argrv.getValue(), DebugVar);
10051005
else
1006-
SGF.B.createDebugValue(loc, argrv.getValue(), DebugVar);
1006+
SGF.B.emitDebugDescription(loc, argrv.getValue(), DebugVar);
10071007
}
10081008
};
10091009
} // end anonymous namespace
@@ -1265,9 +1265,9 @@ static void emitCaptureArguments(SILGenFunction &SGF,
12651265
if (auto *AllocStack = dyn_cast<AllocStackInst>(arg)) {
12661266
AllocStack->setArgNo(ArgNo);
12671267
} else if (box || ty.isAddress()) {
1268-
SGF.B.createDebugValueAddr(Loc, arg, DbgVar);
1268+
SGF.B.emitDebugDescription(Loc, arg, DbgVar);
12691269
} else {
1270-
SGF.B.createDebugValue(Loc, arg, DbgVar);
1270+
SGF.B.emitDebugDescription(Loc, arg, DbgVar);
12711271
}
12721272
}
12731273

@@ -1537,7 +1537,7 @@ uint16_t SILGenFunction::emitBasicProlog(
15371537
RegularLocation loc = RegularLocation::getAutoGeneratedLocation();
15381538
if (throwsLoc.isValid())
15391539
loc = throwsLoc;
1540-
B.createDebugValue(loc, undef.getValue(), dbgVar);
1540+
B.emitDebugDescription(loc, undef.getValue(), dbgVar);
15411541
}
15421542

15431543
for (auto &i : *B.getInsertionBB()) {

0 commit comments

Comments
 (0)