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

This commit is contained in:
Emil Pedersen
2024-05-13 15:31:41 -07:00
parent f3d4969e07
commit 0bc6ece9db
4 changed files with 16 additions and 16 deletions

View File

@@ -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

View File

@@ -1085,7 +1085,7 @@ public:
}
/// 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);

View File

@@ -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) {
@@ -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");

View File

@@ -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;
}
@@ -697,7 +697,7 @@ private:
"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;
};
@@ -950,7 +950,7 @@ private:
}
DebugValueInst *debugInst
= SGF.B.createDebugValueAddr(loc, debugOperand, varinfo);
= SGF.B.emitDebugDescription(loc, debugOperand, varinfo);
if (argrv.getValue() != debugOperand) {
if (auto valueInst =
@@ -1001,9 +1001,9 @@ private:
// 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
@@ -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);
}
}
@@ -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()) {