-
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
Conversation
Cc @jrose-apple, who's been following these changes. |
@@ -42,91 +42,92 @@ | |||
DIAG(REMARK,ID,Options,Text,Signature) | |||
#endif | |||
|
|||
WARNING(warning_parallel_execution_not_supported,none, | |||
WARNING(warning_parallel_execution_not_supported, none, |
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.
Please don't include formatting changes for code you're not touching.
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.
Oh, ok. I thought it'd be useful to do this as I was adding a new warning, but yeah, maybe not.
// AST dump doesn't work in WMO. Since it's not common want to dump the AST, | ||
// we assume that's the priority and ignore `-wmo`, but we warn the user about | ||
// this decision. | ||
if (Args.hasArg(options::OPT_whole_module_optimization) && |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about ignoring OPT_index_file
too, but that seems to be a bit more complicated than just adding it in this check, and it's probably not as important (no one seems to have complained about it or tried to fix it so far).
I'll add a FIXME saying OPT_index_file
should probably also be ignored in the future.
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.
Oh never mind, adding -index-file
to the check seems to have worked after all.
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 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 comment
The 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?
lib/Driver/Driver.cpp
Outdated
@@ -1653,6 +1653,15 @@ Driver::computeCompilerMode(const DerivedArgList &Args, | |||
if (!ArgRequiringSingleCompile) | |||
return OutputInfo::Mode::StandardCompile; | |||
|
|||
// AST dump doesn't work in WMO. Since it's not common want to dump the 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.
Typo: "not common want to".
Should I do a rebase on master every time I update the pull request? It seems like the right thing to do, but at the same time it seems to make github act a little weird. |
I think most of us do do force pushes, which is 90% of GitHub's weirdness, but you don't need to rebase every time if there's not actually a conflict. |
Thanks, this looks good. Can you add a test case for it in test/Driver/ somewhere? |
Heheh, adding tests reminded me why I hadn't ignored This seems to happen because the compiler checks for the last argument ( |
WARNING(warn_ignoring_single_compile, none, | ||
"ignoring '%0' because '-dump-ast' was also specified", (StringRef)) | ||
WARNING(warn_ignoring_wmo, none, | ||
"ignoring '-wmo' because '-dump-ast' was also specified", ()) |
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.
@vinivendra Are you still interested in pursuing this change? |
@CodaFi Yes! |
It looks like this diff still applies just fine. You should probably rebase and retest to make sure, but we don't have to start over if you don't want to. Jordan still has unaddressed feedback, though, which is the most important thing. If you would like, I can close this and file an SR to let somebody else try their hand at this. |
I spoke too soon. This needs a quick rebase. |
You're right, these changes still apply well. I just performed a rebase and everything looks OK. As for Jordan's feedback (where he suggested using
And I tried this, but the program crashes:
Any ideas? |
Weird. I thought that was the point of I'm no longer at Apple at this point, but there's not too much here, and this diagnostic bit shouldn't hold up the rest of the patch if it's not coming together easily. If you rebase, @CodaFi or @brentdax can do the final bit of shepherding it in. |
Ignoring both `-wmo` and `-index-file` will be harder than just `-wmo`. This is because when calling the compiler and passing `-index-file` after `-dump-ast`, the option gets un-ignored by `Driver::buildOutputInfo`. Therefore, we will just ignore `-wmo` for now.
3f3ec79
to
b515a65
Compare
Ok then! It's rebased and should be ready to merge. |
Will manually squash this down when it passes @swift-ci please smoke test |
I don't mean to pressure anyone, but it seems the tests have passed - and I'm afraid if we wait much longer we'll need a new rebase and new tests. Is this still OK to merge? |
⛵️ |
The current Dump AST methods dump the AST for primary files or, if there are no primary files, the main file. This behavior is weird on WMO builds, which don't have the concept of primary files. In that case, the compiler currently dumps the main file and ignores all other files.
Since it's uncommon to have the
-dump-ast
argument in an invocation, it is assumed to be a priority over-wmo
. Therefore, the decision is to ignore-wmo
when-dump-ast
is also present, printing a warning for the user and dumping all files normally.This was briefly discussed on PR-20392, where it was decided that a
FIXME
would be added tolib/FrontendTool/FrontendTool.cpp
and the change would be delayed to a separate pull request.This pull request executes the necessary changes on
Driver.cpp
andDiagnosticsDriver.def
and removes the FIXME fromFrontendTool.cpp
. It also fixes a bit of the code style inDiagnosticsDriver.def
.