Skip to content

Commit 584d1db

Browse files
committed
[IRGen] [DebugInfo] Ignore autogenerated flag for variables
1 parent 00a93d9 commit 584d1db

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

include/swift/SIL/SILLocation.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,16 @@ class SILLocation {
391391
/// Check is this location is part of a function's implicit prologue.
392392
bool isInPrologue() const { return kindAndFlags.fields.inPrologue; }
393393

394+
/// Returns this location with the auto-generated and prologue bits stripped.
395+
/// These bits only make sense for instructions, and should be stripped for
396+
/// variables.
397+
SILLocation strippedForDebugVariable() const {
398+
SILLocation loc = *this;
399+
loc.kindAndFlags.fields.autoGenerated = false;
400+
loc.kindAndFlags.fields.inPrologue = false;
401+
return loc;
402+
}
403+
394404
/// Check if the corresponding source code location definitely points
395405
/// to the end of the AST node.
396406
bool pointsToEnd() const;

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3186,10 +3186,14 @@ void IRGenDebugInfoImpl::emitVariableDeclaration(
31863186
// Create the descriptor for the variable.
31873187
unsigned DVarLine = DInstLine;
31883188
uint16_t DVarCol = DInstLoc.Column;
3189-
if (VarInfo.Loc) {
3190-
auto DVarLoc = getStartLocation(VarInfo.Loc);
3191-
DVarLine = DVarLoc.Line;
3192-
DVarCol = DVarLoc.Column;
3189+
auto VarInfoLoc = VarInfo.Loc ? VarInfo.Loc : DbgInstLoc;
3190+
if (VarInfoLoc) {
3191+
auto VarLoc = VarInfoLoc->strippedForDebugVariable();
3192+
if (VarLoc != DbgInstLoc) {
3193+
auto DVarLoc = getStartLocation(VarLoc);
3194+
DVarLine = DVarLoc.Line;
3195+
DVarCol = DVarLoc.Column;
3196+
}
31933197
}
31943198
llvm::DIScope *VarScope = Scope;
31953199
if (ArgNo == 0 && VarInfo.Scope) {

0 commit comments

Comments
 (0)