Skip to content

[DebugInfo] [SILGen] Always use emitDebugDescription (NFCI) #73866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/HowToUpdateDebugInfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ be dereferenced.
debug_value %0 : $*T, var, name "value", expr op_deref
```

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

> [!Warning]
> At the optimizer level, Swift `Unsafe*Pointer` types can be simplified
Expand Down
2 changes: 1 addition & 1 deletion include/swift/SIL/SILBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ class SILBuilder {
}

/// Create a debug_value according to the type of \p src
SILInstruction *emitDebugDescription(SILLocation Loc, SILValue src,
DebugValueInst *emitDebugDescription(SILLocation Loc, SILValue src,
SILDebugVariable Var) {
if (src->getType().isAddress())
return createDebugValueAddr(Loc, src, Var);
Expand Down
4 changes: 2 additions & 2 deletions lib/SILGen/SILGenConstructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ void SILGenFunction::emitClassConstructorInitializer(ConstructorDecl *ctor) {
SILLocation PrologueLoc(selfDecl);
PrologueLoc.markAsPrologue();
SILDebugVariable DbgVar(selfDecl->isLet(), ++ArgNo);
B.createDebugValue(PrologueLoc, selfArg.getValue(), DbgVar);
B.emitDebugDescription(PrologueLoc, selfArg.getValue(), DbgVar);
}

if (selfClassDecl->isRootDefaultActor() && !isDelegating) {
Expand Down Expand Up @@ -1719,7 +1719,7 @@ void SILGenFunction::emitIVarInitializer(SILDeclRef ivarInitializer) {
PrologueLoc.markAsPrologue();
// Hard-code self as argument number 1.
SILDebugVariable DbgVar(selfDecl->isLet(), 1);
B.createDebugValue(PrologueLoc, selfArg, DbgVar);
B.emitDebugDescription(PrologueLoc, selfArg, DbgVar);
selfArg = B.createMarkUninitialized(selfDecl, selfArg,
MarkUninitializedInst::RootSelf);
assert(selfTy.hasReferenceSemantics() && "can't emit a value type ctor here");
Expand Down
16 changes: 8 additions & 8 deletions lib/SILGen/SILGenProlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ SILValue SILGenFunction::emitSelfDeclForDestructor(VarDecl *selfDecl) {
VarLocs[selfDecl] = VarLoc::get(selfValue);
SILLocation PrologueLoc(selfDecl);
PrologueLoc.markAsPrologue();
B.createDebugValue(PrologueLoc, selfValue, dv);
B.emitDebugDescription(PrologueLoc, selfValue, dv);
return selfValue;
}

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

DebugValueInst *debugInst
= SGF.B.createDebugValueAddr(loc, debugOperand, varinfo);
= SGF.B.emitDebugDescription(loc, debugOperand, varinfo);

if (argrv.getValue() != debugOperand) {
if (auto valueInst =
Expand Down Expand Up @@ -1001,9 +1001,9 @@ class ArgumentInitHelper {
// Emit debug information for the argument.
SILDebugVariable DebugVar(PD->isLet(), ArgNo);
if (argrv.getType().isAddress())
SGF.B.createDebugValueAddr(loc, argrv.getValue(), DebugVar);
SGF.B.emitDebugDescription(loc, argrv.getValue(), DebugVar);
else
SGF.B.createDebugValue(loc, argrv.getValue(), DebugVar);
SGF.B.emitDebugDescription(loc, argrv.getValue(), DebugVar);
}
};
} // end anonymous namespace
Expand Down Expand Up @@ -1265,9 +1265,9 @@ static void emitCaptureArguments(SILGenFunction &SGF,
if (auto *AllocStack = dyn_cast<AllocStackInst>(arg)) {
AllocStack->setArgNo(ArgNo);
} else if (box || ty.isAddress()) {
SGF.B.createDebugValueAddr(Loc, arg, DbgVar);
SGF.B.emitDebugDescription(Loc, arg, DbgVar);
} else {
SGF.B.createDebugValue(Loc, arg, DbgVar);
SGF.B.emitDebugDescription(Loc, arg, DbgVar);
}
}

Expand Down Expand Up @@ -1537,7 +1537,7 @@ uint16_t SILGenFunction::emitBasicProlog(
RegularLocation loc = RegularLocation::getAutoGeneratedLocation();
if (throwsLoc.isValid())
loc = throwsLoc;
B.createDebugValue(loc, undef.getValue(), dbgVar);
B.emitDebugDescription(loc, undef.getValue(), dbgVar);
}

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