aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaModule.cpp
diff options
context:
space:
mode:
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>2024-04-17 16:40:00 +0800
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>2024-04-18 11:00:28 +0800
commitf2695a1c2f561da42b973187a254b6eeb7da76a9 (patch)
treee651bbcbade09b85241ef2145deffbe86d3dde30 /clang/lib/Sema/SemaModule.cpp
parentb6cc667190e3bee7485a225d3dadd8a57c0a22b6 (diff)
downloadllvm-f2695a1c2f561da42b973187a254b6eeb7da76a9.zip
llvm-f2695a1c2f561da42b973187a254b6eeb7da76a9.tar.gz
llvm-f2695a1c2f561da42b973187a254b6eeb7da76a9.tar.bz2
[C++20] [Modules] Avoid writing untouched DeclUpdates from GMF in
Reduced BMI Mitigate https://github.com/llvm/llvm-project/issues/61447 The root cause of the above problem is that when we write a declaration, we need to lookup all the redeclarations in the imported modules. Then it will be pretty slow if there are too many redeclarations in different modules. This patch doesn't solve the porblem. What the patchs mitigated is, when we writing a named module, we shouldn't write the declarations from GMF if it is unreferenced **in current module unit**. The difference here is that, if the declaration is used in the imported modules, we used to emit it as an update. But we definitely want to avoid that after this patch. For that reproducer in https://github.com/llvm/llvm-project/issues/61447, it used to take 2.5s to compile and now it only takes 0.49s to compile, which is a big win.
Diffstat (limited to 'clang/lib/Sema/SemaModule.cpp')
-rw-r--r--clang/lib/Sema/SemaModule.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index 2ddf9d7..67658c9 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/ASTMutationListener.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/SemaInternal.h"
@@ -475,6 +476,9 @@ Sema::ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc,
getASTContext().setCurrentNamedModule(Mod);
+ if (auto *Listener = getASTMutationListener())
+ Listener->EnteringModulePurview();
+
// We already potentially made an implicit import (in the case of a module
// implementation unit importing its interface). Make this module visible
// and return the import decl to be added to the current TU.