mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #27238 from adrian-prantl/silcloner-varinfo
Debug Info: Add missing debug info propagation to SILCloner.
This commit is contained in:
@@ -403,6 +403,8 @@ public:
|
||||
Optional<SILDebugVariable> Var = None,
|
||||
bool hasDynamicLifetime = false) {
|
||||
Loc.markAsPrologue();
|
||||
assert((!dyn_cast_or_null<VarDecl>(Loc.getAsASTNode<Decl>()) || Var) &&
|
||||
"location is a VarDecl, but SILDebugVariable is empty");
|
||||
return insert(AllocStackInst::create(getSILDebugLocation(Loc), elementType,
|
||||
getFunction(), C.OpenedArchetypes,
|
||||
Var, hasDynamicLifetime));
|
||||
@@ -443,6 +445,8 @@ public:
|
||||
Optional<SILDebugVariable> Var = None,
|
||||
bool hasDynamicLifetime = false) {
|
||||
Loc.markAsPrologue();
|
||||
assert((!dyn_cast_or_null<VarDecl>(Loc.getAsASTNode<Decl>()) || Var) &&
|
||||
"location is a VarDecl, but SILDebugVariable is empty");
|
||||
return insert(AllocBoxInst::create(getSILDebugLocation(Loc), BoxType, *F,
|
||||
C.OpenedArchetypes, Var,
|
||||
hasDynamicLifetime));
|
||||
|
||||
@@ -784,9 +784,16 @@ template<typename ImplClass>
|
||||
void
|
||||
SILCloner<ImplClass>::visitAllocStackInst(AllocStackInst *Inst) {
|
||||
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
|
||||
recordClonedInstruction(
|
||||
Inst, getBuilder().createAllocStack(getOpLocation(Inst->getLoc()),
|
||||
getOpType(Inst->getElementType())));
|
||||
// Drop the debug info from mandatory-inlined instructions. It's the law!
|
||||
SILLocation Loc = getOpLocation(Inst->getLoc());
|
||||
Optional<SILDebugVariable> VarInfo = Inst->getVarInfo();
|
||||
if (Loc.getKind() == SILLocation::MandatoryInlinedKind) {
|
||||
Loc = MandatoryInlinedLocation::getAutoGeneratedLocation();
|
||||
VarInfo = None;
|
||||
}
|
||||
recordClonedInstruction(Inst,
|
||||
getBuilder().createAllocStack(
|
||||
Loc, getOpType(Inst->getElementType()), VarInfo));
|
||||
}
|
||||
|
||||
template<typename ImplClass>
|
||||
@@ -829,11 +836,19 @@ template<typename ImplClass>
|
||||
void
|
||||
SILCloner<ImplClass>::visitAllocBoxInst(AllocBoxInst *Inst) {
|
||||
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
|
||||
// Drop the debug info from mandatory-inlined instructions.
|
||||
SILLocation Loc = getOpLocation(Inst->getLoc());
|
||||
Optional<SILDebugVariable> VarInfo = Inst->getVarInfo();
|
||||
if (Loc.getKind() == SILLocation::MandatoryInlinedKind) {
|
||||
Loc = MandatoryInlinedLocation::getAutoGeneratedLocation();
|
||||
VarInfo = None;
|
||||
}
|
||||
|
||||
recordClonedInstruction(
|
||||
Inst,
|
||||
getBuilder().createAllocBox(
|
||||
getOpLocation(Inst->getLoc()),
|
||||
this->getOpType(Inst->getType()).template castTo<SILBoxType>()));
|
||||
Loc, this->getOpType(Inst->getType()).template castTo<SILBoxType>(),
|
||||
VarInfo));
|
||||
}
|
||||
|
||||
template<typename ImplClass>
|
||||
|
||||
@@ -1315,14 +1315,18 @@ public:
|
||||
/// arguments that are needed by DebugValueInst, DebugValueAddrInst,
|
||||
/// AllocStackInst, and AllocBoxInst.
|
||||
struct SILDebugVariable {
|
||||
StringRef Name;
|
||||
unsigned ArgNo : 16;
|
||||
unsigned Constant : 1;
|
||||
|
||||
SILDebugVariable() : ArgNo(0), Constant(false) {}
|
||||
SILDebugVariable(bool Constant, uint16_t ArgNo)
|
||||
: ArgNo(ArgNo), Constant(Constant) {}
|
||||
SILDebugVariable(StringRef Name, bool Constant, unsigned ArgNo)
|
||||
: Name(Name), ArgNo(ArgNo), Constant(Constant) {}
|
||||
StringRef Name;
|
||||
unsigned ArgNo : 16;
|
||||
unsigned Constant : 1;
|
||||
bool operator==(const SILDebugVariable &V) {
|
||||
return ArgNo == V.ArgNo && Constant == V.Constant && Name == V.Name;
|
||||
}
|
||||
};
|
||||
|
||||
/// A DebugVariable where storage for the strings has been
|
||||
|
||||
@@ -662,6 +662,7 @@ public:
|
||||
: SILLocation(L, MandatoryInlinedKind) {}
|
||||
|
||||
static MandatoryInlinedLocation getMandatoryInlinedLocation(SILLocation L);
|
||||
static MandatoryInlinedLocation getAutoGeneratedLocation();
|
||||
|
||||
static MandatoryInlinedLocation getModuleLocation(unsigned Flags) {
|
||||
auto L = MandatoryInlinedLocation();
|
||||
|
||||
Reference in New Issue
Block a user