-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Add frontend options to write SIL and LLVM IR as additional compilation output #84392
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
base: main
Are you sure you want to change the base?
Conversation
@swift-ci please test |
Can you add tests showing this working for multi threaded wmo? |
Ah yeah, I see the issue in performParallelIRGeneration now. I guess in multithreaded WMO we'll need one path per source file then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The added frontend logics LGTM. The test should be frontend test instead (direct swift-frontend invocation, rather than swift driver invocation, reasons below).
Driver code is optional since the legacy driver is deprecated. If you intended to make this a driver flag, please implement the logic in the new swift-driver.
Isn't there an IR linking phase, or does that not create a single IR module to print? It's going to be really tricky to deal with one path per source file in build systems when there is only a single object file that's emitted at the end. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, but I'd like to have a solution to the multi-threaded WMO issue. That's a fairly common configuration.
HelpText<"Output semantic info of current module to <path>">; | ||
|
||
def sil_output_path | ||
: Separate<["-"], "sil-output-path">, MetaVarName<"<path>">, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these are being modeled as additional supplementary outputs they also need a flag SupplementaryOutput
:
swift/include/swift/Option/Options.td
Line 58 in 391a18d
def SupplementaryOutput : OptionFlag; |
@DougGregor In multi-thread WMO, there will be one LLVM Module (.ll file) per source file and also one final product (.o/.bc) file per source file. |
That's tough for this feature, because our output file map is going to have just a single entry (since there's one output file, e.g., I have a very silly idea! In this case, can we print some split-file-like thing so that there's just one output
|
Ok, I'll explore that. I have a patch that emits separate .ll files, but doesn't address the issue @DougGregor pointed out with supplementary output filemaps. I'll update the current diff in case it solicited further feedback. |
a76fa36
to
649f134
Compare
649f134
to
3ad7231
Compare
@swift-ci please test |
3ad7231
to
a17d73d
Compare
@swift-ci please smoke test |
Please test with following pull request: @swift-ci Please test |
a17d73d
to
7c4614a
Compare
Please test with following pull request: @swift-ci Please test |
…on output. This commit adds -sil-output-path and -ir-output-path frontend options that allow generating SIL and LLVM IR files as supplementary outputs during normal compilation. These options can be useful for debugging and analysis tools workflows that need access to intermediate compilation artifacts without requiring separate compiler invocations. Expected behaviour: Primary File mode: - SIL: Generates one .sil file per source file - IR: Generates one .ll file per source file Single-threaded WMO mode: - SIL: Generates one .sil file for the entire module - IR: Generates one .ll file for the entire module Multi-threaded WMO mode: - SIL: Generates one .sil file for the entire module - IR: Generates separate .ll files per source file File Maps with WMO: - Both SIL and IR outputs using first entry's naming, which is consistent with the behaviour of other supplementary outputs. rdar://160297898
7c4614a
to
ba0ce8a
Compare
Please test with following pull request: @swift-ci Please test |
Please test with following pull request: @swift-ci Please smoke test |
This change introduces two new frontend options that enable writing intermediate representations as additional outputs during compilation:
-sil-output-path : Outputs SIL to the specified path
-ir-output-path : Outputs LLVM IR to the specified path
These options can be useful for debugging and analysis tools workflows that need the IR forms without requiring separate compiler invocations.
rdar://160297898