Skip to content
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

[sil] Add flexibility to SILPrinter to allow for full SIL types to printed out in the debugger and programatically without touching the global flag. #78480

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gottesmm
Copy link
Contributor

@gottesmm gottesmm commented Jan 7, 2025

This PR adds flexibility to the SIL printer API such that users can emit full SIL types without touching the global flag. This is implemented by changing SILPrinterContext to take an OptionSet instead of boolean flags and adding a flag to SILPrinterContext that forces the behavior. The default behavior is left alone and is controlled via the global flag.

By doing this, without changing any normal path behavior, we allow for:

  1. Compiler developers in the debugger to dump the full types without needing to restart the compilation session to set the global flag.
  2. In certain cases when emitting logging specific to an optimization pass, it is useful to emit full types to enable quick triaging. This occurs in RegionAnalysis where we do a quick dump of the entire function before we emit logging to give the user a more global look at the function. It is not intended to be used to get actual output (that is a job for -sil-print-function) but rather just for quick scanning to get a sense of what types/etc are being used. This is especially useful when looking at a large piece of code where types are defined very early in the function (several pages up).

@gottesmm
Copy link
Contributor Author

gottesmm commented Jan 7, 2025

@swift-ci test

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flag value seems to be wrong.
Otherwise lgtm

include/swift/SIL/SILPrintContext.h Outdated Show resolved Hide resolved
@gottesmm gottesmm force-pushed the pr-2e966caa607714d3609428172c32939fb183ff49 branch from de5423a to 8bd60da Compare January 8, 2025 19:22
@gottesmm
Copy link
Contributor Author

gottesmm commented Jan 8, 2025

@swift-ci smoke test

…f boolean flags.

This will allow for more control of how SIL is printed in logging messages and
also will make it easier to feed flags through SILFunction::dump and friends.
…o set the global flag.

This is useful if one wants to dump out state in the debugger or programatically
dump out SIL with all of the types without changing the behavior in the rest of
the compiler.

My intention is to use this to emit full types in a little bit of the logging in
SendNonSendable where seeing the full type speeds up debugging in the context of
debugging user code and where in truth, I will never ever want to suppress types
and will not use this to create test cases. It is just for quick scanning.
@gottesmm gottesmm force-pushed the pr-2e966caa607714d3609428172c32939fb183ff49 branch from 8bd60da to c83c4cd Compare January 8, 2025 19:25
@gottesmm
Copy link
Contributor Author

gottesmm commented Jan 8, 2025

@swift-ci smoke test

@gottesmm gottesmm enabled auto-merge January 8, 2025 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants