diff options
author | David Majnemer <david.majnemer@gmail.com> | 2016-05-16 20:30:03 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2016-05-16 20:30:03 +0000 |
commit | 7ffd0b44091ecfdbab65051e07636362939ec541 (patch) | |
tree | 1e1ad8c5da81d73411a1b0934aab8415e1bcfe1d /clang/lib/Lex/ModuleMap.cpp | |
parent | 58b794ae505b254a35a84456a3ef072bcbad0eb5 (diff) | |
download | bcm5719-llvm-7ffd0b44091ecfdbab65051e07636362939ec541.tar.gz bcm5719-llvm-7ffd0b44091ecfdbab65051e07636362939ec541.zip |
[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
Diffstat (limited to 'clang/lib/Lex/ModuleMap.cpp')
-rw-r--r-- | clang/lib/Lex/ModuleMap.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index 51477185ae0..3e3215dee82 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()) |