[clang][Preprocessor] Replace the slow translateFile call by a new, faster isMainFile...
authorAlex Lorenz <arphaman@gmail.com>
Thu, 14 May 2020 21:11:31 +0000 (14:11 -0700)
committerAlex Lorenz <arphaman@gmail.com>
Thu, 14 May 2020 21:13:34 +0000 (14:13 -0700)
commit11d612ac99a621c762c2cc8f7bacbb8ae32d7fe9
tree2af435bc475fbc930c9fd4516e9f755a182a3e43
parent428d0b6f77986efd944df01bb4ae7888c6262c2f
[clang][Preprocessor] Replace the slow translateFile call by a new, faster isMainFile check

The commit 3c28a2dc6bdc331e5a0d8097a5fa59d06682b9d0 introduced the check that checks if we're
trying to re-enter a main file when building a preamble. Unfortunately this slowed down the preamble
compilation by 80-90% in some test cases, as translateFile is really slow. This change checks
to see if the FileEntry is the main file without calling translateFile, but by using the new
isMainFile check instead. This speeds up preamble building by 1.5-2x for certain test cases that we have.

rdar://59361291

Differential Revision: https://reviews.llvm.org/D79834
clang/include/clang/Basic/SourceManager.h
clang/lib/Basic/SourceManager.cpp
clang/lib/Lex/PPDirectives.cpp
clang/unittests/Basic/SourceManagerTest.cpp