diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2024-10-22 08:57:33 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-22 08:57:33 -0700 |
commit | 8bbd0797d4b8aa1d993f587eb2dfd9a89df1f406 (patch) | |
tree | cbf5ed65b14bb62991a259a24480097526130dd8 /clang/lib/Basic/Module.cpp | |
parent | 40c3e583b7c29c94b3fdd2361c5288b2dcc3be83 (diff) | |
download | llvm-8bbd0797d4b8aa1d993f587eb2dfd9a89df1f406.zip llvm-8bbd0797d4b8aa1d993f587eb2dfd9a89df1f406.tar.gz llvm-8bbd0797d4b8aa1d993f587eb2dfd9a89df1f406.tar.bz2 |
[clang] Allocate `Module` instances in `BumpPtrAllocator` (#112795)
In `clang-scan-deps`, we're creating lots of `Module` instances.
Allocating them all in a bump-pointer allocator reduces the number of
retired instructions by 1-1.5% on my workload.
Diffstat (limited to 'clang/lib/Basic/Module.cpp')
-rw-r--r-- | clang/lib/Basic/Module.cpp | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index fee372b..ad52fcc 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -34,8 +34,9 @@ using namespace clang; -Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent, - bool IsFramework, bool IsExplicit, unsigned VisibilityID) +Module::Module(ModuleConstructorTag, StringRef Name, + SourceLocation DefinitionLoc, Module *Parent, bool IsFramework, + bool IsExplicit, unsigned VisibilityID) : Name(Name), DefinitionLoc(DefinitionLoc), Parent(Parent), VisibilityID(VisibilityID), IsUnimportable(false), HasIncompatibleModuleFile(false), IsAvailable(true), @@ -58,11 +59,7 @@ Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent, } } -Module::~Module() { - for (auto *Submodule : SubModules) { - delete Submodule; - } -} +Module::~Module() = default; static bool isPlatformEnvironment(const TargetInfo &Target, StringRef Feature) { StringRef Platform = Target.getPlatformName(); @@ -361,21 +358,6 @@ Module *Module::findSubmodule(StringRef Name) const { return SubModules[Pos->getValue()]; } -Module *Module::findOrInferSubmodule(StringRef Name) { - llvm::StringMap<unsigned>::const_iterator Pos = SubModuleIndex.find(Name); - if (Pos != SubModuleIndex.end()) - return SubModules[Pos->getValue()]; - if (!InferSubmodules) - return nullptr; - Module *Result = new Module(Name, SourceLocation(), this, false, InferExplicitSubmodules, 0); - Result->InferExplicitSubmodules = InferExplicitSubmodules; - Result->InferSubmodules = InferSubmodules; - Result->InferExportWildcard = InferExportWildcard; - if (Result->InferExportWildcard) - Result->Exports.push_back(Module::ExportDecl(nullptr, true)); - return Result; -} - Module *Module::getGlobalModuleFragment() const { assert(isNamedModuleUnit() && "We should only query the global module " "fragment from the C++20 Named modules"); |