[llvm-commits] [dragonegg] r94888 - /dragonegg/trunk/llvm-debug.cpp
Duncan Sands
baldrick at free.fr
Sat Jan 30 06:05:52 PST 2010
Author: baldrick
Date: Sat Jan 30 08:05:52 2010
New Revision: 94888
URL: http://llvm.org/viewvc/llvm-project?rev=94888&view=rev
Log:
Port llvm-gcc commit 93485 (dpatel):
Avoid recursive while emitting debug info for function types.
test/FrontendC/2010-01-14-FnType-DebugInfo.c is the test case.
Modified:
dragonegg/trunk/llvm-debug.cpp
Modified: dragonegg/trunk/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.cpp?rev=94888&r1=94887&r2=94888&view=diff
==============================================================================
--- dragonegg/trunk/llvm-debug.cpp (original)
+++ dragonegg/trunk/llvm-debug.cpp Sat Jan 30 08:05:52 2010
@@ -478,6 +478,21 @@
/// createMethodType - Create MethodType.
DIType DebugInfo::createMethodType(tree type) {
+ // Create a place holder type first. The may be used as a context
+ // for the argument types.
+ llvm::DIType FwdType =
+ DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type,
+ getOrCreateCompileUnit(NULL),
+ StringRef(),
+ getOrCreateCompileUnit(NULL),
+ 0, 0, 0, 0, 0,
+ llvm::DIType(), llvm::DIArray());
+ llvm::TrackingVH<llvm::MDNode> FwdTypeNode = FwdType.getNode();
+ TypeCache[type] = WeakVH(FwdType.getNode());
+ // Push the struct on region stack.
+ RegionStack.push_back(WeakVH(FwdType.getNode()));
+ RegionMap[type] = WeakVH(FwdType.getNode());
+
llvm::SmallVector<llvm::DIDescriptor, 16> EltTys;
// Add the result type at least.
@@ -493,12 +508,24 @@
llvm::DIArray EltTypeArray =
DebugFactory.GetOrCreateArray(EltTys.data(), EltTys.size());
- return DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type,
- findRegion(TYPE_CONTEXT(type)),
- StringRef(),
- getOrCreateCompileUnit(NULL),
- 0, 0, 0, 0, 0,
- llvm::DIType(), EltTypeArray);
+ RegionStack.pop_back();
+ std::map<tree_node *, WeakVH>::iterator RI = RegionMap.find(type);
+ if (RI != RegionMap.end())
+ RegionMap.erase(RI);
+
+ llvm::DIType RealType =
+ DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type,
+ findRegion(TYPE_CONTEXT(type)),
+ StringRef(),
+ getOrCreateCompileUnit(NULL),
+ 0, 0, 0, 0, 0,
+ llvm::DIType(), EltTypeArray);
+
+ // Now that we have a real decl for the struct, replace anything using the
+ // old decl with the new one. This will recursively update the debug info.
+ llvm::DIDerivedType(FwdTypeNode).replaceAllUsesWith(RealType);
+
+ return RealType;
}
/// createPointerType - Create PointerType.
More information about the llvm-commits
mailing list