Skip to content

Add compile flag for lost debug variables statistics #73334

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 3 commits into from
May 2, 2024

Conversation

Snowy1803
Copy link
Member

@Snowy1803 Snowy1803 commented Apr 30, 2024

Add a new -sil-stats-lost-variables flag to record statistics about lost debug variables. In combination with -sil-stats-output-file, it is possible to get a log file with the lost debug variables for each pass and function.

Using the included utils/process-stats-lost-variables, it is possible to get the number of lost variables for each pass, on a complete project.

It is possible to run it with the source compatibility test suite:

swift-source-compat-suite/runner.py --swift-branch main --projects swift-source-compat-suite/projects.json --include-repos 'path == "PROJECT_NAME"' --include-actions 'action.startswith("Build")' --swiftc path/to/swiftc --add-swift-flags '-Xllvm -sil-stats-lost-variables -Xllvm -sil-stats-output-file=/tmp/lostvariables.log'
swift/utils/process-stats-lost-variables /tmp/lostvariables.log

The compiler creates a CSV with the following format:

function, lostvars, [Stage Name], [Pass Name], [Pass Number], [Lost variables count], [Pass duration], [Mangled function name]

The process-stats-lost-variables creates a simpler CSV summarizing it:

[Pass name], [Lost variables]

The process-stats-lost-variables script also adds a header so it can easily be imported into Numbers.

Copy link
Contributor

@adrian-prantl adrian-prantl left a comment

Choose a reason for hiding this comment

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

This is great and going to be very useful! Can you add a paragraph to the debug info howto and the how to debug the compiler document?

@Snowy1803
Copy link
Member Author

@swift-ci please test

@Snowy1803 Snowy1803 merged commit d451c3e into swiftlang:main May 2, 2024
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