-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Ast dump ignore wmo #20596
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
Ast dump ignore wmo #20596
Changes from all commits
21debbc
8d8b1ed
d31e473
3618e63
7088ff7
9aa8bd0
b515a65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1758,6 +1758,17 @@ Driver::computeCompilerMode(const DerivedArgList &Args, | |
const Arg *ArgRequiringSinglePrimaryCompile = | ||
Args.getLastArg(options::OPT_enable_source_range_dependencies); | ||
|
||
// AST dump doesn't work with `-wmo`. Since it's not common to want to dump | ||
// the AST, we assume that's the priority and ignore `-wmo`, but we warn the | ||
// user about this decision. | ||
// FIXME: AST dump also doesn't work with `-index-file`, but that fix is a bit | ||
// more complicated than this. | ||
if (Args.hasArg(options::OPT_whole_module_optimization) && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're ignoring OPT_index_file here, compared to the logic above. If that's intentional, it deserves a comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought about ignoring I'll add a FIXME saying There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh never mind, adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would just reuse the boolean from above, so that it's always consistent. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I'm reusing the boolean, but I think a separate if statement makes the code easier to understand... do you agree? |
||
Args.hasArg(options::OPT_dump_ast)) { | ||
Diags.diagnose(SourceLoc(), diag::warn_ignoring_wmo); | ||
return OutputInfo::Mode::StandardCompile; | ||
} | ||
|
||
// Override batch mode if given -wmo or -index-file. | ||
if (ArgRequiringSingleCompile) { | ||
if (BatchModeOut) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// RUN: %empty-directory(%t) | ||
|
||
|
||
// Check that -wmo is ignored when -dump-ast is present and that the AST gets | ||
// dumped to stdout, no matter the order of the options | ||
|
||
// RUN: %swiftc_driver -whole-module-optimization -dump-ast -module-name=main %S/../Inputs/empty.swift -### 2>%t/stderr_WMO_dump | %FileCheck -check-prefix CHECK-STDOUT %s | ||
// RUN: %swiftc_driver -dump-ast -whole-module-optimization -module-name=main %S/../Inputs/empty.swift -### 2>%t/stderr_dump_WMO | %FileCheck -check-prefix CHECK-STDOUT %s | ||
// RUN: %FileCheck -check-prefix CHECK-WMO %s <%t/stderr_WMO_dump | ||
// RUN: %FileCheck -check-prefix CHECK-WMO %s <%t/stderr_dump_WMO | ||
|
||
|
||
// Check that ignoring -wmo doesn't affect the output file paths for the AST | ||
// dumps | ||
|
||
// RUN: cd %t | ||
// RUN: echo ' ' > a.swift | ||
// RUN: echo ' ' > main.swift | ||
// RUN: echo '{ "a.swift": { "ast-dump": "a.ast" }, "main.swift": { "ast-dump": "main.ast" }}' > outputFileMap.json | ||
|
||
// RUN: %swiftc_driver -whole-module-optimization -dump-ast -module-name=main -output-file-map=outputFileMap.json main.swift a.swift -### 2>%t/stderr_WMO_OFM | %FileCheck -check-prefix CHECK-OFM %s | ||
// RUN: %FileCheck -check-prefix CHECK-WMO %s <%t/stderr_WMO_OFM | ||
|
||
|
||
|
||
// CHECK-WMO: warning: ignoring '-wmo' because '-dump-ast' was also specified | ||
|
||
// CHECK-STDOUT-NOT: -whole-module-optimization | ||
// CHECK-STDOUT-NOT: -wmo | ||
// CHECK-STDOUT: -dump-ast | ||
// CHECK-STDOUT: -o - | ||
|
||
// CHECK-OFM-NOT: -whole-module-optimization | ||
// CHECK-OFM-NOT: -wmo | ||
// CHECK-OFM: -dump-ast | ||
// CHECK-OFM-SAME: -o main.ast | ||
// CHECK-OFM-NEXT: -dump-ast | ||
// CHECK-OFM-SAME: -o a.ast |
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.
I think this was better the way it was before, since there are several ways to spell the flag.
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 place from which I copied this code (Driver.cpp at line 1672, just below my changes) used
ArgRequiringSingleCompile->getOption().getPrefixedName()
. As far as I can tell, this will always print "-whole-module-optimization
", even if you pass the shortened-wmo
version.The snippet I copied uses this method to distinguish between printing
-whole-module-optimization
or-index-file
, but I don't think it'll have the desired effect here unless we change the way we get the flag name too.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.
Hm, then we should probably be using
ArgRequiringSingleCompile->getSpelling()
instead, probably in both places.