Skip to content

Add dump overloads to print debug info for SIL. #80079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/swift/SIL/SILBasicBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,9 @@ public SwiftObjectHeader {
/// Pretty-print the SILBasicBlock.
void dump() const;

/// Pretty-print the SILBasicBlock with Debug Info.
void dump(bool DebugInfo) const;

/// Pretty-print the SILBasicBlock with the designated stream.
void print(llvm::raw_ostream &OS) const;

Expand Down
5 changes: 4 additions & 1 deletion include/swift/SIL/SILFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,10 @@ class SILFunction
/// Pretty-print the SILFunction.
void dump(bool Verbose) const;
void dump() const;


/// Pretty-print the SILFunction with DebugInfo.
void dump(bool Verbose, bool DebugInfo) const;

/// Pretty-print the SILFunction.
/// Useful for dumping the function when running in a debugger.
/// Warning: no error handling is done. Fails with an assert if the file
Expand Down
3 changes: 3 additions & 0 deletions include/swift/SIL/SILInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,9 @@ class SILInstruction : public llvm::ilist_node<SILInstruction> {
void dump() const;
void print(raw_ostream &OS) const;

/// Pretty-print the value with DebugInfo.
void dump(bool DebugInfo) const;

/// Pretty-print the value in context, preceded by its operands (if the
/// value represents the result of an instruction) and followed by its
/// users.
Expand Down
3 changes: 3 additions & 0 deletions include/swift/SIL/SILModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,9 @@ class SILModule {
/// Pretty-print the module.
void dump(bool Verbose = false) const;

/// Pretty-print the module with DebugInfo.
void dump(bool Verbose, bool DebugInfo) const;

/// Pretty-print the module to a file.
/// Useful for dumping the module when running in a debugger.
/// Warning: no error handling is done. Fails with an assert if the file
Expand Down
27 changes: 27 additions & 0 deletions lib/SIL/IR/SILPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3336,6 +3336,12 @@ void SILInstruction::dump() const {
print(llvm::errs());
}

void SILInstruction::dump(bool DebugInfo) const {
SILPrintContext Ctx(llvm::errs(), /*Verbose*/ false, /*SortedSIL*/ false,
DebugInfo, /*PrintFullConvention*/ false);
SILPrinter(Ctx).print(this);
}

void SingleValueInstruction::dump() const {
SILInstruction::dump();
}
Expand All @@ -3354,6 +3360,13 @@ void SILBasicBlock::dump() const {
print(llvm::errs());
}

/// Pretty-print the SILBasicBlock to errs with Debug Info.
void SILBasicBlock::dump(bool DebugInfo) const {
SILPrintContext Ctx(llvm::errs(), /*Verbose*/ false, /*SortedSIL*/ false,
DebugInfo, /*PrintFullConvention*/ false);
SILPrinter(Ctx).print(this);
}

/// Pretty-print the SILBasicBlock to the designated stream.
void SILBasicBlock::print(raw_ostream &OS) const {
SILPrintContext Ctx(OS);
Expand Down Expand Up @@ -3408,6 +3421,13 @@ void SILFunction::dump() const {
dump(false);
}

/// Pretty-print the SILFunction to errs.
void SILFunction::dump(bool Verbose, bool DebugInfo) const {
SILPrintContext Ctx(llvm::errs(), Verbose, /*SortedSIL*/ false, DebugInfo,
/*PrintFullConvention*/ false);
print(Ctx);
}

void SILFunction::dump(const char *FileName) const {
std::error_code EC;
llvm::raw_fd_ostream os(FileName, EC, llvm::sys::fs::OpenFlags::OF_None);
Expand Down Expand Up @@ -3732,6 +3752,13 @@ void SILModule::dump(bool Verbose) const {
print(Ctx);
}

/// Pretty-print the SILModule to errs with DebugInfo.
void SILModule::dump(bool Verbose, bool DebugInfo) const {
SILPrintContext Ctx(llvm::errs(), Verbose, /*SortedSIL*/ false, DebugInfo,
/*PrintFullConvention*/ false);
print(Ctx);
}

void SILModule::dump(const char *FileName, bool Verbose,
bool PrintASTDecls) const {
std::error_code EC;
Expand Down