[llvm-commits] [llvm-gcc-4.2] r98022 - in /llvm-gcc-4.2/trunk/gcc: llvm-debug.cpp llvm-debug.h
Devang Patel
dpatel at apple.com
Mon Mar 8 16:45:32 PST 2010
Author: dpatel
Date: Mon Mar 8 18:45:31 2010
New Revision: 98022
URL: http://llvm.org/viewvc/llvm-project?rev=98022&view=rev
Log:
Start using DIFile. Corresponding llvm patch is r98020.
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=98022&r1=98021&r2=98022&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Mon Mar 8 18:45:31 2010
@@ -319,7 +319,7 @@
ArtificialFnWithAbstractOrigin = true;
DIDescriptor SPContext = ArtificialFnWithAbstractOrigin ?
- getOrCreateCompileUnit(main_input_filename) :
+ getOrCreateFile(main_input_filename) :
findRegion (DECL_CONTEXT(FnDecl));
// Creating context may have triggered creation of this SP descriptor. So
@@ -361,7 +361,7 @@
DebugFactory.CreateSubprogram(SPContext,
FnName, FnName,
LinkageName,
- getOrCreateCompileUnit(Loc.file), lineno,
+ getOrCreateFile(Loc.file), lineno,
FNType,
Fn->hasInternalLinkage(),
true /*definition*/,
@@ -385,7 +385,7 @@
expanded_location Loc = GetNodeLocation(Node, false);
DINameSpace DNS =
DebugFactory.CreateNameSpace(Context, GetNodeName(Node),
- getOrCreateCompileUnit(Loc.file), Loc.line);
+ getOrCreateFile(Loc.file), Loc.line);
NameSpaceCache[Node] = WeakVH(DNS.getNode());
return DNS;
@@ -394,7 +394,7 @@
/// findRegion - Find tree_node N's region.
DIDescriptor DebugInfo::findRegion(tree Node) {
if (Node == NULL_TREE)
- return getOrCreateCompileUnit(main_input_filename);
+ return getOrCreateFile(main_input_filename);
std::map<tree_node *, WeakVH>::iterator I = RegionMap.find(Node);
if (I != RegionMap.end())
@@ -422,7 +422,7 @@
}
// Otherwise main compile unit covers everything.
- return getOrCreateCompileUnit(main_input_filename);
+ return getOrCreateFile(main_input_filename);
}
/// EmitFunctionEnd - Constructs the debug code for exiting a declarative
@@ -464,7 +464,7 @@
Ty = DebugFactory.CreateArtificialType(Ty);
llvm::DIVariable D =
DebugFactory.CreateVariable(Tag, VarScope,
- Name, getOrCreateCompileUnit(Loc.file),
+ Name, getOrCreateFile(Loc.file),
Loc.line, Ty);
// Insert an llvm.dbg.declare into the current block.
@@ -553,7 +553,7 @@
LinkageName = GV->getName();
DebugFactory.CreateGlobalVariable(findRegion(DECL_CONTEXT(decl)),
DispName, DispName, LinkageName,
- getOrCreateCompileUnit(Loc.file), Loc.line,
+ getOrCreateFile(Loc.file), Loc.line,
TyD, GV->hasInternalLinkage(),
true/*definition*/, GV);
}
@@ -600,9 +600,9 @@
}
return
- DebugFactory.CreateBasicType(getOrCreateCompileUnit(main_input_filename),
+ DebugFactory.CreateBasicType(getOrCreateFile(main_input_filename),
TypeName,
- getOrCreateCompileUnit(main_input_filename),
+ getOrCreateFile(main_input_filename),
0, Size, Align,
0, 0, Encoding);
}
@@ -631,9 +631,9 @@
sprintf(FwdTypeName, "fwd.type.%d", FwdTypeCount++);
llvm::DIType FwdType =
DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type,
- getOrCreateCompileUnit(NULL),
+ getOrCreateFile(main_input_filename),
FwdTypeName,
- getOrCreateCompileUnit(NULL),
+ getOrCreateFile(main_input_filename),
0, 0, 0, 0, 0,
llvm::DIType(), llvm::DIArray());
llvm::TrackingVH<llvm::MDNode> FwdTypeNode = FwdType.getNode();
@@ -674,7 +674,7 @@
DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type,
findRegion(TYPE_CONTEXT(type)),
StringRef(),
- getOrCreateCompileUnit(NULL),
+ getOrCreateFile(main_input_filename),
0, 0, 0, 0, 0,
llvm::DIType(), EltTypeArray);
@@ -706,7 +706,7 @@
DIType Ty =
DebugFactory.CreateDerivedType(Tag, findRegion(DECL_CONTEXT(TyName)),
GetNodeName(TyName),
- getOrCreateCompileUnit(TypeNameLoc.file),
+ getOrCreateFile(TypeNameLoc.file),
TypeNameLoc.line,
0 /*size*/,
0 /*align*/,
@@ -722,7 +722,7 @@
DebugFactory.CreateDerivedType(Tag, findRegion(TYPE_CONTEXT(type)),
Tag == DW_TAG_pointer_type ?
StringRef() : PName,
- getOrCreateCompileUnit(NULL),
+ getOrCreateFile(main_input_filename),
0 /*line no*/,
NodeSizeInBits(type),
NodeAlignInBits(type),
@@ -784,7 +784,7 @@
return DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_array_type,
findRegion(TYPE_CONTEXT(type)),
StringRef(),
- getOrCreateCompileUnit(Loc.file), 0,
+ getOrCreateFile(Loc.file), 0,
NodeSizeInBits(type),
NodeAlignInBits(type), 0, 0,
getOrCreateType(EltTy),
@@ -816,7 +816,7 @@
return DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_enumeration_type,
findRegion(TYPE_CONTEXT(type)),
GetNodeName(type),
- getOrCreateCompileUnit(Loc.file),
+ getOrCreateFile(Loc.file),
Loc.line,
NodeSizeInBits(type),
NodeAlignInBits(type), 0, 0,
@@ -834,8 +834,7 @@
if (TYPE_LANG_SPECIFIC (type)
&& lang_hooks.types.is_runtime_specific_type (type))
{
- DICompileUnit CU = getOrCreateCompileUnit(main_input_filename);
- unsigned CULang = CU.getLanguage();
+ unsigned CULang = TheCU.getLanguage();
switch (CULang) {
case DW_LANG_ObjC_plus_plus :
RunTimeLang = DW_LANG_ObjC_plus_plus;
@@ -890,7 +889,7 @@
DebugFactory.CreateCompositeType(Tag,
TyContext,
FwdName.c_str(),
- getOrCreateCompileUnit(Loc.file),
+ getOrCreateFile(Loc.file),
Loc.line,
0, 0, 0, SFlags | llvm::DIType::FlagFwdDecl,
llvm::DIType(), llvm::DIArray(),
@@ -940,7 +939,7 @@
DIType DTy =
DebugFactory.CreateDerivedType(DW_TAG_inheritance,
findRegion(TYPE_CONTEXT(type)), StringRef(),
- llvm::DICompileUnit(), 0,0,0,
+ llvm::DIFile(), 0,0,0,
Offset,
BFlags, BaseClass);
EltTys.push_back(DTy);
@@ -986,7 +985,7 @@
DebugFactory.CreateDerivedType(DW_TAG_member,
findRegion(DECL_CONTEXT(Member)),
MemberName,
- getOrCreateCompileUnit(MemLoc.file),
+ getOrCreateFile(MemLoc.file),
MemLoc.line, NodeSizeInBits(Member),
NodeAlignInBits(FieldNodeType),
int_bit_position(Member),
@@ -1025,7 +1024,7 @@
DebugFactory.CreateSubprogram(findRegion(DECL_CONTEXT(Member)),
MemberName, MemberName,
LinkageName,
- getOrCreateCompileUnit(MemLoc.file),
+ getOrCreateFile(MemLoc.file),
MemLoc.line, SPTy, false, false,
Virtuality, VIndex, ContainingType,
DECL_ARTIFICIAL (Member));
@@ -1050,7 +1049,7 @@
llvm::DICompositeType RealDecl =
DebugFactory.CreateCompositeType(Tag, findRegion(TYPE_CONTEXT(type)),
GetNodeName(type),
- getOrCreateCompileUnit(Loc.file),
+ getOrCreateFile(Loc.file),
Loc.line,
NodeSizeInBits(type), NodeAlignInBits(type),
0, SFlags, llvm::DIType(), Elements,
@@ -1078,7 +1077,7 @@
Ty = DebugFactory.CreateDerivedType(DW_TAG_typedef,
findRegion(DECL_CONTEXT(TyDef)),
GetNodeName(TyDef),
- getOrCreateCompileUnit(TypeDefLoc.file),
+ getOrCreateFile(TypeDefLoc.file),
TypeDefLoc.line,
0 /*size*/,
0 /*align*/,
@@ -1094,7 +1093,7 @@
Ty = DebugFactory.CreateDerivedType(DW_TAG_volatile_type,
findRegion(TYPE_CONTEXT(type)),
StringRef(),
- getOrCreateCompileUnit(NULL),
+ getOrCreateFile(main_input_filename),
0 /*line no*/,
NodeSizeInBits(type),
NodeAlignInBits(type),
@@ -1108,7 +1107,7 @@
Ty = DebugFactory.CreateDerivedType(DW_TAG_const_type,
findRegion(TYPE_CONTEXT(type)),
StringRef(),
- getOrCreateCompileUnit(NULL),
+ getOrCreateFile(main_input_filename),
0 /*line no*/,
NodeSizeInBits(type),
NodeAlignInBits(type),
@@ -1227,9 +1226,9 @@
// module does not contain any main compile unit then the code generator
// will emit multiple compile units in the output object file.
if (!strcmp (main_input_filename, ""))
- getOrCreateCompileUnit("<stdin>", true);
+ TheCU = getOrCreateCompileUnit("<stdin>", true);
else
- getOrCreateCompileUnit(main_input_filename, true);
+ TheCU = getOrCreateCompileUnit(main_input_filename, true);
}
/// getOrCreateCompileUnit - Get the compile unit from the cache or
@@ -1242,10 +1241,6 @@
else
FullPath = main_input_filename;
}
- std::map<std::string, WeakVH >::iterator I = CUCache.find(FullPath);
- if (I != CUCache.end())
- if (Value *M = I->second)
- return DICompileUnit(cast<MDNode>(M));
// Get source file information.
std::string Directory;
@@ -1286,13 +1281,27 @@
unsigned ObjcRunTimeVer = 0;
if (flag_objc_abi != 0 && flag_objc_abi != -1)
ObjcRunTimeVer = flag_objc_abi;
- DICompileUnit NewCU = DebugFactory.CreateCompileUnit(LangTag, FileName.c_str(),
- Directory.c_str(),
- version_string, isMain,
- optimize, Flags,
- ObjcRunTimeVer);
- CUCache[FullPath] = WeakVH(NewCU.getNode());
- return NewCU;
+ return DebugFactory.CreateCompileUnit(LangTag, FileName.c_str(),
+ Directory.c_str(),
+ version_string, isMain,
+ optimize, Flags,
+ ObjcRunTimeVer);
+}
+
+/// getOrCreateFile - Get DIFile descriptor.
+DIFile DebugInfo::getOrCreateFile(const char *FullPath) {
+ if (!FullPath) {
+ if (!strcmp (main_input_filename, ""))
+ FullPath = "<stdin>";
+ else
+ FullPath = main_input_filename;
+ }
+
+ // Get source file information.
+ std::string Directory;
+ std::string FileName;
+ DirectoryAndFile(FullPath, Directory, FileName);
+ return DebugFactory.CreateFile(FileName, Directory, TheCU);
}
/* LLVM LOCAL end (ENTIRE FILE!) */
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=98022&r1=98021&r2=98022&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.h Mon Mar 8 18:45:31 2010
@@ -62,7 +62,8 @@
const char *PrevFullPath; // Previous location file encountered.
int PrevLineNo; // Previous location line# encountered.
BasicBlock *PrevBB; // Last basic block encountered.
-
+ DICompileUnit TheCU; // The compile unit.
+
// Current GCC lexical block (or enclosing FUNCTION_DECL).
tree_node *CurrentGCCLexicalBlock;
@@ -71,7 +72,6 @@
// debug info (through MDNodes) is not shared accidently.
unsigned FwdTypeCount;
- std::map<std::string, WeakVH > CUCache;
std::map<tree_node *, WeakVH > TypeCache;
// Cache of previously constructed
// Types.
@@ -168,6 +168,9 @@
DICompileUnit getOrCreateCompileUnit(const char *FullPath,
bool isMain = false);
+ /// getOrCreateFile - Get DIFile descriptor.
+ DIFile getOrCreateFile(const char *FullPath);
+
/// findRegion - Find tree_node N's region.
DIDescriptor findRegion(tree_node *n);
More information about the llvm-commits
mailing list