-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[ASTWriter] Detect more non-affecting FileIDs to reduce source location duplication #112015
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
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b6508a1
[ASTWriter] Detect more non-affecting FileIDs to reduce duplication o…
ilya-biryukov dc19161
fixup! [ASTWriter] Detect more non-affecting FileIDs to reduce duplic…
ilya-biryukov 4361ca5
fixup! [ASTWriter] Detect more non-affecting FileIDs to reduce duplic…
ilya-biryukov f0336e0
Merge remote-tracking branch 'origin/main'
ilya-biryukov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
clang/test/Modules/prune-non-affecting-module-map-repeated.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| // Check that the same module map file passed to -fmodule-map-file *and* | ||
| // available from one of the `-fmodule-file` does not allocate extra source | ||
| // location space. This optimization is important for using module maps in | ||
| // large codebases to avoid running out of source location space. | ||
|
|
||
| // RUN: rm -rf %t && mkdir %t | ||
| // RUN: split-file %s %t | ||
|
|
||
| // RUN: %clang_cc1 -xc++ -fmodules -fno-implicit-modules -fmodule-map-file=%t/base.map -fmodule-name=base -emit-module %t/base.map -o %t/base.pcm | ||
| // RUN: %clang_cc1 -xc++ -fmodules -fno-implicit-modules \ | ||
| // RUN: -fmodule-map-file=%t/base.map -fmodule-map-file=%t/mod1.map \ | ||
| // RUN: -fmodule-file=%t/base.pcm \ | ||
| // RUN: -fmodule-name=mod1 -emit-module %t/mod1.map -o %t/mod1.pcm | ||
| // RUN: %clang_cc1 -xc++ -fmodules -fno-implicit-modules \ | ||
| // RUN: -fmodule-map-file=%t/base.map -fmodule-map-file=%t/mod1.map -fmodule-map-file=%t/mod2.map \ | ||
| // RUN: -fmodule-file=%t/mod1.pcm \ | ||
| // RUN: -fmodule-name=mod2 -emit-module %t/mod2.map -o %t/mod2.pcm | ||
| // RUN: %clang_cc1 -xc++ -fmodules -fno-implicit-modules \ | ||
| // RUN: -fmodule-map-file=%t/base.map -fmodule-map-file=%t/mod2.map -fmodule-map-file=%t/mod3.map \ | ||
| // RUN: -fmodule-file=%t/mod2.pcm \ | ||
| // RUN: -fmodule-name=mod3 -emit-module %t/mod3.map -o %t/mod3.pcm | ||
| // RUN: %clang_cc1 -xc++ -fmodules -fno-implicit-modules \ | ||
| // RUN: -fmodule-map-file=%t/base.map -fmodule-map-file=%t/mod3.map -fmodule-map-file=%t/mod4.map \ | ||
| // RUN: -fmodule-file=%t/mod3.pcm \ | ||
| // RUN: -fmodule-name=mod4 -emit-module %t/mod4.map -o %t/mod4.pcm | ||
| // RUN: %clang_cc1 -xc++ -fmodules -fno-implicit-modules -fmodule-map-file=%t/base.map -fmodule-map-file=%t/mod4.map -fmodule-file=%t/mod4.pcm -fsyntax-only -verify %t/check_slocs.cc | ||
|
|
||
| //--- base.map | ||
| module base { header "vector.h" } | ||
| //--- mod1.map | ||
| module mod1 { header "mod1.h" } | ||
| //--- mod2.map | ||
| module mod2 { header "mod2.h" } | ||
| //--- mod3.map | ||
| module mod3 { header "mod3.h" } | ||
| //--- mod4.map | ||
| module mod4 { header "mod4.h" } | ||
| //--- check_slocs.cc | ||
| #include "mod4.h" | ||
| #pragma clang __debug sloc_usage // expected-remark {{source manager location address space usage}} | ||
| // expected-note@* {{% of available space}} | ||
|
|
||
| // Module map files files that were specified on the command line are entered twice (once when parsing command-line, once loaded from the .pcm) | ||
| // Those that not specified on the command line must be entered once. | ||
|
|
||
| // [email protected]:1 {{file entered 2 times}} | ||
| // [email protected]:1 {{file entered 2 times}} | ||
| // [email protected]:1 {{file entered 1 time}} | ||
| // [email protected]:1 {{file entered 1 time}} | ||
| // [email protected]:1 {{file entered 1 time}} | ||
| // expected-note@* + {{file entered}} | ||
|
|
||
|
|
||
| //--- vector.h | ||
| #ifndef VECTOR_H | ||
| #define VECTOR_H | ||
| #endif | ||
|
|
||
| //--- mod1.h | ||
| #ifndef MOD1 | ||
| #define MOD1 | ||
| #include "vector.h" | ||
| int mod1(); | ||
| #endif | ||
| //--- mod2.h | ||
| #ifndef MOD2 | ||
| #define MOD2 | ||
| #include "vector.h" | ||
| #include "mod1.h" | ||
| int mod2(); | ||
| #endif | ||
| //--- mod3.h | ||
| #ifndef MOD3 | ||
| #define MOD3 | ||
| #include "vector.h" | ||
| #include "mod2.h" | ||
| int mod3(); | ||
| #endif | ||
| //--- mod4.h | ||
| #ifndef MOD4 | ||
| #define MOD4 | ||
| #include "vector.h" | ||
| #include "mod3.h" | ||
| int mod4(); | ||
| #endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 it's fairly important to not report those on command lines. On Darwin, we have one module map that includes lots of other module maps, so listing them all blows up the command line length (and is unnecessary).
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.
Thanks for pointing this out, I did not realize this was important.
That would require digging into scan-deps a bit, let me try to see if it's possible to match the previous behavior.
In general, I feel that rewriting ModuleDepCollector in a way that walks over the module dependency graph rather than the
InputFileis probably the right solution in the long run, but I'm not sure if it's an easy change to make. (I still don't have a good grasp on what outputs are generally expected here, relying on something as internal asInputFilein the serialized AST was a surprise).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've updated the code to keep the old behavior in that case, PTAL.