Skip to content

Commit 502ec8a

Browse files
Add option -sil-print-debuginfo-verbose
The option -sil-print-debuginfo-verbose will print the values of the fields, implicit, and autoGenerated for a SILLocation, as well as whether the SILLocation is considered hidden from debug information by calling SILLocation::isHiddenFromDebugInfo() (cherry picked from commit 1567386)
1 parent 08af019 commit 502ec8a

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

lib/SIL/IR/SILPrinter.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ llvm::cl::opt<bool>
7373
SILPrintDebugInfo("sil-print-debuginfo", llvm::cl::init(false),
7474
llvm::cl::desc("Include debug info in SIL output"));
7575

76+
llvm::cl::opt<bool>
77+
SILPrintDebugInfoVerbose("sil-print-debuginfo-verbose",
78+
llvm::cl::init(false),
79+
llvm::cl::desc("Print verbose debug info output"));
80+
7681
llvm::cl::opt<bool>
7782
SILPrintSourceInfo("sil-print-sourceinfo", llvm::cl::init(false),
7883
llvm::cl::desc("Include source annotation in SIL output"));
@@ -1071,6 +1076,22 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
10711076
*this << "* ";
10721077
*this << QuotedString(DL.filename) << ':' << DL.line << ':'
10731078
<< (unsigned)DL.column;
1079+
if (SILPrintDebugInfoVerbose) {
1080+
if (Loc.isImplicit())
1081+
*this << " isImplicit: " << "true";
1082+
else
1083+
*this << " isImplicit: " << "false";
1084+
1085+
if (Loc.isAutoGenerated())
1086+
*this << ", isAutoGenerated: " << "true";
1087+
else
1088+
*this << ", isAutoGenerated: " << "false";
1089+
1090+
if (Loc.isHiddenFromDebugInfo())
1091+
*this << ", isHiddenFromDebugInfo: " << "true";
1092+
else
1093+
*this << ", isHiddenFromDebugInfo: " << "false";
1094+
}
10741095
}
10751096
}
10761097

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-swift-frontend %s -Xllvm -sil-print-debuginfo -Xllvm -sil-print-debuginfo-verbose -emit-sil -Onone -g -o - | %FileCheck %s
2+
// CHECK: %0 = alloc_stack [var_decl] $Int64, var, name "x", type $Int64, loc {{.*}} isImplicit: false, isAutoGenerated: false, isHiddenFromDebugInfo: false
3+
// CHECK-NEXT: %1 = integer_literal $Builtin.Int64, 1, loc {{.*}} isImplicit: false, isAutoGenerated: false, isHiddenFromDebugInfo: false
4+
// CHECK-NEXT: %2 = struct $Int64 (%1 : $Builtin.Int64), loc {{.*}} isImplicit: false, isAutoGenerated: false, isHiddenFromDebugInfo: false
5+
// CHECK-NEXT: store %2 to %0 : $*Int64, loc {{.*}} isImplicit: false, isAutoGenerated: false, isHiddenFromDebugInfo: false
6+
// CHECK-NEXT: dealloc_stack %0 : $*Int64, loc {{.*}} isImplicit: false, isAutoGenerated: false, isHiddenFromDebugInfo: false
7+
// CHECK-NEXT: %5 = tuple (), loc {{.*}} isImplicit: false, isAutoGenerated: false, isHiddenFromDebugInfo: false
8+
// CHECK-NEXT: return %5 : $(), loc {{.*}} isImplicit: false, isAutoGenerated: false, isHiddenFromDebugInfo: false
9+
10+
func main() {
11+
var x : Int64 = 1
12+
}

0 commit comments

Comments
 (0)