diff options
author | Alex Lorenz <arphaman@gmail.com> | 2019-09-11 20:40:31 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2019-09-11 20:40:31 +0000 |
commit | ca6e60971e9578acb0561df7797283474291f9d9 (patch) | |
tree | 7befe213930939771810d9aa830ce7323c119389 /clang/tools/clang-scan-deps/ClangScanDeps.cpp | |
parent | 2f843616849963e8df7a561ce5179ed29a767057 (diff) | |
download | bcm5719-llvm-ca6e60971e9578acb0561df7797283474291f9d9.tar.gz bcm5719-llvm-ca6e60971e9578acb0561df7797283474291f9d9.zip |
[clang-scan-deps] add skip excluded conditional preprocessor block preprocessing optimization
This commit adds an optimization to clang-scan-deps and clang's preprocessor that skips excluded preprocessor
blocks by bumping the lexer pointer, and not lexing the tokens until reaching appropriate #else/#endif directive.
The skip positions and lexer offsets are computed when the file is minimized, directly from the minimized tokens.
On an 18-core iMacPro with macOS Catalina Beta I got 10-15% speed-up from this optimization when running clang-scan-deps on
the compilation database for a recent LLVM and Clang (3511 files).
Differential Revision: https://reviews.llvm.org/D67127
llvm-svn: 371656
Diffstat (limited to 'clang/tools/clang-scan-deps/ClangScanDeps.cpp')
-rw-r--r-- | clang/tools/clang-scan-deps/ClangScanDeps.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp index bee4b479b2d..2181e0e0d39 100644 --- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp +++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp @@ -168,6 +168,14 @@ llvm::cl::opt<bool> ReuseFileManager( llvm::cl::desc("Reuse the file manager and its cache between invocations."), llvm::cl::init(true), llvm::cl::cat(DependencyScannerCategory)); +llvm::cl::opt<bool> SkipExcludedPPRanges( + "skip-excluded-pp-ranges", + llvm::cl::desc( + "Use the preprocessor optimization that skips excluded conditionals by " + "bumping the buffer pointer in the lexer instead of lexing the tokens " + "until reaching the end directive."), + llvm::cl::init(true), llvm::cl::cat(DependencyScannerCategory)); + } // end anonymous namespace int main(int argc, const char **argv) { @@ -214,7 +222,8 @@ int main(int argc, const char **argv) { // Print out the dependency results to STDOUT by default. SharedStream DependencyOS(llvm::outs()); - DependencyScanningService Service(ScanMode, ReuseFileManager); + DependencyScanningService Service(ScanMode, ReuseFileManager, + SkipExcludedPPRanges); #if LLVM_ENABLE_THREADS unsigned NumWorkers = NumThreads == 0 ? llvm::hardware_concurrency() : NumThreads; |