[clang] 77924d6 - [clang][deps] Modules don't contribute to search path usage

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 16 04:17:58 PDT 2022


Author: Jan Svoboda
Date: 2022-03-16T12:17:52+01:00
New Revision: 77924d60efa8b3a0278361fe77403a71576c9349

URL: https://github.com/llvm/llvm-project/commit/77924d60efa8b3a0278361fe77403a71576c9349
DIFF: https://github.com/llvm/llvm-project/commit/77924d60efa8b3a0278361fe77403a71576c9349.diff

LOG: [clang][deps] Modules don't contribute to search path usage

To reduce the number of modules we build in explicit builds (which use strict context hash), we prune unused header search paths. This essentially merges parts of the dependency graph.

Determining whether a search path was used to discover a module (through implicit module maps) proved to be somewhat complicated. Initial support landed in D102923, while D113676 attempts to fix some bugs.

However, now that we don't use implicit module maps in explicit builds (since D120465), we don't need to consider such search paths as used anymore. Modules are no longer discovered through the header search mechanism, so we can drop such search paths (provided they are not needed for other reasons).

This patch removes whatever support for detecting such usage we had, since it's buggy and not required anymore.

Depends on D120465.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D121295

Added: 
    

Modified: 
    clang/include/clang/Lex/HeaderSearch.h
    clang/lib/Lex/HeaderSearch.cpp
    clang/test/Preprocessor/search-path-usage.m

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Lex/HeaderSearch.h b/clang/include/clang/Lex/HeaderSearch.h
index 2de46d727ece4..22afec4b33eb8 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -561,6 +561,7 @@ class HeaderSearch {
 
   /// Determine which HeaderSearchOptions::UserEntries have been successfully
   /// used so far and mark their index with 'true' in the resulting bit vector.
+  /// Note: implicit module maps don't contribute to entry usage.
   std::vector<bool> computeUserEntryUsage() const;
 
   /// This method returns a HeaderMap for the specified

diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index c8908642a4c25..469c435edd965 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -365,9 +365,6 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName,
       break;
   }
 
-  if (Module)
-    noteLookupUsage(It.Idx, ImportLoc);
-
   return Module;
 }
 

diff  --git a/clang/test/Preprocessor/search-path-usage.m b/clang/test/Preprocessor/search-path-usage.m
index 66f626808cf6f..4676a19ab6ca4 100644
--- a/clang/test/Preprocessor/search-path-usage.m
+++ b/clang/test/Preprocessor/search-path-usage.m
@@ -129,7 +129,7 @@
 #endif
 #endif
 
-// Check that search paths with module maps are reported.
+// Check that search paths with module maps are NOT reported.
 //
 // RUN: mkdir %t/modulemap_abs
 // RUN: sed "s|DIR|%/S/Inputs/search-path-usage|g"                            \
@@ -142,5 +142,5 @@
 // RUN:   -DMODMAP_ABS -verify
 #ifdef MODMAP_ABS
 @import b; // \
-// expected-remark-re {{search path used: '{{.*}}/modulemap_abs'}}
+// expected-no-diagnostics
 #endif


        


More information about the cfe-commits mailing list