llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Vladimir Shiryaev (tagolog) <details> <summary>Changes</summary> `isPreprocessedModuleFile()` scans the whole source line by line, looking for `__preprocessed_module` or `__preprocessed_import` directives. This scan is pretty expensive. Add a fast path by checking for the presence of the `__preprocessed_` string. On `swiftlang/llvm-project`, a cache hit through `clang-cache` with its default inline dependency scan drops - from 201.4 to 189.8 ms (-5.7%) on Windows - from 107.7 to 100.3 ms (-6.9%) on Linux --- Full diff: https://github.com/llvm/llvm-project/pull/239449.diff 1 Files Affected: - (modified) clang/lib/Lex/DependencyDirectivesScanner.cpp (+5) ``````````diff diff --git a/clang/lib/Lex/DependencyDirectivesScanner.cpp b/clang/lib/Lex/DependencyDirectivesScanner.cpp index ccf80c4a9f572..430f46d0ba7f6 100644 --- a/clang/lib/Lex/DependencyDirectivesScanner.cpp +++ b/clang/lib/Lex/DependencyDirectivesScanner.cpp @@ -1212,6 +1212,11 @@ ModuleUnitKind clang::scanInputForCXX20ModuleUnit(StringRef Source) { } bool clang::isPreprocessedModuleFile(StringRef Source) { + // Fast path: a file without "__preprocessed_" has neither directive. + // Skipping the line-by-line walk speeds up the scan. + if (!Source.contains("__preprocessed_")) + return false; + const char *First = Source.begin(); const char *const End = Source.end(); `````````` </details> https://github.com/llvm/llvm-project/pull/239449 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
