[llvm-commits] [dragonegg] r92476 - in /dragonegg/trunk: llvm-debug.cpp llvm-debug.h
Duncan Sands
baldrick at free.fr
Mon Jan 4 03:41:18 PST 2010
Author: baldrick
Date: Mon Jan 4 05:41:17 2010
New Revision: 92476
URL: http://llvm.org/viewvc/llvm-project?rev=92476&view=rev
Log:
Port commit 90284 (dpatel) from llvm-gcc:
Reuse existing DISubprograms.
Modified:
dragonegg/trunk/llvm-debug.cpp
dragonegg/trunk/llvm-debug.h
Modified: dragonegg/trunk/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.cpp?rev=92476&r1=92475&r2=92476&view=diff
==============================================================================
--- dragonegg/trunk/llvm-debug.cpp (original)
+++ dragonegg/trunk/llvm-debug.cpp Mon Jan 4 05:41:17 2010
@@ -229,6 +229,22 @@
/// "llvm.dbg.func.start."
void DebugInfo::EmitFunctionStart(tree FnDecl, Function *Fn,
BasicBlock *CurBB) {
+
+ DIType FNType = getOrCreateType(TREE_TYPE(FnDecl));
+
+ std::map<tree_node *, WeakVH >::iterator I = SPCache.find(FnDecl);
+ if (I != SPCache.end()) {
+ DISubprogram SPDecl(cast<MDNode>(I->second));
+ DISubprogram SP =
+ DebugFactory.CreateSubprogramDefinition(SPDecl);
+ SPDecl.getNode()->replaceAllUsesWith(SP.getNode());
+
+ // Push function on region stack.
+ RegionStack.push_back(WeakVH(SP.getNode()));
+ RegionMap[FnDecl] = WeakVH(SP.getNode());
+ return;
+ }
+
// Gather location information.
expanded_location Loc = GetNodeLocation(FnDecl, false);
StringRef LinkageName = getLinkageName(FnDecl);
@@ -239,10 +255,12 @@
lang_hooks.dwarf_name(FnDecl, 0),
LinkageName,
getOrCreateCompileUnit(Loc.file), CurLineNo,
- getOrCreateType(TREE_TYPE(FnDecl)),
+ FNType,
Fn->hasInternalLinkage(),
true /*definition*/);
+ SPCache[FnDecl] = WeakVH(SP.getNode());
+
// Push function on region stack.
RegionStack.push_back(WeakVH(SP.getNode()));
RegionMap[FnDecl] = WeakVH(SP.getNode());
@@ -722,18 +740,23 @@
// In C++, TEMPLATE_DECLs are marked Ignored, and should be.
if (DECL_P (Member) && DECL_IGNORED_P (Member)) continue;
- // Get the location of the member.
- expanded_location MemLoc = GetNodeLocation(Member, false);
-
- const char *MemberName = lang_hooks.dwarf_name(Member, 0);
- StringRef LinkageName = getLinkageName(Member);
- DIType SPTy = getOrCreateType(TREE_TYPE(Member));
- DISubprogram SP =
- DebugFactory.CreateSubprogram(findRegion(Member), MemberName, MemberName,
- LinkageName,
- getOrCreateCompileUnit(MemLoc.file),
- MemLoc.line, SPTy, false, false);
- EltTys.push_back(SP);
+ std::map<tree_node *, WeakVH >::iterator I = SPCache.find(Member);
+ if (I != SPCache.end())
+ EltTys.push_back(DISubprogram(cast<MDNode>(I->second)));
+ else {
+ // Get the location of the member.
+ expanded_location MemLoc = GetNodeLocation(Member, false);
+ const char *MemberName = lang_hooks.dwarf_name(Member, 0);
+ StringRef LinkageName = getLinkageName(Member);
+ DIType SPTy = getOrCreateType(TREE_TYPE(Member));
+ DISubprogram SP =
+ DebugFactory.CreateSubprogram(findRegion(Member), MemberName, MemberName,
+ LinkageName,
+ getOrCreateCompileUnit(MemLoc.file),
+ MemLoc.line, SPTy, false, false);
+ EltTys.push_back(SP);
+ SPCache[Member] = WeakVH(SP.getNode());
+ }
}
llvm::DIArray Elements =
Modified: dragonegg/trunk/llvm-debug.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.h?rev=92476&r1=92475&r2=92476&view=diff
==============================================================================
--- dragonegg/trunk/llvm-debug.h (original)
+++ dragonegg/trunk/llvm-debug.h Mon Jan 4 05:41:17 2010
@@ -61,6 +61,9 @@
std::map<tree_node *, WeakVH > TypeCache;
// Cache of previously constructed
// Types.
+ std::map<tree_node *, WeakVH > SPCache;
+ // Cache of previously constructed
+ // Subprograms.
SmallVector<WeakVH, 4> RegionStack;
// Stack to track declarative scopes.
More information about the llvm-commits
mailing list