[cfe-commits] [PATCH] Speed up parsing of global declarations.

Manuel Klimek klimek at google.com
Wed Dec 12 01:51:57 PST 2012

Comment at: lib/Sema/SemaDecl.cpp:7238
@@ -7236,1 +7237,3 @@
+                       var->getLocation()) &&
+      var->isThisDeclarationADefinition() &&
       var->getLinkage() == ExternalLinkage) {
I think this is the uncontroversial part of the patch :)

That said, I'm still planning on doing what you propose anyway, I just think it's pretty orthogonal to the patch.

Comment at: lib/Basic/DiagnosticIDs.cpp:226
@@ +225,3 @@
+/// \brief Cache lookup of the DiagID -> ClassInfo ID mapping.
+static std::pair<unsigned, bool> DiagnosticClassCache[diag::DIAG_UPPER_LIMIT];
Manuel Klimek wrote:
> Nope, Benjamin brought that up on IRC already (which led to him checking in a first patch to speed up GetDiagInfo).
> I'm now doing more benchmarks, and if this turns out to be still needed, Benjamin said that putting it into DiagnosticIDs is probably fine.
Funnily enough this cache (at least for the synthetic "int i<N>" benchmark) has a strong effect - and if I so much as sneeze on it, performance drops again.

I tried:
- using unsigned char instead of unsigned int - significant drop
- folding the bool into the range of the result, and using a mask - significant drop
- various combinations of the above

I'm not sure what the effect of this particular change is overall, so I'm now running more high level benchmark.

So far, this patch overall provides about 3% speedup on the google code base (minus d0k's other patch - I'm benchmarking the effects of that as I'm writing this).


More information about the cfe-commits mailing list