Skip to content

[SIL][Frontend] Simplify debug info generation flow for SIL files #38167

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
Jul 1, 2021

Conversation

mshockwave
Copy link
Contributor

@mshockwave mshockwave commented Jun 29, 2021

  • If any of the -g<kind> flag is given -- except -gnone, debug info will be printed into every generated SIL files.
  • The -gsil is deprecated in favor of -sil-based-debuginfo to avoid confusion with -g, -gnone, -gline-tables-only etc. The SILDebugInfoGenerator Pass now generates intermediate SIL file with name ".sil_dbg_.sil". Other functionalities of that Pass remain the same.

For -sil-based-debuginfo, I tried to avoid generating intermediate SIL file (i.e. *.sil_dbg_*.sil) if the input is already a SIL file -- the idea was to modify SILParser if the input is SIL. But it turned out to take non-trivial amount of changes in SILParser, which is probably not worth it for a feature that is less-frequently used. So I eventually fallback to using the existing round-trip-solution by SILDebugInfoGenerator, which always generates an intermediates SIL file, regardless of the input file type.

This PR should be synchronized with swiftlang/swift-driver#737

@mshockwave
Copy link
Contributor Author

@swift-ci test

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.

Thanks, this looks good, and is makes the options less confusion.

@mshockwave mshockwave force-pushed the dev-sil-deserialize branch from a3c616d to 3aa9a26 Compare June 30, 2021 00:19
@mshockwave
Copy link
Contributor Author

Alright, instead of removing -gsil, now I keep the flag, make it no-op, and print a warning message regarding the deprecation. Not sure if this is the best solution so feel free to provide some suggestions here.

@mshockwave
Copy link
Contributor Author

@swift-ci test

@mshockwave mshockwave force-pushed the dev-sil-deserialize branch from 3aa9a26 to 73fd231 Compare June 30, 2021 18:46
@mshockwave mshockwave changed the title [SIL][Driver] Simplify debug info generation flow for SIL files [SIL][Frontend] Simplify debug info generation flow for SIL files Jun 30, 2021
@mshockwave
Copy link
Contributor Author

I just simplified the flags passed from driver: No extra -Xllvm -sil-print-debuginfo flags will be passed from driver anymore if -g is given. Instead, if any of the debugger level is given, the frontend will populate the newly-added SILOptions::PrintDebugInfo flag, which will later be used by SILPrinter to print debug info into SIL files.

@mshockwave
Copy link
Contributor Author

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 73fd2319da0edca75742285c1eee61e57d893d6f

 - If any of the `-g<kind>` flag is given -- except `-gnone`, debug
   info will be printed into every generated SIL files.
 - The `-gsil` is deprecated in favor of `-sil-based-debuginfo`. The
   SILDebugInfoGenerator Pass now generates intermediate SIL file with
   name "<output file>.sil_dbg_<n>.sil". Other functionalities of that
   Pass remain the same.
@mshockwave mshockwave force-pushed the dev-sil-deserialize branch from 73fd231 to d00a6cc Compare July 1, 2021 00:22
@mshockwave
Copy link
Contributor Author

Fix test failure in SILOptimizer/outliner.swift by updating the CHECK directive to consider the debug location.
@swift-ci test

@mshockwave mshockwave merged commit 4ec8ee8 into swiftlang:main Jul 1, 2021
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.

6 participants