diff options
| author | Alex Lorenz <arphaman@gmail.com> | 2019-08-06 20:43:25 +0000 |
|---|---|---|
| committer | Alex Lorenz <arphaman@gmail.com> | 2019-08-06 20:43:25 +0000 |
| commit | e1f4c4aad27992d6b8a0b8d85af42c14fa68c298 (patch) | |
| tree | 82d894bcc36d70ad55cf69960f89683730a99578 /clang/tools | |
| parent | e4bd38478b38ab752af54b380da9f265fd90ba72 (diff) | |
| download | bcm5719-llvm-e1f4c4aad27992d6b8a0b8d85af42c14fa68c298.tar.gz bcm5719-llvm-e1f4c4aad27992d6b8a0b8d85af42c14fa68c298.zip | |
[clang-scan-deps] Implementation of dependency scanner over minimized sources
This commit implements the fast dependency scanning mode in clang-scan-deps: the
preprocessing is done on files that are minimized using the dependency directives source minimizer.
A shared file system cache is used to ensure that the file system requests and source minimization
is performed only once. The cache assumes that the underlying filesystem won't change during the course
of the scan (or if it will, it will not affect the output), and it can't be evicted. This means that the
service and workers can be used for a single run of a dependency scanner, and can't be reused across multiple,
incremental runs. This is something that we'll most likely support in the future though.
Note that the driver still utilizes the underlying real filesystem.
This commit is also still missing the fast skipped PP block skipping optimization that I mentioned at EuroLLVM talk.
Additionally, the file manager is still not reused by the threads as well.
Differential Revision: https://reviews.llvm.org/D63907
llvm-svn: 368086
Diffstat (limited to 'clang/tools')
| -rw-r--r-- | clang/tools/clang-scan-deps/ClangScanDeps.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp index 5fea09d1a7e..422799f3bf8 100644 --- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp +++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp @@ -8,6 +8,7 @@ #include "clang/Frontend/CompilerInstance.h" #include "clang/Tooling/CommonOptionsParser.h" +#include "clang/Tooling/DependencyScanning/DependencyScanningService.h" #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h" #include "clang/Tooling/JSONCompilationDatabase.h" #include "llvm/Support/InitLLVM.h" @@ -45,9 +46,10 @@ public: /// /// \param Compilations The reference to the compilation database that's /// used by the clang tool. - DependencyScanningTool(const tooling::CompilationDatabase &Compilations, + DependencyScanningTool(DependencyScanningService &Service, + const tooling::CompilationDatabase &Compilations, SharedStream &OS, SharedStream &Errs) - : Compilations(Compilations), OS(OS), Errs(Errs) {} + : Worker(Service), Compilations(Compilations), OS(OS), Errs(Errs) {} /// Computes the dependencies for the given file and prints them out. /// @@ -80,6 +82,20 @@ llvm::cl::opt<bool> Help("h", llvm::cl::desc("Alias for -help"), llvm::cl::OptionCategory DependencyScannerCategory("Tool options"); +static llvm::cl::opt<ScanningMode> ScanMode( + "mode", + llvm::cl::desc("The preprocessing mode used to compute the dependencies"), + llvm::cl::values( + clEnumValN(ScanningMode::MinimizedSourcePreprocessing, + "preprocess-minimized-sources", + "The set of dependencies is computed by preprocessing the " + "source files that were minimized to only include the " + "contents that might affect the dependencies"), + clEnumValN(ScanningMode::CanonicalPreprocessing, "preprocess", + "The set of dependencies is computed by preprocessing the " + "unmodified source files")), + llvm::cl::init(ScanningMode::MinimizedSourcePreprocessing)); + llvm::cl::opt<unsigned> NumThreads("j", llvm::cl::Optional, llvm::cl::desc("Number of worker threads to use (default: use " @@ -136,12 +152,14 @@ int main(int argc, const char **argv) { SharedStream Errs(llvm::errs()); // Print out the dependency results to STDOUT by default. SharedStream DependencyOS(llvm::outs()); + + DependencyScanningService Service(ScanMode); unsigned NumWorkers = NumThreads == 0 ? llvm::hardware_concurrency() : NumThreads; std::vector<std::unique_ptr<DependencyScanningTool>> WorkerTools; for (unsigned I = 0; I < NumWorkers; ++I) WorkerTools.push_back(llvm::make_unique<DependencyScanningTool>( - *AdjustingCompilations, DependencyOS, Errs)); + Service, *AdjustingCompilations, DependencyOS, Errs)); std::vector<std::thread> WorkerThreads; std::atomic<bool> HadErrors(false); |

