Skip to content

Commit cce0b01

Browse files
Add dump overloads to print debug info for SIL.
This patch adds dump overload methods to SILInstruction, SILBasicBlock, SILFunction, and SILModule that prints the debug information as well.
1 parent 7f1792a commit cce0b01

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed

include/swift/SIL/SILBasicBlock.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,9 @@ public SwiftObjectHeader {
557557
/// Pretty-print the SILBasicBlock.
558558
void dump() const;
559559

560+
/// Pretty-print the SILBasicBlock with Debug Info.
561+
void dump(bool DebugInfo) const;
562+
560563
/// Pretty-print the SILBasicBlock with the designated stream.
561564
void print(llvm::raw_ostream &OS) const;
562565

include/swift/SIL/SILFunction.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,10 @@ class SILFunction
17041704
/// Pretty-print the SILFunction.
17051705
void dump(bool Verbose) const;
17061706
void dump() const;
1707-
1707+
1708+
/// Pretty-print the SILFunction with DebugInfo.
1709+
void dump(bool DebugInfo, bool Verbose) const;
1710+
17081711
/// Pretty-print the SILFunction.
17091712
/// Useful for dumping the function when running in a debugger.
17101713
/// Warning: no error handling is done. Fails with an assert if the file

include/swift/SIL/SILInstruction.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,9 @@ class SILInstruction : public llvm::ilist_node<SILInstruction> {
911911
void dump() const;
912912
void print(raw_ostream &OS) const;
913913

914+
/// Pretty-print the value with DebugInfo.
915+
void dump(bool DebugInfo) const;
916+
914917
/// Pretty-print the value in context, preceded by its operands (if the
915918
/// value represents the result of an instruction) and followed by its
916919
/// users.

include/swift/SIL/SILModule.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,9 @@ class SILModule {
975975
/// Pretty-print the module.
976976
void dump(bool Verbose = false) const;
977977

978+
/// Pretty-print the module with DebugInfo.
979+
void dump(bool DebugInfo, bool Verbose = false) const;
980+
978981
/// Pretty-print the module to a file.
979982
/// Useful for dumping the module when running in a debugger.
980983
/// Warning: no error handling is done. Fails with an assert if the file

lib/SIL/IR/SILPrinter.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3336,6 +3336,12 @@ void SILInstruction::dump() const {
33363336
print(llvm::errs());
33373337
}
33383338

3339+
void SILInstruction::dump(bool DebugInfo) const {
3340+
SILPrintContext Ctx(llvm::errs(), /*Verbose*/ false, /*SortedSIL*/ false,
3341+
DebugInfo, /*PrintFullConvention*/ false);
3342+
SILPrinter(Ctx).print(this);
3343+
}
3344+
33393345
void SingleValueInstruction::dump() const {
33403346
SILInstruction::dump();
33413347
}
@@ -3354,6 +3360,13 @@ void SILBasicBlock::dump() const {
33543360
print(llvm::errs());
33553361
}
33563362

3363+
/// Pretty-print the SILBasicBlock to errs with Debug Info.
3364+
void SILBasicBlock::dump(bool DebugInfo) const {
3365+
SILPrintContext Ctx(llvm::errs(), /*Verbose*/ false, /*SortedSIL*/ false,
3366+
DebugInfo, /*PrintFullConvention*/ false);
3367+
SILPrinter(Ctx).print(this);
3368+
}
3369+
33573370
/// Pretty-print the SILBasicBlock to the designated stream.
33583371
void SILBasicBlock::print(raw_ostream &OS) const {
33593372
SILPrintContext Ctx(OS);
@@ -3408,6 +3421,13 @@ void SILFunction::dump() const {
34083421
dump(false);
34093422
}
34103423

3424+
/// Pretty-print the SILFunction to errs.
3425+
void SILFunction::dump(bool DebugInfo, bool Verbose) const {
3426+
SILPrintContext Ctx(llvm::errs(), Verbose, /*SortedSIL*/ false, DebugInfo,
3427+
/*PrintFullConvention*/ false);
3428+
print(Ctx);
3429+
}
3430+
34113431
void SILFunction::dump(const char *FileName) const {
34123432
std::error_code EC;
34133433
llvm::raw_fd_ostream os(FileName, EC, llvm::sys::fs::OpenFlags::OF_None);
@@ -3732,6 +3752,13 @@ void SILModule::dump(bool Verbose) const {
37323752
print(Ctx);
37333753
}
37343754

3755+
/// Pretty-print the SILModule to errs with DebugInfo.
3756+
void SILModule::dump(bool DebugInfo, bool Verbose) const {
3757+
SILPrintContext Ctx(llvm::errs(), Verbose, /*SortedSIL*/ false, DebugInfo,
3758+
/*PrintFullConvention*/ false);
3759+
print(Ctx);
3760+
}
3761+
37353762
void SILModule::dump(const char *FileName, bool Verbose,
37363763
bool PrintASTDecls) const {
37373764
std::error_code EC;

0 commit comments

Comments
 (0)