Skip to content

Commit 343d842

Browse files
committed
[SIL][DebugInfo] PATCH 3/3: Deprecate debug_value_addr SIL instruciton
This patch removes all references to DebugValueAddrInst class and debug_value_addr instruction in textual SIL files.
1 parent e1023bc commit 343d842

File tree

104 files changed

+262
-569
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+262
-569
lines changed

include/swift/SIL/DebugUtils.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212
//
1313
// This file contains utilities to work with debug-info related instructions:
14-
// debug_value and debug_value_addr.
14+
// debug_value, alloc_stack, and alloc_box.
1515
//
1616
// SIL optimizations should deal with debug-info related instructions when
1717
// looking at the uses of a value.
@@ -228,7 +228,6 @@ struct DebugVarCarryingInst {
228228
enum class Kind {
229229
Invalid = 0,
230230
DebugValue,
231-
DebugValueAddr,
232231
AllocStack,
233232
AllocBox,
234233
};
@@ -239,8 +238,6 @@ struct DebugVarCarryingInst {
239238
DebugVarCarryingInst() : kind(Kind::Invalid), inst(nullptr) {}
240239
DebugVarCarryingInst(DebugValueInst *dvi)
241240
: kind(Kind::DebugValue), inst(dvi) {}
242-
DebugVarCarryingInst(DebugValueAddrInst *dvai)
243-
: kind(Kind::DebugValueAddr), inst(dvai) {}
244241
DebugVarCarryingInst(AllocStackInst *asi)
245242
: kind(Kind::AllocStack), inst(asi) {}
246243
DebugVarCarryingInst(AllocBoxInst *abi) : kind(Kind::AllocBox), inst(abi) {}
@@ -252,9 +249,6 @@ struct DebugVarCarryingInst {
252249
case SILInstructionKind::DebugValueInst:
253250
kind = Kind::DebugValue;
254251
break;
255-
case SILInstructionKind::DebugValueAddrInst:
256-
kind = Kind::DebugValueAddr;
257-
break;
258252
case SILInstructionKind::AllocStackInst:
259253
kind = Kind::AllocStack;
260254
break;
@@ -283,8 +277,6 @@ struct DebugVarCarryingInst {
283277
llvm_unreachable("Invalid?!");
284278
case Kind::DebugValue:
285279
return cast<DebugValueInst>(inst)->getDecl();
286-
case Kind::DebugValueAddr:
287-
return cast<DebugValueAddrInst>(inst)->getDecl();
288280
case Kind::AllocStack:
289281
return cast<AllocStackInst>(inst)->getDecl();
290282
case Kind::AllocBox:
@@ -299,8 +291,6 @@ struct DebugVarCarryingInst {
299291
llvm_unreachable("Invalid?!");
300292
case Kind::DebugValue:
301293
return cast<DebugValueInst>(inst)->getVarInfo();
302-
case Kind::DebugValueAddr:
303-
return cast<DebugValueAddrInst>(inst)->getVarInfo();
304294
case Kind::AllocStack:
305295
return cast<AllocStackInst>(inst)->getVarInfo();
306296
case Kind::AllocBox:
@@ -316,9 +306,6 @@ struct DebugVarCarryingInst {
316306
case Kind::DebugValue:
317307
cast<DebugValueInst>(inst)->setDebugVarScope(NewDS);
318308
break;
319-
case Kind::DebugValueAddr:
320-
cast<DebugValueAddrInst>(inst)->setDebugVarScope(NewDS);
321-
break;
322309
case Kind::AllocStack:
323310
cast<AllocStackInst>(inst)->setDebugVarScope(NewDS);
324311
break;

include/swift/SIL/Projection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ class ProjectionTree {
859859
ProjectionTree &operator=(ProjectionTree &&) = default;
860860

861861
/// Compute liveness and use information in this projection tree using Base.
862-
/// All debug instructions (debug_value, debug_value_addr) are ignored.
862+
/// All debug_value instructions are ignored.
863863
void computeUsesAndLiveness(SILValue Base);
864864

865865
/// Create a root SILValue iout of the given leaf node values by walking on

include/swift/SIL/SILBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ class SILBuilder {
930930
DebugValueInst *createDebugValueAddr(SILLocation Loc, SILValue src,
931931
SILDebugVariable Var);
932932

933-
/// Create a debug_value_addr if \p src is an address; a debug_value if not.
933+
/// Create a debug_value according to the type of \p src
934934
SILInstruction *emitDebugDescription(SILLocation Loc, SILValue src,
935935
SILDebugVariable Var) {
936936
if (src->getType().isAddress())

include/swift/SIL/SILCloner.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,24 +1254,6 @@ SILCloner<ImplClass>::visitDebugValueInst(DebugValueInst *Inst) {
12541254
remapDebugVarInfo(DebugVarCarryingInst(NewInst));
12551255
recordClonedInstruction(Inst, NewInst);
12561256
}
1257-
template<typename ImplClass>
1258-
void
1259-
SILCloner<ImplClass>::visitDebugValueAddrInst(DebugValueAddrInst *Inst) {
1260-
// We cannot inline/clone debug intrinsics without a scope. If they
1261-
// describe function arguments there is no way to determine which
1262-
// function they belong to.
1263-
if (!Inst->getDebugScope())
1264-
return;
1265-
1266-
// Do not remap the location for a debug Instruction.
1267-
SILDebugVariable VarInfo = *Inst->getVarInfo();
1268-
SILValue OpValue = getOpValue(Inst->getOperand());
1269-
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
1270-
auto *NewInst = getBuilder().createDebugValueAddr(Inst->getLoc(), OpValue,
1271-
*Inst->getVarInfo());
1272-
remapDebugVarInfo(DebugVarCarryingInst(NewInst));
1273-
recordClonedInstruction(Inst, NewInst);
1274-
}
12751257

12761258
#define NEVER_LOADABLE_CHECKED_REF_STORAGE(Name, name, ...) \
12771259
template <typename ImplClass> \

include/swift/SIL/SILInstruction.h

Lines changed: 3 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,7 @@ class SILInstruction : public llvm::ilist_node<SILInstruction> {
734734
/// Returns true if the instruction is only relevant for debug
735735
/// informations and has no other impact on program semantics.
736736
bool isDebugInstruction() const {
737-
return getKind() == SILInstructionKind::DebugValueInst ||
738-
getKind() == SILInstructionKind::DebugValueAddrInst;
737+
return getKind() == SILInstructionKind::DebugValueInst;
739738
}
740739

741740
/// Returns true if the instruction is a meta instruction which is
@@ -1720,8 +1719,8 @@ class UnaryInstructionWithTypeDependentOperandsBase
17201719
};
17211720

17221721
/// Holds common debug information about local variables and function
1723-
/// arguments that are needed by DebugValueInst, DebugValueAddrInst,
1724-
/// AllocStackInst, and AllocBoxInst.
1722+
/// arguments that are needed by DebugValueInst, AllocStackInst,
1723+
/// and AllocBoxInst.
17251724
struct SILDebugVariable {
17261725
StringRef Name;
17271726
unsigned ArgNo : 16;
@@ -4741,58 +4740,6 @@ class DebugValueInst final
47414740
}
47424741
};
47434742

4744-
/// Define the start or update to a symbolic variable value (for address-only
4745-
/// types) .
4746-
class DebugValueAddrInst final
4747-
: public UnaryInstructionBase<SILInstructionKind::DebugValueAddrInst,
4748-
NonValueInstruction>,
4749-
private SILDebugVariableSupplement,
4750-
private llvm::TrailingObjects<DebugValueAddrInst, SILType, SILLocation,
4751-
const SILDebugScope *, SILDIExprElement,
4752-
char> {
4753-
friend TrailingObjects;
4754-
friend SILBuilder;
4755-
4756-
TailAllocatedDebugVariable VarInfo;
4757-
4758-
DebugValueAddrInst(SILDebugLocation DebugLoc, SILValue Operand,
4759-
SILDebugVariable Var);
4760-
static DebugValueAddrInst *create(SILDebugLocation DebugLoc,
4761-
SILValue Operand, SILModule &M,
4762-
SILDebugVariable Var);
4763-
4764-
SIL_DEBUG_VAR_SUPPLEMENT_TRAILING_OBJS_IMPL()
4765-
4766-
public:
4767-
/// Return the underlying variable declaration that this denotes,
4768-
/// or null if we don't have one.
4769-
VarDecl *getDecl() const;
4770-
/// Return the debug variable information attached to this instruction.
4771-
Optional<SILDebugVariable> getVarInfo() const {
4772-
Optional<SILType> AuxVarType;
4773-
Optional<SILLocation> VarDeclLoc;
4774-
const SILDebugScope *VarDeclScope = nullptr;
4775-
if (HasAuxDebugVariableType)
4776-
AuxVarType = *getTrailingObjects<SILType>();
4777-
4778-
if (hasAuxDebugLocation())
4779-
VarDeclLoc = *getTrailingObjects<SILLocation>();
4780-
if (hasAuxDebugScope())
4781-
VarDeclScope = *getTrailingObjects<const SILDebugScope *>();
4782-
4783-
llvm::ArrayRef<SILDIExprElement> DIExprElements(
4784-
getTrailingObjects<SILDIExprElement>(), NumDIExprOperands);
4785-
4786-
return VarInfo.get(getDecl(), getTrailingObjects<char>(), AuxVarType,
4787-
VarDeclLoc, VarDeclScope, DIExprElements);
4788-
}
4789-
4790-
void setDebugVarScope(const SILDebugScope *NewDS) {
4791-
if (hasAuxDebugScope())
4792-
*getTrailingObjects<const SILDebugScope *>() = NewDS;
4793-
}
4794-
};
4795-
47964743
/// An abstract class representing a load from some kind of reference storage.
47974744
template <SILInstructionKind K>
47984745
class LoadReferenceInstBase

include/swift/SIL/SILNodes.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,8 +875,6 @@ NON_VALUE_INST(MarkFunctionEscapeInst, mark_function_escape,
875875
SILInstruction, None, DoesNotRelease)
876876
BRIDGED_NON_VALUE_INST(DebugValueInst, debug_value,
877877
SILInstruction, None, DoesNotRelease)
878-
BRIDGED_NON_VALUE_INST(DebugValueAddrInst, debug_value_addr,
879-
SILInstruction, None, DoesNotRelease)
880878
#define NEVER_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, name, ...) \
881879
NON_VALUE_INST(Store##Name##Inst, store_##name, \
882880
SILInstruction, MayWrite, DoesNotRelease)

include/swift/SILOptimizer/Utils/CanonicalOSSALifetime.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
/// bb0(%arg : @owned $T, %addr : @trivial $*T):
2828
/// %copy = copy_value %arg : $T
2929
/// store %copy to [init] %addr : $*T
30-
/// debug_value_addr %addr : $*T
30+
/// debug_value %addr : $*T, expr op_deref
3131
/// destroy_value %arg : $T
3232
///
3333
/// Will be transformed to:
3434
///
3535
/// bb0(%arg : @owned $T, %addr : @trivial $*T):
3636
/// store %copy to [init] %addr : $*T
37-
/// debug_value_addr %addr : $*T
37+
/// debug_value %addr : $*T, expr op_deref
3838
///
3939
/// Example #2: Destroys are hoisted to the last use. Copies are inserted only
4040
/// at consumes within the lifetime (to directly satisfy ownership conventions):
@@ -43,7 +43,7 @@
4343
/// %copy1 = copy_value %arg : $T
4444
/// store %arg to [init] %addr : $*T
4545
/// %_ = apply %_(%copy1) : $@convention(thin) (@guaranteed T) -> ()
46-
/// debug_value_addr %addr : $*T
46+
/// debug_value %addr : $*T, expr op_deref
4747
/// destroy_value %copy1 : $T
4848
///
4949
/// Will be transformed to:
@@ -53,7 +53,7 @@
5353
/// store %copy1 to [init] %addr : $*T
5454
/// %_ = apply %_(%arg) : $@convention(thin) (@guaranteed T) -> ()
5555
/// destroy_value %arg : $T
56-
/// debug_value_addr %addr : $*T
56+
/// debug_value %addr : $*T, expr op_deref
5757
///
5858
/// Example #3: Handle control flow.
5959
///

include/swift/SILOptimizer/Utils/DebugOptUtils.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ inline void deleteAllDebugUses(SILInstruction *inst,
4444
}
4545

4646
/// Transfer debug info associated with (the result of) \p I to a
47-
/// new `debug_value` or `debug_value_addr` instruction before \p I is
48-
/// deleted.
47+
/// new `debug_value` instruction before \p I is deleted.
4948
void salvageDebugInfo(SILInstruction *I);
5049

5150
/// Erases the instruction \p I from it's parent block and deletes it, including

lib/IRGen/IRGenSIL.cpp

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,6 @@ class IRGenSILFunction :
11461146
llvm_unreachable("unimplemented");
11471147
}
11481148
void visitDebugValueInst(DebugValueInst *i);
1149-
void visitDebugValueAddrInst(DebugValueAddrInst *i);
11501149
void visitRetainValueInst(RetainValueInst *i);
11511150
void visitRetainValueAddrInst(RetainValueAddrInst *i);
11521151
void visitCopyValueInst(CopyValueInst *i);
@@ -4792,64 +4791,6 @@ void IRGenSILFunction::visitDebugValueInst(DebugValueInst *i) {
47924791
i->getLoc(), *VarInfo, Indirection);
47934792
}
47944793

4795-
void IRGenSILFunction::visitDebugValueAddrInst(DebugValueAddrInst *i) {
4796-
if (i->getDebugScope()->getInlinedFunction()->isTransparent())
4797-
return;
4798-
4799-
auto SILVal = i->getOperand();
4800-
if (isa<SILUndef>(SILVal))
4801-
return;
4802-
4803-
auto VarInfo = i->getVarInfo();
4804-
assert(VarInfo && "debug_value_addr without debug info");
4805-
bool IsAnonymous = false;
4806-
bool IsLoadablyByAddress = isa<AllocStackInst>(SILVal);
4807-
IndirectionKind Indirection =
4808-
(IsLoadablyByAddress) ? DirectValue : IndirectValue;
4809-
VarInfo->Name = getVarName(i, IsAnonymous);
4810-
auto *Addr = getLoweredAddress(SILVal).getAddress();
4811-
SILType SILTy;
4812-
if (auto MaybeSILTy = VarInfo->Type)
4813-
// If there is auxiliary type info, use it
4814-
SILTy = *MaybeSILTy;
4815-
else
4816-
SILTy = SILVal->getType();
4817-
auto RealType = SILTy.getASTType();
4818-
if (CurSILFn->isAsync() && !i->getDebugScope()->InlinedCallSite) {
4819-
Indirection = CoroIndirectValue;
4820-
if (auto *PBI = dyn_cast<ProjectBoxInst>(i->getOperand())) {
4821-
// Usually debug info only ever describes the *result* of a projectBox
4822-
// call. To allow the debugger to display a boxed parameter of an async
4823-
// continuation object, however, the debug info can only describe the box
4824-
// itself and thus also needs to emit a box type for it so the debugger
4825-
// knows to call into Remote Mirrors to unbox the value.
4826-
RealType = PBI->getOperand()->getType().getASTType();
4827-
assert(isa<SILBoxType>(RealType));
4828-
}
4829-
}
4830-
4831-
DebugTypeInfo DbgTy;
4832-
if (VarDecl *Decl = i->getDecl())
4833-
DbgTy = DebugTypeInfo::getLocalVariable(Decl, RealType,
4834-
getTypeInfo(SILVal->getType()));
4835-
else if (i->getFunction()->isBare() && !SILTy.hasArchetype() &&
4836-
!VarInfo->Name.empty())
4837-
// Handle the cases that read from a SIL file
4838-
DbgTy = DebugTypeInfo::getFromTypeInfo(RealType, getTypeInfo(SILTy));
4839-
else
4840-
return;
4841-
4842-
bindArchetypes(DbgTy.getType());
4843-
if (!IGM.DebugInfo)
4844-
return;
4845-
4846-
// Put the value's address into a stack slot at -Onone and emit a debug
4847-
// intrinsic.
4848-
emitDebugVariableDeclaration(
4849-
emitShadowCopyIfNeeded(Addr, i->getDebugScope(), *VarInfo, IsAnonymous),
4850-
DbgTy, SILType(), i->getDebugScope(), i->getLoc(), *VarInfo, Indirection);
4851-
}
4852-
48534794
void IRGenSILFunction::visitFixLifetimeInst(swift::FixLifetimeInst *i) {
48544795
if (i->getOperand()->getType().isAddress()) {
48554796
// Just pass in the address to fix lifetime if we have one. We will not do

lib/IRGen/LoadableByAddress.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,9 +1078,9 @@ static AllocStackInst *allocate(StructLoweringState &pass, SILType type) {
10781078
// Insert an alloc_stack at the beginning of the function.
10791079
SILBuilderWithScope allocBuilder(&*pass.F->begin());
10801080
// Don't put any variable debug info into the alloc_stack, there will be a
1081-
// debug_value_addr insterted later. TODO: It may be more elegant to insert
1081+
// debug_value insterted later. TODO: It may be more elegant to insert
10821082
// the variable info into the alloc_stack instead of additionally generating a
1083-
// debug_value_addr.
1083+
// debug_value.
10841084
AllocStackInst *alloc = allocBuilder.createAllocStack(
10851085
RegularLocation::getAutoGeneratedLocation(), type);
10861086

@@ -2969,10 +2969,8 @@ void LoadableByAddress::run() {
29692969
builtinInstrs.insert(instr);
29702970
break;
29712971
}
2972-
case SILInstructionKind::DebugValueAddrInst:
2973-
case SILInstructionKind::DebugValueInst: {
2972+
case SILInstructionKind::DebugValueInst:
29742973
break;
2975-
}
29762974
default:
29772975
llvm_unreachable("Unhandled use of FunctionRefInst");
29782976
}

lib/SIL/IR/OperandOwnership.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ OPERAND_OWNERSHIP(TrivialUse, CondBranch)
143143
OPERAND_OWNERSHIP(TrivialUse, CondFail)
144144
OPERAND_OWNERSHIP(TrivialUse, CopyAddr)
145145
OPERAND_OWNERSHIP(TrivialUse, DeallocStack)
146-
OPERAND_OWNERSHIP(TrivialUse, DebugValueAddr)
147146
OPERAND_OWNERSHIP(TrivialUse, DeinitExistentialAddr)
148147
OPERAND_OWNERSHIP(TrivialUse, DestroyAddr)
149148
OPERAND_OWNERSHIP(TrivialUse, EndAccess)

lib/SIL/IR/SILDebugScope.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ SILFunction *SILDebugScope::getParentFunction() const {
6060
bool swift::maybeScopeless(const SILInstruction &inst) {
6161
if (inst.getFunction()->isBare())
6262
return true;
63-
return !isa<DebugValueInst>(inst) && !isa<DebugValueAddrInst>(inst);
63+
return !isa<DebugValueInst>(inst);
6464
}

lib/SIL/IR/SILInstruction.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,6 @@ bool SILInstruction::isMetaInstruction() const {
13671367
case SILInstructionKind::AllocBoxInst:
13681368
case SILInstructionKind::AllocStackInst:
13691369
case SILInstructionKind::DebugValueInst:
1370-
case SILInstructionKind::DebugValueAddrInst:
13711370
return true;
13721371
default:
13731372
return false;

lib/SIL/IR/SILInstructions.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -380,33 +380,9 @@ bool DebugValueInst::exprStartsWithDeref() const {
380380
== SILDIExprOperator::Dereference;
381381
}
382382

383-
DebugValueAddrInst::DebugValueAddrInst(SILDebugLocation DebugLoc,
384-
SILValue Operand, SILDebugVariable Var)
385-
: UnaryInstructionBase(DebugLoc, Operand),
386-
SILDebugVariableSupplement(Var.DIExpr.getNumElements(),
387-
Var.Type.hasValue(), Var.Loc.hasValue(),
388-
Var.Scope),
389-
VarInfo(Var, getTrailingObjects<char>(), getTrailingObjects<SILType>(),
390-
getTrailingObjects<SILLocation>(),
391-
getTrailingObjects<const SILDebugScope *>(),
392-
getTrailingObjects<SILDIExprElement>()) {
393-
if (auto *VD = DebugLoc.getLocation().getAsASTNode<VarDecl>())
394-
VarInfo.setImplicit(VD->isImplicit() || VarInfo.isImplicit());
395-
}
396-
397-
DebugValueAddrInst *DebugValueAddrInst::create(SILDebugLocation DebugLoc,
398-
SILValue Operand, SILModule &M,
399-
SILDebugVariable Var) {
400-
void *buf = allocateDebugVarCarryingInst<DebugValueAddrInst>(M, Var);
401-
return ::new (buf) DebugValueAddrInst(DebugLoc, Operand, Var);
402-
}
403-
404383
VarDecl *DebugValueInst::getDecl() const {
405384
return getLoc().getAsASTNode<VarDecl>();
406385
}
407-
VarDecl *DebugValueAddrInst::getDecl() const {
408-
return getLoc().getAsASTNode<VarDecl>();
409-
}
410386

411387
AllocExistentialBoxInst *AllocExistentialBoxInst::create(
412388
SILDebugLocation Loc, SILType ExistentialType, CanType ConcreteType,

0 commit comments

Comments
 (0)