This is an archive of the discontinued LLVM Phabricator instance.

[Diag] Optimize DiagnosticIDs::getDiagnosticSeverity
Needs ReviewPublic

Authored by ogoffart on Nov 9 2016, 10:38 AM.

Details

Summary

DiagnosticIDs::getDiagnosticSeverity function turns out to take a lot of time in getDecomposedLoc. It is called quite often from different places. (For example from Sema::CheckTemplateArgument which attempt to emit warn_cxx98_compat_* diagnostics.)
In most cases, the diagnostics are not overridden by pragmas and the mapping from the command line is good enough. This commit adds a bit in the the first mapping which specify if we should look up the real mapping.

This saves more than 5% of the parsing time according to perf.

Diff Detail

Event Timeline

ogoffart updated this revision to Diff 77377.Nov 9 2016, 10:38 AM
ogoffart retitled this revision from to [Diag] Optimize DiagnosticIDs::getDiagnosticSeverity.
ogoffart updated this object.
ogoffart added reviewers: cfe-commits, rsmith.

Is there any way to test this change?

This saves more than 5% of the parsing time according to perf.

That sounds great. What did you test the parsing on? Will this patch get similar improvements for code that compiles without errors and warnings?

lib/Basic/DiagnosticIDs.cpp
423

I think it would be better if you wrap this piece of code in a static function that returns DiagnosticMapping &, as it should allow you to get rid of all these . to -> changes below.

ogoffart marked an inline comment as done.Dec 22 2016, 3:32 AM

What did you test the parsing on? Will this patch get similar improvements for code that compiles without errors and warnings?

It was benchamerked with https://github.com/woboq/woboq_codebrowser generating itself.
The code does not contain warnings. (unless you really consider the warn_cxx98_compat_* to be warnings)

lib/Basic/DiagnosticIDs.cpp
423

The problem is that most things are private in DiagnosticsEngine, so i made it a privte member of DiagnosticIds (which is a friend)

ogoffart updated this revision to Diff 82325.Dec 22 2016, 3:35 AM
ogoffart marked an inline comment as done.