Skip to content

Commit 65a515b

Browse files
Merge pull request #80079 from rastogishubham/EnhanceDump
Add dump overloads to print debug info for SIL.
2 parents 431138b + b016c74 commit 65a515b

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed

include/swift/SIL/SILBasicBlock.h

+3
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

+4-1
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 Verbose, bool DebugInfo) 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

+3
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

+3
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,9 @@ class SILModule {
10121012
/// Pretty-print the module.
10131013
void dump(bool Verbose = false) const;
10141014

1015+
/// Pretty-print the module with DebugInfo.
1016+
void dump(bool Verbose, bool DebugInfo) const;
1017+
10151018
/// Pretty-print the module to a file.
10161019
/// Useful for dumping the module when running in a debugger.
10171020
/// Warning: no error handling is done. Fails with an assert if the file

lib/SIL/IR/SILPrinter.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -3359,6 +3359,12 @@ void SILInstruction::dump() const {
33593359
print(llvm::errs());
33603360
}
33613361

3362+
void SILInstruction::dump(bool DebugInfo) const {
3363+
SILPrintContext Ctx(llvm::errs(), /*Verbose*/ false, /*SortedSIL*/ false,
3364+
DebugInfo, /*PrintFullConvention*/ false);
3365+
SILPrinter(Ctx).print(this);
3366+
}
3367+
33623368
void SingleValueInstruction::dump() const {
33633369
SILInstruction::dump();
33643370
}
@@ -3377,6 +3383,13 @@ void SILBasicBlock::dump() const {
33773383
print(llvm::errs());
33783384
}
33793385

3386+
/// Pretty-print the SILBasicBlock to errs with Debug Info.
3387+
void SILBasicBlock::dump(bool DebugInfo) const {
3388+
SILPrintContext Ctx(llvm::errs(), /*Verbose*/ false, /*SortedSIL*/ false,
3389+
DebugInfo, /*PrintFullConvention*/ false);
3390+
SILPrinter(Ctx).print(this);
3391+
}
3392+
33803393
/// Pretty-print the SILBasicBlock to the designated stream.
33813394
void SILBasicBlock::print(raw_ostream &OS) const {
33823395
SILPrintContext Ctx(OS);
@@ -3431,6 +3444,13 @@ void SILFunction::dump() const {
34313444
dump(false);
34323445
}
34333446

3447+
/// Pretty-print the SILFunction to errs.
3448+
void SILFunction::dump(bool Verbose, bool DebugInfo) const {
3449+
SILPrintContext Ctx(llvm::errs(), Verbose, /*SortedSIL*/ false, DebugInfo,
3450+
/*PrintFullConvention*/ false);
3451+
print(Ctx);
3452+
}
3453+
34343454
void SILFunction::dump(const char *FileName) const {
34353455
std::error_code EC;
34363456
llvm::raw_fd_ostream os(FileName, EC, llvm::sys::fs::OpenFlags::OF_None);
@@ -3755,6 +3775,13 @@ void SILModule::dump(bool Verbose) const {
37553775
print(Ctx);
37563776
}
37573777

3778+
/// Pretty-print the SILModule to errs with DebugInfo.
3779+
void SILModule::dump(bool Verbose, bool DebugInfo) const {
3780+
SILPrintContext Ctx(llvm::errs(), Verbose, /*SortedSIL*/ false, DebugInfo,
3781+
/*PrintFullConvention*/ false);
3782+
print(Ctx);
3783+
}
3784+
37583785
void SILModule::dump(const char *FileName, bool Verbose,
37593786
bool PrintASTDecls) const {
37603787
std::error_code EC;

0 commit comments

Comments
 (0)