[llvm-commits] [llvm-gcc-4.2] r80407 - in /llvm-gcc-4.2/trunk/gcc: llvm-debug.cpp llvm-debug.h
Devang Patel
dpatel at apple.com
Fri Aug 28 16:27:36 PDT 2009
Author: dpatel
Date: Fri Aug 28 18:27:35 2009
New Revision: 80407
URL: http://llvm.org/viewvc/llvm-project?rev=80407&view=rev
Log:
Reapply 79978.
Use MDNodes to encode debug info in LLVM IR.
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
llvm-gcc-4.2/trunk/gcc/llvm-debug.h
Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=80407&r1=80406&r2=80407&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Fri Aug 28 18:27:35 2009
@@ -401,6 +401,7 @@
break;
}
}
+
return
DebugFactory.CreateBasicType(getOrCreateCompileUnit(main_input_filename),
TypeName,
@@ -445,7 +446,10 @@
DW_TAG_pointer_type :
DW_TAG_reference_type;
expanded_location Loc = GetNodeLocation(type);
- return DebugFactory.CreateDerivedType(Tag, findRegion(type), "",
+
+ std::string PName;
+ FromTy.getName(PName);
+ return DebugFactory.CreateDerivedType(Tag, findRegion(type), PName,
getOrCreateCompileUnit(NULL),
0 /*line no*/,
NodeSizeInBits(type),
@@ -576,13 +580,22 @@
// recursive) and replace all uses of the forward declaration with the
// final definition.
expanded_location Loc = GetNodeLocation(TREE_CHAIN(type), false);
+ // FIXME: findRegion() is not able to find context all the time. This
+ // means when type names in different context match then FwdDecl is
+ // reused because MDNodes are uniqued. To avoid this, use type context
+ /// also while creating FwdDecl for now.
+ std::string FwdName;
+ if (TYPE_CONTEXT(type))
+ FwdName = GetNodeName(TYPE_CONTEXT(type));
+ FwdName = FwdName + GetNodeName(type);
unsigned Flags = llvm::DIType::FlagFwdDecl;
if (TYPE_BLOCK_IMPL_STRUCT(type))
Flags |= llvm::DIType::FlagAppleBlock;
+
llvm::DICompositeType FwdDecl =
DebugFactory.CreateCompositeType(Tag,
findRegion(type),
- GetNodeName(type),
+ FwdName,
getOrCreateCompileUnit(Loc.file),
Loc.line,
0, 0, 0, Flags,
@@ -594,7 +607,7 @@
return FwdDecl;
// Insert into the TypeCache so that recursive uses will find it.
- TypeCache[type] = FwdDecl;
+ TypeCache[type] = FwdDecl.getNode();
// Convert all the elements.
llvm::SmallVector<llvm::DIDescriptor, 16> EltTys;
@@ -684,7 +697,7 @@
llvm::DIArray Elements =
DebugFactory.GetOrCreateArray(EltTys.data(), EltTys.size());
-
+
llvm::DICompositeType RealDecl =
DebugFactory.CreateCompositeType(Tag, findRegion(type),
GetNodeName(type),
@@ -705,6 +718,9 @@
DIType Ty;
if (tree TyDef = TYPE_NAME(type)) {
+ std::map<tree_node *, MDNode *>::iterator I = TypeCache.find(TyDef);
+ if (I != TypeCache.end())
+ return DIType(I->second);
if (TREE_CODE(TyDef) == TYPE_DECL && DECL_ORIGINAL_TYPE(TyDef)) {
expanded_location TypeDefLoc = GetNodeLocation(TyDef);
Ty = DebugFactory.CreateDerivedType(DW_TAG_typedef, findRegion(TyDef),
@@ -716,7 +732,7 @@
0 /*offset */,
0 /*flags*/,
MainTy);
- TypeCache[TyDef] = Ty;
+ TypeCache[TyDef] = Ty.getNode();
return Ty;
}
}
@@ -746,7 +762,7 @@
MainTy);
if (TYPE_VOLATILE(type) || TYPE_READONLY(type)) {
- TypeCache[type] = Ty;
+ TypeCache[type] = Ty.getNode();
return Ty;
}
@@ -766,10 +782,10 @@
if (TREE_CODE(type) == VOID_TYPE) return DIType();
// Check to see if the compile unit already has created this type.
- DIType &Slot = TypeCache[type];
- if (!Slot.isNull())
- return Slot;
-
+ std::map<tree_node *, MDNode *>::iterator I = TypeCache.find(type);
+ if (I != TypeCache.end())
+ return DIType(I->second);
+
DIType MainTy;
if (type != TYPE_MAIN_VARIANT(type) && TYPE_MAIN_VARIANT(type))
MainTy = getOrCreateType(TYPE_MAIN_VARIANT(type));
@@ -835,7 +851,7 @@
Ty = createBasicType(type);
break;
}
- TypeCache[type] = Ty;
+ TypeCache[type] = Ty.getNode();
return Ty;
}
@@ -861,7 +877,7 @@
bool isMain) {
if (!FullPath)
FullPath = main_input_filename;
- GlobalVariable *&CU = CUCache[FullPath];
+ MDNode *&CU = CUCache[FullPath];
if (CU)
return DICompileUnit(CU);
@@ -909,7 +925,7 @@
version_string, isMain,
optimize, Flags,
ObjcRunTimeVer);
- CU = NewCU.getGV();
+ CU = NewCU.getNode();
return NewCU;
}
Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.h?rev=80407&r1=80406&r2=80407&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.h Fri Aug 28 18:27:35 2009
@@ -59,8 +59,8 @@
const char *PrevFullPath; // Previous location file encountered.
int PrevLineNo; // Previous location line# encountered.
BasicBlock *PrevBB; // Last basic block encountered.
- std::map<std::string, GlobalVariable *> CUCache;
- std::map<tree_node *, DIType> TypeCache;
+ std::map<std::string, MDNode *> CUCache;
+ std::map<tree_node *, MDNode *> TypeCache;
// Cache of previously constructed
// Types.
std::vector<DIDescriptor> RegionStack;
More information about the llvm-commits
mailing list