]> granicus.if.org Git - clang/commitdiff
[Lex] inferModuleFromLocation should do no work if there are no modules
authorDavid Majnemer <david.majnemer@gmail.com>
Mon, 16 May 2016 20:30:03 +0000 (20:30 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Mon, 16 May 2016 20:30:03 +0000 (20:30 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@269687 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/ModuleMap.cpp

index 51477185ae0e0c23f122a3a295d0d44f3853da9c..3e3215dee82a88d07a09a3f0a57b30aa3bc0c692 100644 (file)
@@ -917,6 +917,9 @@ Module *ModuleMap::inferModuleFromLocation(FullSourceLoc Loc) {
   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())