[PATCH] D136779: [clang][AST] make FunctionProtoType::Profile consistent for FoldingSet
Troy Johnson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 26 12:05:42 PDT 2022
troyj created this revision.
troyj added a reviewer: bruno.
Herald added a project: All.
troyj requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
This patch changes the Profile function to match the FunctionProtoType constructor, which uses epi.ExceptionSpec.SourceDecl and not epi.ExceptionSpec.SourceDecl->getCanonicalDecl(). This change eliminates an inconsistency that was observed within the FunctionProtoTypes set by adding a verification function to FoldingSet to assert that all items in the set still hash to their current bucket. Asserting this verification showed that some FunctionProtoTypes no longer hashed to their original bucket. This inconsistency was not catastrophic because of self-correction -- FoldingSet does not store hashes and recomputes them whenever it rebuckets. Thus, it's not possible to observe the issue immediately after rebucketing. Comparing the before and after profiles of a FunctionProtoType that was in the wrong bucket showed that the only part of the profile that changed was epi.ExceptionSpec.SourceDecl->getCanonicalDecl(). After changing the profile function to match the constructor, no incorrectly bucketed FunctionProtoTypes were observed in a TU with ~2.6M prototypes.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D136779
Files:
clang/lib/AST/Type.cpp
Index: clang/lib/AST/Type.cpp
===================================================================
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -3385,7 +3385,7 @@
epi.ExceptionSpec.NoexceptExpr->Profile(ID, Context, Canonical);
} else if (epi.ExceptionSpec.Type == EST_Uninstantiated ||
epi.ExceptionSpec.Type == EST_Unevaluated) {
- ID.AddPointer(epi.ExceptionSpec.SourceDecl->getCanonicalDecl());
+ ID.AddPointer(epi.ExceptionSpec.SourceDecl);
}
if (epi.ExtParameterInfos) {
for (unsigned i = 0; i != NumParams; ++i)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136779.470889.patch
Type: text/x-patch
Size: 569 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221026/371ac275/attachment.bin>
More information about the cfe-commits
mailing list