From 0bc6ece9dba54ee70af1508759db2887d0837389 Mon Sep 17 00:00:00 2001 From: Emil Pedersen Date: Mon, 13 May 2024 15:31:41 -0700 Subject: [PATCH] [DebugInfo] [SILGen] Always use emitDebugDescription (NFCI) --- docs/HowToUpdateDebugInfo.md | 10 +++++----- include/swift/SIL/SILBuilder.h | 2 +- lib/SILGen/SILGenConstructor.cpp | 4 ++-- lib/SILGen/SILGenProlog.cpp | 16 ++++++++-------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/HowToUpdateDebugInfo.md b/docs/HowToUpdateDebugInfo.md index 756e117f46f..69f84644e30 100644 --- a/docs/HowToUpdateDebugInfo.md +++ b/docs/HowToUpdateDebugInfo.md @@ -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 diff --git a/include/swift/SIL/SILBuilder.h b/include/swift/SIL/SILBuilder.h index af1443add37..9df56472477 100644 --- a/include/swift/SIL/SILBuilder.h +++ b/include/swift/SIL/SILBuilder.h @@ -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); diff --git a/lib/SILGen/SILGenConstructor.cpp b/lib/SILGen/SILGenConstructor.cpp index 95b77e676b1..63a03cb921f 100644 --- a/lib/SILGen/SILGenConstructor.cpp +++ b/lib/SILGen/SILGenConstructor.cpp @@ -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"); diff --git a/lib/SILGen/SILGenProlog.cpp b/lib/SILGen/SILGenProlog.cpp index a017cd2f820..d2d54d37772 100644 --- a/lib/SILGen/SILGenProlog.cpp +++ b/lib/SILGen/SILGenProlog.cpp @@ -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(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()) {