r269687 - [Lex] inferModuleFromLocation should do no work if there are no modules

David Majnemer via cfe-commits cfe-commits at lists.llvm.org
Mon May 16 13:30:03 PDT 2016


Author: majnemer
Date: Mon May 16 15:30:03 2016
New Revision: 269687

URL: http://llvm.org/viewvc/llvm-project?rev=269687&view=rev
Log:
[Lex] inferModuleFromLocation should do no work if there are no modules

getModuleContainingLocation ends up on the hot-path for typical C code
which can lead to calls to getFileIDSlow.

To speed this up, short circuit inferModuleFromLocation when there
aren't any modules, implicit or otherwise.

This shaves 4-5% build time when building the linux kernel.

Modified:
    cfe/trunk/lib/Lex/ModuleMap.cpp

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=269687&r1=269686&r2=269687&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Mon May 16 15:30:03 2016
@@ -917,6 +917,9 @@ Module *ModuleMap::inferModuleFromLocati
   if (Loc.isInvalid())
     return nullptr;
 
+  if (UmbrellaDirs.empty() && Headers.empty())
+    return nullptr;
+
   // Use the expansion location to determine which module we're in.
   FullSourceLoc ExpansionLoc = Loc.getExpansionLoc();
   if (!ExpansionLoc.isFileID())




More information about the cfe-commits mailing list