-
Notifications
You must be signed in to change notification settings - Fork 15k
[AST] Match the FoldingSetNodeID computed before and after creating TypedefType #157662
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
Conversation
…ypedefType At some point the call to static `TypedefType::Profile` inside `ASTContext::getTypedefType` got out-of-sync with the non-static `TypedefType::Profile`. This seem to cause some bad performance patterns with `FoldingSet` and are seeing 10x increases in compile times in certain scenarios. After this commit, the compile times go back to normal. This commit does not include tests or benchmarks because we want to land this ASAP to unbreak our deployment. I will work on adding asserts, tests or benchmarks in a follow-up.
@llvm/pr-subscribers-clang Author: Ilya Biryukov (ilya-biryukov) ChangesAt some point the call to static This seem to cause some bad performance patterns with This commit does not include tests or benchmarks because we want to land this ASAP to unbreak our deployment. I will work on adding asserts, tests or benchmarks in a follow-up. Full diff: https://github.com/llvm/llvm-project/pull/157662.diff 1 Files Affected:
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index dca05b41aee77..c04de4e132739 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -5316,7 +5316,8 @@ ASTContext::getTypedefType(ElaboratedTypeKeyword Keyword,
}
llvm::FoldingSetNodeID ID;
- TypedefType::Profile(ID, Keyword, Qualifier, Decl, UnderlyingType);
+ TypedefType::Profile(ID, Keyword, Qualifier, Decl,
+ *TypeMatchesDeclOrNone ? QualType() : UnderlyingType);
void *InsertPos = nullptr;
if (FoldingSetPlaceholder<TypedefType> *Placeholder =
|
cc @mizvekov as I believe this is probably related to the new representation of |
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.
Thank you for the fix!
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.
ugh this looks quite fragile (not your fix but rather having multiple ways to call profile), i am worried we might have divergences in other places as well :(
i think it would be nice to handle that in a more principled way for the future. thanks for the fix!
I am definitely worried as well and was trying to figure out a generic way to assert the two I'll prepare a PR to propose that so we can discuss this further. |
Sent out a draft PR with an assert that seems to catch more cases like this: #157692, let's discuss further there. |
At some point the call to static
TypedefType::Profile
insideASTContext::getTypedefType
got out-of-sync with the non-staticTypedefType::Profile
.This seem to cause some bad performance patterns with
FoldingSet
and are seeing 10x increases in compile times in certain scenarios. After this commit, the compile times go back to normal.This commit does not include tests or benchmarks because we want to land this ASAP to unbreak our deployment. I will work on adding asserts, tests or benchmarks in a follow-up.