[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
This commit is contained in:
David Majnemer 2016-05-16 20:30:03 +00:00
parent 58b794ae50
commit 7ffd0b4409
1 changed files with 3 additions and 0 deletions

View 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())