This is an archive of the discontinued LLVM Phabricator instance.

Cache FileID when translating diagnostics in PCH files
ClosedPublic

Authored by erikjv on Feb 9 2017, 2:16 AM.

Details

Summary

Modules/preambles/PCH files can contain diagnostics, which, when used,
are added to the current ASTUnit. For that to work, they are translated
to use the current FileManager's FileIDs. When the entry is not the
main file, all local source locations will be checked by a linear
search. Now this is a problem, when there are lots of diagnostics (say,

  1. and lots of local source locations (say, 440000), and end up

taking seconds when using such a preamble.

The fix is to cache the last FileID, because many subsequent diagnostics
refer to the same file. This reduces the time spent in
ASTUnit::TranslateStoredDiagnostics from seconds to a few milliseconds
for files with many slocs/diagnostics.

This fixes PR31353.

Diff Detail

Event Timeline

erikjv created this revision.Feb 9 2017, 2:16 AM
erikjv edited the summary of this revision. (Show Details)Feb 9 2017, 2:27 AM
ahatanak added inline comments.
lib/Frontend/ASTUnit.cpp
2551–2554

Since FID is always equal to CachedFID, I think you can simplify this a bit by removing FID and using just CachedFID.

erikjv updated this revision to Diff 88366.Feb 14 2017, 6:32 AM
erikjv marked an inline comment as done.
This revision is now accepted and ready to land.Feb 14 2017, 6:34 AM
This revision was automatically updated to reflect the committed changes.