-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[clang][modules] HeaderSearch::MarkFileModuleHeader sets textual headers' HeaderFileInfo non-external when it shouldn't #89005
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
[clang][modules] HeaderSearch::MarkFileModuleHeader sets textual headers' HeaderFileInfo non-external when it shouldn't #89005
Conversation
@llvm/pr-subscribers-clang Author: Ian Anderson (ian-twilightcoder) ChangesHeaderSearch::MarkFileModuleHeader is no longer properly checking for no-changes, and so creates a new HeaderFileInfo for every Full diff: https://github.com/llvm/llvm-project/pull/89005.diff 1 Files Affected:
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 0632882b296146..9409b97ba0e64a 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1313,6 +1313,14 @@ OptionalFileEntryRef HeaderSearch::LookupSubframeworkHeader(
// File Info Management.
//===----------------------------------------------------------------------===//
+static bool
+headerFileInfoModuleBitsMatchRole(const HeaderFileInfo *HFI,
+ ModuleMap::ModuleHeaderRole Role) {
+ return (HFI->isModuleHeader == ModuleMap::isModular(Role)) &&
+ (HFI->isTextualModuleHeader ==
+ ((Role & ModuleMap::TextualHeader) != 0));
+}
+
static void mergeHeaderFileInfoModuleBits(HeaderFileInfo &HFI,
bool isModuleHeader,
bool isTextualModuleHeader) {
@@ -1432,7 +1440,7 @@ void HeaderSearch::MarkFileModuleHeader(FileEntryRef FE,
if ((Role & ModuleMap::ExcludedHeader))
return;
auto *HFI = getExistingFileInfo(FE);
- if (HFI && HFI->isModuleHeader)
+ if (HFI && headerFileInfoModuleBitsMatchRole(HFI, Role))
return;
}
|
I don't really know a great way to write a test for this. If someone could point me at a similar existing test or has an idea how to write a new test that would be much appreciated. |
@ilya-biryukov can you check that this fixes your running out of source location space problem please? |
As a test, maybe you could probe the resulting PCM with |
Just tried it. The patch as is did not help. Changing from |
Until recently that function still consulted |
Does it not help because |
f45cb72
to
0ea2af8
Compare
Ok this one should fix the logic I think. @ilya-biryukov can you give this a try please? |
What would I be looking for? Presumably the problem is we import the same module twice but fail to find the built pcm in the module cache and so we build it again? I don't know what else would cause runaway growth of pcm files... I actually don't really understand the problem Ilya is hitting... But Richard found (2 now!) good bugs in my code and I'm hoping fixing that will fix Ilya's problem. |
Also note that if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
continue; Since textual headers from other modules have |
#83660 shouldn't affect that logic. |
@ilya-biryukov sorry to ping you again, just nobody else knows how to test this. |
Ilya is out on vacation, I'm able to test this and will get started on that now (apologies for delay & thanks for digging into this) |
Unfortunately with this patch I'm still seeing the same source-location-exhausted error. |
Damn I really thought that was going to be the one. If you have any way I could reproduce or better write a test that would be great. |
Can you try applying #89428 as well? I think we would need both in order to prune the module map from the serialized SLocEntries. |
Hmm, I locally reverted #87849 and still see the same issue. In any case I'll try it, and then work on constructing a reproducer (so far I've been mostly treating this as a black box) |
#89441 might be of interest too. |
#89441 fixes our build problems, with or without this patch applied. It's possible this patch makes things better - I haven't checked for actual sloc usage yet, just whether the build fails. So I'll focus on understanding that one and then return here. (I think I'm close to a sharable reproducer too) |
Just so you're aware, it's possible that #87848 introduced some unexpected behavior change. It would be good to check if your issues are caused just by one patch in isolation or by a combination of more patches that landed recently. |
Thanks for the pointer to 87848 - reverting that one locally doesn't help though, even in combination with applying #89005 and #89428. So this change isn't on the critical path to fixing our builds, but still much appreciated and will take a look now. Unsurprisingly, the builds that hit this limit are big and slow :-) Here's a reproducer that seems to capture our case well: modulegen.zip Good
Bad
|
0ea2af8
to
45e7409
Compare
From Jan:
|
45e7409
to
011ff5a
Compare
We tried this, but it seems that by the time the modules compile, everything ends up being local instead of external anyway. I think a unit test is probably good enough for this one since we aren't even sure what the practical consequence is of this bug. |
011ff5a
to
f6bcc20
Compare
✅ With the latest revision this PR passed the C/C++ code formatter. |
bdb3519
to
eb296a4
Compare
…ers' HeaderFileInfo non-external when it shouldn't HeaderSearch::MarkFileModuleHeader is no longer properly checking for no-changes, and so sets the HeaderFileInfo for every `textual header` to non-external.
eb296a4
to
85df42b
Compare
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.
LGTM!
The only test failure is in CodeGen/PowerPC/subreg-lanemasks.mir and doesn't look related to this change. |
HeaderSearch::MarkFileModuleHeader is no longer properly checking for no-changes, and so sets the HeaderFileInfo for every
textual header
to non-external.