summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-03-30 00:27:51 +0000
committerTed Kremenek <kremenek@apple.com>2010-03-30 00:27:51 +0000
commitdbb8cd1d34aa6393bb491a0dce2a7d1f94532492 (patch)
tree004c1b50f53dd77eb7c47295113f0da92b80d75d /clang/lib/CodeGen/CGDebugInfo.cpp
parent486aa2eadc8216ae6ae635734194720b7dde88a5 (diff)
downloadbcm5719-llvm-dbb8cd1d34aa6393bb491a0dce2a7d1f94532492.tar.gz
bcm5719-llvm-dbb8cd1d34aa6393bb491a0dce2a7d1f94532492.zip
Cache results computed by CGDebugInfo::getOrCreateFile() in a DenseMap.
This reduces '-c -g' time on one file in 403.gcc by 12%. llvm-svn: 99857
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index d8a9f36c825..0e789c92d67 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -88,17 +88,35 @@ llvm::StringRef CGDebugInfo::getFunctionName(const FunctionDecl *FD) {
/// getOrCreateFile - Get the file debug info descriptor for the input location.
llvm::DIFile CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
- if (!Loc.isValid())
+ if (!Loc.isValid())
// If Location is not valid then use main input file.
return DebugFactory.CreateFile(TheCU.getFilename(), TheCU.getDirectory(),
TheCU);
SourceManager &SM = CGM.getContext().getSourceManager();
PresumedLoc PLoc = SM.getPresumedLoc(Loc);
+
+ // Cache the results.
+ const char *fname = PLoc.getFilename();
+ llvm::DenseMap<const char *, llvm::WeakVH>::iterator it =
+ DIFileCache.find(fname);
+
+ if (it != DIFileCache.end()) {
+ // Verify that the information still exists.
+ if (&*it->second)
+ return llvm::DIFile(cast<llvm::MDNode>(it->second));
+ }
+
+ // FIXME: We shouldn't even need to call 'makeAbsolute()' in the cases
+ // where we can consult the FileEntry.
llvm::sys::Path AbsFileName(PLoc.getFilename());
AbsFileName.makeAbsolute();
- return DebugFactory.CreateFile(AbsFileName.getLast(),
- AbsFileName.getDirname(), TheCU);
+ llvm::DIFile F = DebugFactory.CreateFile(AbsFileName.getLast(),
+ AbsFileName.getDirname(), TheCU);
+
+ DIFileCache[fname] = F.getNode();
+ return F;
+
}
/// CreateCompileUnit - Create new compile unit.
void CGDebugInfo::CreateCompileUnit() {
OpenPOWER on IntegriCloud