From 7ffd0b44091ecfdbab65051e07636362939ec541 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Mon, 16 May 2016 20:30:03 +0000 Subject: [PATCH] [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. llvm-svn: 269687 --- clang/lib/Lex/ModuleMap.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index 51477185ae0e..3e3215dee82a 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -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())