[PATCH] D136019: [clang][lex] Avoid `DirectoryLookup` copies

Jan Svoboda via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 19 16:40:26 PDT 2022


jansvoboda11 updated this revision to Diff 469077.
jansvoboda11 added a comment.

Add regression test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136019/new/

https://reviews.llvm.org/D136019

Files:
  clang/lib/Lex/HeaderSearch.cpp
  clang/test/Modules/file-manager-lookup-count.m


Index: clang/test/Modules/file-manager-lookup-count.m
===================================================================
--- /dev/null
+++ clang/test/Modules/file-manager-lookup-count.m
@@ -0,0 +1,78 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+//--- include-0/sub/module.modulemap
+module sub_0 {}
+//--- include-1/sub/module.modulemap
+module sub_1 {}
+//--- include-2/sub/module.modulemap
+module sub_2 {}
+//--- include-3/sub/module.modulemap
+module sub_3 {}
+//--- include-4/sub/module.modulemap
+module sub_4 {}
+//--- include-5/sub/module.modulemap
+module sub_5 {}
+//--- include-6/sub/module.modulemap
+module sub_6 {}
+//--- include-7/sub/module.modulemap
+module sub_7 {}
+//--- include-8/sub/module.modulemap
+module sub_8 {}
+//--- include-9/sub/module.modulemap
+module sub_9 {}
+//--- include-A/sub/module.modulemap
+module A {}
+//--- include-B/sub/module.modulemap
+module B {}
+//--- include-C/sub/module.modulemap
+module C {}
+//--- include-D/sub/module.modulemap
+module D {}
+//--- include-E/sub/module.modulemap
+module E {}
+//--- include-F/sub/module.modulemap
+module F {}
+//--- include-G/sub/module.modulemap
+module G {}
+//--- include-H/sub/module.modulemap
+module H {}
+
+//--- tu.m
+ at import A;
+ at import B;
+ at import C;
+ at import D;
+ at import E;
+ at import F;
+ at import G;
+ at import H;
+
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache \
+// RUN:   -fsyntax-only %t/tu.m -stats-file=%t/stats \
+// RUN:   -I %t/include-0 \
+// RUN:   -I %t/include-1 \
+// RUN:   -I %t/include-2 \
+// RUN:   -I %t/include-3 \
+// RUN:   -I %t/include-4 \
+// RUN:   -I %t/include-5 \
+// RUN:   -I %t/include-6 \
+// RUN:   -I %t/include-7 \
+// RUN:   -I %t/include-8 \
+// RUN:   -I %t/include-9 \
+// RUN:   -I %t/include-A \
+// RUN:   -I %t/include-B \
+// RUN:   -I %t/include-C \
+// RUN:   -I %t/include-D \
+// RUN:   -I %t/include-E \
+// RUN:   -I %t/include-F \
+// RUN:   -I %t/include-G \
+// RUN:   -I %t/include-H
+
+// RUN: FileCheck --input-file %t/stats %s
+// CHECK:      {
+// CHECK-NEXT:   "file-search.NumDirCacheMisses": 156,
+// CHECK-NEXT:   "file-search.NumDirLookups": 427,
+// CHECK-NEXT:   "file-search.NumFileCacheMisses": 89,
+// CHECK-NEXT:   "file-search.NumFileLookups": 341
+// CHECK-NEXT: }
Index: clang/lib/Lex/HeaderSearch.cpp
===================================================================
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -305,7 +305,7 @@
 
   // Look through the various header search paths to load any available module
   // maps, searching for a module map that describes this module.
-  for (DirectoryLookup Dir : search_dir_range()) {
+  for (DirectoryLookup &Dir : search_dir_range()) {
     if (Dir.isFramework()) {
       // Search for or infer a module map for a framework. Here we use
       // SearchName rather than ModuleName, to permit finding private modules


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136019.469077.patch
Type: text/x-patch
Size: 2911 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221019/b94a9bc9/attachment-0001.bin>


More information about the cfe-commits mailing list