summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2019-11-15 11:22:02 -0800
committerReid Kleckner <rnk@google.com>2019-11-19 12:42:33 -0800
commit586f65d31f32ca6bc8cfdb8a4f61bee5057bf6c8 (patch)
treee32016eb58e356afd2b04643d8e00dc4b7a9c17f
parent1aacf58819a27f428a46ce839a0ee797af03c1fd (diff)
downloadbcm5719-llvm-586f65d31f32ca6bc8cfdb8a4f61bee5057bf6c8.tar.gz
bcm5719-llvm-586f65d31f32ca6bc8cfdb8a4f61bee5057bf6c8.zip
Add a key method to Sema to optimize debug info size
It turns out that the debug info describing the Sema class is an appreciable percentage of the total object file size of objects in Sema. By adding a key function, clang is able to optimize the debug info size by emitting a forward declaration in TUs that do not define the key function. On Windows, with clang-cl, these are the total sizes of object files in Sema before and after this change, compiling with optimizations and debug info: before: 335,012 KB after: 278,116 KB delta: -56,896 KB percent: -17.0% The effect on link time was negligible, despite having ~56MB less input. On Linux, with clang, these are the same sizes using DWARF -g and optimizations: before: 603,756 KB after: 515,340 KB delta: -88,416 KB percent: -14.6% I didn't use type units, DWARF-5, fission, or any other special flags. Reviewed By: thakis Differential Revision: https://reviews.llvm.org/D70340
-rw-r--r--clang/include/clang/Sema/Sema.h5
-rw-r--r--clang/lib/Sema/Sema.cpp3
2 files changed, 7 insertions, 1 deletions
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 220b6c17835..7d8ab59fe90 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -328,10 +328,13 @@ private:
};
/// Sema - This implements semantic analysis and AST building for C.
-class Sema {
+class Sema final {
Sema(const Sema &) = delete;
void operator=(const Sema &) = delete;
+ /// A key method to reduce duplicate debug info from Sema.
+ virtual void anchor();
+
///Source of additional semantic information.
ExternalSemaSource *ExternalSource;
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index bedea216795..c3c6cad277f 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -189,6 +189,9 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
SemaPPCallbackHandler->set(*this);
}
+// Anchor Sema's type info to this TU.
+void Sema::anchor() {}
+
void Sema::addImplicitTypedef(StringRef Name, QualType T) {
DeclarationName DN = &Context.Idents.get(Name);
if (IdResolver.begin(DN) == IdResolver.end())
OpenPOWER on IntegriCloud