[cfe-commits] r99857 - in /cfe/trunk/lib/CodeGen: CGDebugInfo.cpp CGDebugInfo.h
Daniel Dunbar
daniel at zuster.org
Tue Mar 30 19:32:30 PDT 2010
On Mon, Mar 29, 2010 at 5:27 PM, Ted Kremenek <kremenek at apple.com> wrote:
> Author: kremenek
> Date: Mon Mar 29 19:27:51 2010
> New Revision: 99857
>
> URL: http://llvm.org/viewvc/llvm-project?rev=99857&view=rev
> Log:
> Cache results computed by CGDebugInfo::getOrCreateFile() in a DenseMap.
> This reduces '-c -g' time on one file in 403.gcc by 12%.
Nice!
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CGDebugInfo.h
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=99857&r1=99856&r2=99857&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Mar 29 19:27:51 2010
> @@ -88,17 +88,35 @@
>
> /// 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.
Probably worth a note here about why it is safe to cache using the
const char* (which might not be unique) here as a key, its not
completely obvious.
- Daniel
> + 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() {
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=99857&r1=99856&r2=99857&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Mon Mar 29 19:27:51 2010
> @@ -64,6 +64,7 @@
> /// constructed on demand. For example, C++ destructors, C++ operators etc..
> llvm::BumpPtrAllocator DebugInfoNames;
>
> + llvm::DenseMap<const char *, llvm::WeakVH> DIFileCache;
> llvm::DenseMap<const FunctionDecl *, llvm::WeakVH> SPCache;
> llvm::DenseMap<const NamespaceDecl *, llvm::WeakVH> NameSpaceCache;
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
More information about the cfe-commits
mailing list