<div dir="ltr">woot.<div><br></div><div style>Thank you! *crosses off of TODO list*</div><div style><br></div><div style>-eric</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Mar 11, 2013 at 4:39 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dblaikie<br>
Date: Mon Mar 11 18:39:23 2013<br>
New Revision: 176838<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=176838&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=176838&view=rev</a><br>
Log:<br>
Remove support for versioned debug info.<br>
<br>
Versioned debug info support has been a burden to maintain & also compromised<br>
current debug info verification by causing test cases testing old debug info to<br>
remain rather than being updated to the latest. It also makes it hard to add or<br>
change the metadata schema by requiring various backwards-compatibility in the<br>
DI* hierarchy.<br>
<br>
So it's being removed in preparation for new changes to the schema to tidy up<br>
old/unnecessary fields and add new fields needed for new debug info (well, new<br>
to LLVM at least).<br>
<br>
The more surprising part of this is the changes to DI*::Verify - this became<br>
necessary due to the changes to AsmWriter. AsmWriter was relying on the version<br>
test to decide which bits of metadata were actually debug info when printing<br>
the comment annotations. Without the version information the tag numbers were<br>
too common & it would print debug info on random metadata that happened to<br>
start with an integer that matched a tag number. Instead this change makes the<br>
Verify functions more precise (just adding "number of operands" checks - not<br>
type checking those operands yet) & relies on that to decide which metadata is<br>
debug info metadata.<br>
<br>
Modified:<br>
llvm/trunk/include/llvm/DebugInfo.h<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
llvm/trunk/lib/IR/AsmWriter.cpp<br>
llvm/trunk/lib/IR/DebugInfo.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo.h?rev=176838&r1=176837&r2=176838&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo.h?rev=176838&r1=176837&r2=176838&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo.h Mon Mar 11 18:39:23 2013<br>
@@ -96,15 +96,11 @@ namespace llvm {<br>
explicit DIDescriptor(const DIVariable F);<br>
explicit DIDescriptor(const DIType F);<br>
<br>
- bool Verify() const { return DbgNode != 0; }<br>
+ bool Verify() const;<br>
<br>
operator MDNode *() const { return const_cast<MDNode*>(DbgNode); }<br>
MDNode *operator ->() const { return const_cast<MDNode*>(DbgNode); }<br>
<br>
- unsigned getVersion() const {<br>
- return getUnsignedField(0) & LLVMDebugVersionMask;<br>
- }<br>
-<br>
unsigned getTag() const {<br>
return getUnsignedField(0) & ~LLVMDebugVersionMask;<br>
}<br>
@@ -146,6 +142,7 @@ namespace llvm {<br>
<br>
int64_t getLo() const { return getInt64Field(1); }<br>
int64_t getCount() const { return getInt64Field(2); }<br>
+ bool Verify() const;<br>
};<br>
<br>
/// DIArray - This descriptor holds an array of descriptors.<br>
@@ -220,10 +217,7 @@ namespace llvm {<br>
}<br>
StringRef getFilename() const { return getStringField(1); }<br>
StringRef getDirectory() const { return getStringField(2); }<br>
- DICompileUnit getCompileUnit() const{<br>
- assert (getVersion() <= LLVMDebugVersion10 && "Invalid CompileUnit!");<br>
- return getFieldAs<DICompileUnit>(3);<br>
- }<br>
+ bool Verify() const;<br>
};<br>
<br>
/// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').<br>
@@ -237,6 +231,7 @@ namespace llvm {<br>
<br>
StringRef getName() const { return getStringField(1); }<br>
uint64_t getEnumValue() const { return getUInt64Field(2); }<br>
+ bool Verify() const;<br>
};<br>
<br>
/// DIType - This is a wrapper for a type.<br>
@@ -257,13 +252,6 @@ namespace llvm {<br>
<br>
DIScope getContext() const { return getFieldAs<DIScope>(1); }<br>
StringRef getName() const { return getStringField(2); }<br>
- DICompileUnit getCompileUnit() const{<br>
- assert (getVersion() <= LLVMDebugVersion10 && "Invalid getCompileUnit!");<br>
- if (getVersion() == llvm::LLVMDebugVersion7)<br>
- return getFieldAs<DICompileUnit>(3);<br>
-<br>
- return getFieldAs<DIFile>(3).getCompileUnit();<br>
- }<br>
DIFile getFile() const { return getFieldAs<DIFile>(3); }<br>
unsigned getLineNumber() const { return getUnsignedField(4); }<br>
uint64_t getSizeInBits() const { return getUInt64Field(5); }<br>
@@ -310,15 +298,9 @@ namespace llvm {<br>
return DbgNode && (isBasicType() || isDerivedType() || isCompositeType());<br>
}<br>
StringRef getDirectory() const {<br>
- if (getVersion() == llvm::LLVMDebugVersion7)<br>
- return getCompileUnit().getDirectory();<br>
-<br>
return getFieldAs<DIFile>(3).getDirectory();<br>
}<br>
StringRef getFilename() const {<br>
- if (getVersion() == llvm::LLVMDebugVersion7)<br>
- return getCompileUnit().getFilename();<br>
-<br>
return getFieldAs<DIFile>(3).getFilename();<br>
}<br>
<br>
@@ -375,44 +357,6 @@ namespace llvm {<br>
return getConstantField(10);<br>
}<br>
<br>
- StringRef getObjCPropertyName() const {<br>
- if (getVersion() > LLVMDebugVersion11)<br>
- return StringRef();<br>
- return getStringField(10);<br>
- }<br>
- StringRef getObjCPropertyGetterName() const {<br>
- assert (getVersion() <= LLVMDebugVersion11 && "Invalid Request");<br>
- return getStringField(11);<br>
- }<br>
- StringRef getObjCPropertySetterName() const {<br>
- assert (getVersion() <= LLVMDebugVersion11 && "Invalid Request");<br>
- return getStringField(12);<br>
- }<br>
- bool isReadOnlyObjCProperty() {<br>
- assert (getVersion() <= LLVMDebugVersion11 && "Invalid Request");<br>
- return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_readonly) != 0;<br>
- }<br>
- bool isReadWriteObjCProperty() {<br>
- assert (getVersion() <= LLVMDebugVersion11 && "Invalid Request");<br>
- return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;<br>
- }<br>
- bool isAssignObjCProperty() {<br>
- assert (getVersion() <= LLVMDebugVersion11 && "Invalid Request");<br>
- return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_assign) != 0;<br>
- }<br>
- bool isRetainObjCProperty() {<br>
- assert (getVersion() <= LLVMDebugVersion11 && "Invalid Request");<br>
- return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_retain) != 0;<br>
- }<br>
- bool isCopyObjCProperty() {<br>
- assert (getVersion() <= LLVMDebugVersion11 && "Invalid Request");<br>
- return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_copy) != 0;<br>
- }<br>
- bool isNonAtomicObjCProperty() {<br>
- assert (getVersion() <= LLVMDebugVersion11 && "Invalid Request");<br>
- return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;<br>
- }<br>
-<br>
/// Verify - Verify that a derived type descriptor is well formed.<br>
bool Verify() const;<br>
};<br>
@@ -457,6 +401,7 @@ namespace llvm {<br>
}<br>
unsigned getLineNumber() const { return getUnsignedField(5); }<br>
unsigned getColumnNumber() const { return getUnsignedField(6); }<br>
+ bool Verify() const;<br>
};<br>
<br>
/// DITemplateValueParameter - This is a wrapper for template value parameter.<br>
@@ -476,6 +421,7 @@ namespace llvm {<br>
}<br>
unsigned getLineNumber() const { return getUnsignedField(6); }<br>
unsigned getColumnNumber() const { return getUnsignedField(7); }<br>
+ bool Verify() const;<br>
};<br>
<br>
/// DISubprogram - This is a wrapper for a subprogram (e.g. a function).<br>
@@ -489,13 +435,6 @@ namespace llvm {<br>
StringRef getName() const { return getStringField(3); }<br>
StringRef getDisplayName() const { return getStringField(4); }<br>
StringRef getLinkageName() const { return getStringField(5); }<br>
- DICompileUnit getCompileUnit() const{<br>
- assert (getVersion() <= LLVMDebugVersion10 && "Invalid getCompileUnit!");<br>
- if (getVersion() == llvm::LLVMDebugVersion7)<br>
- return getFieldAs<DICompileUnit>(6);<br>
-<br>
- return getFieldAs<DIFile>(6).getCompileUnit();<br>
- }<br>
unsigned getLineNumber() const { return getUnsignedField(7); }<br>
DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }<br>
<br>
@@ -529,50 +468,34 @@ namespace llvm {<br>
}<br>
<br>
unsigned isArtificial() const {<br>
- if (getVersion() <= llvm::LLVMDebugVersion8)<br>
- return getUnsignedField(14);<br>
return (getUnsignedField(14) & FlagArtificial) != 0;<br>
}<br>
/// isPrivate - Return true if this subprogram has "private"<br>
/// access specifier.<br>
bool isPrivate() const {<br>
- if (getVersion() <= llvm::LLVMDebugVersion8)<br>
- return false;<br>
return (getUnsignedField(14) & FlagPrivate) != 0;<br>
}<br>
/// isProtected - Return true if this subprogram has "protected"<br>
/// access specifier.<br>
bool isProtected() const {<br>
- if (getVersion() <= llvm::LLVMDebugVersion8)<br>
- return false;<br>
return (getUnsignedField(14) & FlagProtected) != 0;<br>
}<br>
/// isExplicit - Return true if this subprogram is marked as explicit.<br>
bool isExplicit() const {<br>
- if (getVersion() <= llvm::LLVMDebugVersion8)<br>
- return false;<br>
return (getUnsignedField(14) & FlagExplicit) != 0;<br>
}<br>
/// isPrototyped - Return true if this subprogram is prototyped.<br>
bool isPrototyped() const {<br>
- if (getVersion() <= llvm::LLVMDebugVersion8)<br>
- return false;<br>
return (getUnsignedField(14) & FlagPrototyped) != 0;<br>
}<br>
<br>
unsigned isOptimized() const;<br>
<br>
StringRef getFilename() const {<br>
- if (getVersion() == llvm::LLVMDebugVersion7)<br>
- return getCompileUnit().getFilename();<br>
-<br>
return getFieldAs<DIFile>(6).getFilename();<br>
}<br>
<br>
StringRef getDirectory() const {<br>
- if (getVersion() == llvm::LLVMDebugVersion7)<br>
- return getCompileUnit().getFilename();<br>
-<br>
return getFieldAs<DIFile>(6).getDirectory();<br>
}<br>
<br>
@@ -613,22 +536,10 @@ namespace llvm {<br>
StringRef getName() const { return getStringField(3); }<br>
StringRef getDisplayName() const { return getStringField(4); }<br>
StringRef getLinkageName() const { return getStringField(5); }<br>
- DICompileUnit getCompileUnit() const{<br>
- assert (getVersion() <= LLVMDebugVersion10 && "Invalid getCompileUnit!");<br>
- if (getVersion() == llvm::LLVMDebugVersion7)<br>
- return getFieldAs<DICompileUnit>(6);<br>
-<br>
- DIFile F = getFieldAs<DIFile>(6);<br>
- return F.getCompileUnit();<br>
- }<br>
StringRef getFilename() const {<br>
- if (getVersion() <= llvm::LLVMDebugVersion10)<br>
- return getContext().getFilename();<br>
return getFieldAs<DIFile>(6).getFilename();<br>
}<br>
StringRef getDirectory() const {<br>
- if (getVersion() <= llvm::LLVMDebugVersion10)<br>
- return getContext().getDirectory();<br>
return getFieldAs<DIFile>(6).getDirectory();<br>
<br>
}<br>
@@ -659,14 +570,6 @@ namespace llvm {<br>
<br>
DIScope getContext() const { return getFieldAs<DIScope>(1); }<br>
StringRef getName() const { return getStringField(2); }<br>
- DICompileUnit getCompileUnit() const {<br>
- assert (getVersion() <= LLVMDebugVersion10 && "Invalid getCompileUnit!");<br>
- if (getVersion() == llvm::LLVMDebugVersion7)<br>
- return getFieldAs<DICompileUnit>(3);<br>
-<br>
- DIFile F = getFieldAs<DIFile>(3);<br>
- return F.getCompileUnit();<br>
- }<br>
DIFile getFile() const { return getFieldAs<DIFile>(3); }<br>
unsigned getLineNumber() const {<br>
return (getUnsignedField(4) << 8) >> 8;<br>
@@ -679,8 +582,6 @@ namespace llvm {<br>
<br>
/// isArtificial - Return true if this variable is marked as "artificial".<br>
bool isArtificial() const {<br>
- if (getVersion() <= llvm::LLVMDebugVersion8)<br>
- return false;<br>
return (getUnsignedField(6) & FlagArtificial) != 0;<br>
}<br>
<br>
@@ -702,10 +603,6 @@ namespace llvm {<br>
unsigned getNumAddrElements() const;<br>
<br>
uint64_t getAddrElement(unsigned Idx) const {<br>
- if (getVersion() <= llvm::LLVMDebugVersion8)<br>
- return getUInt64Field(Idx+6);<br>
- if (getVersion() == llvm::LLVMDebugVersion9)<br>
- return getUInt64Field(Idx+7);<br>
return getUInt64Field(Idx+8);<br>
}<br>
<br>
@@ -737,6 +634,7 @@ namespace llvm {<br>
StringRef filename = getFieldAs<DIFile>(4).getFilename();<br>
return !filename.empty() ? filename : getContext().getFilename();<br>
}<br>
+ bool Verify() const;<br>
};<br>
<br>
/// DILexicalBlockFile - This is a wrapper for a lexical block with<br>
@@ -757,6 +655,7 @@ namespace llvm {<br>
return filename;<br>
}<br>
DILexicalBlock getScope() const { return getFieldAs<DILexicalBlock>(1); }<br>
+ bool Verify() const;<br>
};<br>
<br>
/// DINameSpace - A wrapper for a C++ style name space.<br>
@@ -771,13 +670,6 @@ namespace llvm {<br>
StringRef getFilename() const {<br>
return getFieldAs<DIFile>(3).getFilename();<br>
}<br>
- DICompileUnit getCompileUnit() const{<br>
- assert (getVersion() <= LLVMDebugVersion10 && "Invalid getCompileUnit!");<br>
- if (getVersion() == llvm::LLVMDebugVersion7)<br>
- return getFieldAs<DICompileUnit>(3);<br>
-<br>
- return getFieldAs<DIFile>(3).getCompileUnit();<br>
- }<br>
unsigned getLineNumber() const { return getUnsignedField(4); }<br>
bool Verify() const;<br>
};<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=176838&r1=176837&r2=176838&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=176838&r1=176837&r2=176838&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Mon Mar 11 18:39:23 2013<br>
@@ -1672,33 +1672,6 @@ DIE *CompileUnit::createMemberDIE(DIDeri<br>
if (DT.isArtificial())<br>
addFlag(MemberDie, dwarf::DW_AT_artificial);<br>
<br>
- // This is only for backward compatibility.<br>
- StringRef PropertyName = DT.getObjCPropertyName();<br>
- if (!PropertyName.empty()) {<br>
- addString(MemberDie, dwarf::DW_AT_APPLE_property_name, PropertyName);<br>
- StringRef GetterName = DT.getObjCPropertyGetterName();<br>
- if (!GetterName.empty())<br>
- addString(MemberDie, dwarf::DW_AT_APPLE_property_getter, GetterName);<br>
- StringRef SetterName = DT.getObjCPropertySetterName();<br>
- if (!SetterName.empty())<br>
- addString(MemberDie, dwarf::DW_AT_APPLE_property_setter, SetterName);<br>
- unsigned PropertyAttributes = 0;<br>
- if (DT.isReadOnlyObjCProperty())<br>
- PropertyAttributes |= dwarf::DW_APPLE_PROPERTY_readonly;<br>
- if (DT.isReadWriteObjCProperty())<br>
- PropertyAttributes |= dwarf::DW_APPLE_PROPERTY_readwrite;<br>
- if (DT.isAssignObjCProperty())<br>
- PropertyAttributes |= dwarf::DW_APPLE_PROPERTY_assign;<br>
- if (DT.isRetainObjCProperty())<br>
- PropertyAttributes |= dwarf::DW_APPLE_PROPERTY_retain;<br>
- if (DT.isCopyObjCProperty())<br>
- PropertyAttributes |= dwarf::DW_APPLE_PROPERTY_copy;<br>
- if (DT.isNonAtomicObjCProperty())<br>
- PropertyAttributes |= dwarf::DW_APPLE_PROPERTY_nonatomic;<br>
- if (PropertyAttributes)<br>
- addUInt(MemberDie, dwarf::DW_AT_APPLE_property_attribute, 0,<br>
- PropertyAttributes);<br>
- }<br>
return MemberDie;<br>
}<br>
<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=176838&r1=176837&r2=176838&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=176838&r1=176837&r2=176838&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Mar 11 18:39:23 2013<br>
@@ -756,82 +756,6 @@ void DwarfDebug::constructSubprogramDIE(<br>
TheCU->addGlobalName(SP.getName(), SubprogramDie);<br>
}<br>
<br>
-// Collect debug info from named mdnodes such as llvm.dbg.enum and llvm.dbg.ty.<br>
-void DwarfDebug::collectInfoFromNamedMDNodes(const Module *M) {<br>
- if (NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.sp"))<br>
- for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {<br>
- const MDNode *N = NMD->getOperand(i);<br>
- if (CompileUnit *CU = CUMap.lookup(DISubprogram(N).getCompileUnit()))<br>
- constructSubprogramDIE(CU, N);<br>
- }<br>
-<br>
- if (NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.gv"))<br>
- for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {<br>
- const MDNode *N = NMD->getOperand(i);<br>
- if (CompileUnit *CU = CUMap.lookup(DIGlobalVariable(N).getCompileUnit()))<br>
- CU->createGlobalVariableDIE(N);<br>
- }<br>
-<br>
- if (NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.enum"))<br>
- for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {<br>
- DIType Ty(NMD->getOperand(i));<br>
- if (CompileUnit *CU = CUMap.lookup(Ty.getCompileUnit()))<br>
- CU->getOrCreateTypeDIE(Ty);<br>
- }<br>
-<br>
- if (NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.ty"))<br>
- for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {<br>
- DIType Ty(NMD->getOperand(i));<br>
- if (CompileUnit *CU = CUMap.lookup(Ty.getCompileUnit()))<br>
- CU->getOrCreateTypeDIE(Ty);<br>
- }<br>
-}<br>
-<br>
-// Collect debug info using DebugInfoFinder.<br>
-// FIXME - Remove this when dragonegg switches to DIBuilder.<br>
-bool DwarfDebug::collectLegacyDebugInfo(const Module *M) {<br>
- DebugInfoFinder DbgFinder;<br>
- DbgFinder.processModule(*M);<br>
-<br>
- bool HasDebugInfo = false;<br>
- // Scan all the compile-units to see if there are any marked as the main<br>
- // unit. If not, we do not generate debug info.<br>
- for (DebugInfoFinder::iterator I = DbgFinder.compile_unit_begin(),<br>
- E = DbgFinder.compile_unit_end(); I != E; ++I) {<br>
- if (DICompileUnit(*I).isMain()) {<br>
- HasDebugInfo = true;<br>
- break;<br>
- }<br>
- }<br>
- if (!HasDebugInfo) return false;<br>
-<br>
- // Emit initial sections so we can refer to them later.<br>
- emitSectionLabels();<br>
-<br>
- // Create all the compile unit DIEs.<br>
- for (DebugInfoFinder::iterator I = DbgFinder.compile_unit_begin(),<br>
- E = DbgFinder.compile_unit_end(); I != E; ++I)<br>
- constructCompileUnit(*I);<br>
-<br>
- // Create DIEs for each global variable.<br>
- for (DebugInfoFinder::iterator I = DbgFinder.global_variable_begin(),<br>
- E = DbgFinder.global_variable_end(); I != E; ++I) {<br>
- const MDNode *N = *I;<br>
- if (CompileUnit *CU = CUMap.lookup(DIGlobalVariable(N).getCompileUnit()))<br>
- CU->createGlobalVariableDIE(N);<br>
- }<br>
-<br>
- // Create DIEs for each subprogram.<br>
- for (DebugInfoFinder::iterator I = DbgFinder.subprogram_begin(),<br>
- E = DbgFinder.subprogram_end(); I != E; ++I) {<br>
- const MDNode *N = *I;<br>
- if (CompileUnit *CU = CUMap.lookup(DISubprogram(N).getCompileUnit()))<br>
- constructSubprogramDIE(CU, N);<br>
- }<br>
-<br>
- return HasDebugInfo;<br>
-}<br>
-<br>
// Emit all Dwarf sections that should come prior to the content. Create<br>
// global DIEs and emit initial debug info sections. This is invoked by<br>
// the target AsmPrinter.<br>
@@ -844,30 +768,28 @@ void DwarfDebug::beginModule() {<br>
// If module has named metadata anchors then use them, otherwise scan the<br>
// module using debug info finder to collect debug info.<br>
NamedMDNode *CU_Nodes = M->getNamedMetadata("<a href="http://llvm.dbg.cu" target="_blank">llvm.dbg.cu</a>");<br>
- if (CU_Nodes) {<br>
- // Emit initial sections so we can reference labels later.<br>
- emitSectionLabels();<br>
-<br>
- for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {<br>
- DICompileUnit CUNode(CU_Nodes->getOperand(i));<br>
- CompileUnit *CU = constructCompileUnit(CUNode);<br>
- DIArray GVs = CUNode.getGlobalVariables();<br>
- for (unsigned i = 0, e = GVs.getNumElements(); i != e; ++i)<br>
- CU->createGlobalVariableDIE(GVs.getElement(i));<br>
- DIArray SPs = CUNode.getSubprograms();<br>
- for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i)<br>
- constructSubprogramDIE(CU, SPs.getElement(i));<br>
- DIArray EnumTypes = CUNode.getEnumTypes();<br>
- for (unsigned i = 0, e = EnumTypes.getNumElements(); i != e; ++i)<br>
- CU->getOrCreateTypeDIE(EnumTypes.getElement(i));<br>
- DIArray RetainedTypes = CUNode.getRetainedTypes();<br>
- for (unsigned i = 0, e = RetainedTypes.getNumElements(); i != e; ++i)<br>
- CU->getOrCreateTypeDIE(RetainedTypes.getElement(i));<br>
- }<br>
- } else if (!collectLegacyDebugInfo(M))<br>
+ if (!CU_Nodes)<br>
return;<br>
<br>
- collectInfoFromNamedMDNodes(M);<br>
+ // Emit initial sections so we can reference labels later.<br>
+ emitSectionLabels();<br>
+<br>
+ for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {<br>
+ DICompileUnit CUNode(CU_Nodes->getOperand(i));<br>
+ CompileUnit *CU = constructCompileUnit(CUNode);<br>
+ DIArray GVs = CUNode.getGlobalVariables();<br>
+ for (unsigned i = 0, e = GVs.getNumElements(); i != e; ++i)<br>
+ CU->createGlobalVariableDIE(GVs.getElement(i));<br>
+ DIArray SPs = CUNode.getSubprograms();<br>
+ for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i)<br>
+ constructSubprogramDIE(CU, SPs.getElement(i));<br>
+ DIArray EnumTypes = CUNode.getEnumTypes();<br>
+ for (unsigned i = 0, e = EnumTypes.getNumElements(); i != e; ++i)<br>
+ CU->getOrCreateTypeDIE(EnumTypes.getElement(i));<br>
+ DIArray RetainedTypes = CUNode.getRetainedTypes();<br>
+ for (unsigned i = 0, e = RetainedTypes.getNumElements(); i != e; ++i)<br>
+ CU->getOrCreateTypeDIE(RetainedTypes.getElement(i));<br>
+ }<br>
<br>
// Tell MMI that we have debug info.<br>
MMI->setDebugInfoAvailability(true);<br>
@@ -1211,16 +1133,10 @@ DwarfDebug::collectVariableInfo(const Ma<br>
if (DV.getTag() == dwarf::DW_TAG_arg_variable &&<br>
DISubprogram(DV.getContext()).describes(MF->getFunction()))<br>
Scope = LScopes.getCurrentFunctionScope();<br>
- else {<br>
- if (DV.getVersion() <= LLVMDebugVersion9)<br>
- Scope = LScopes.findLexicalScope(MInsn->getDebugLoc());<br>
- else {<br>
- if (MDNode *IA = DV.getInlinedAt())<br>
- Scope = LScopes.findInlinedScope(DebugLoc::getFromDILocation(IA));<br>
- else<br>
- Scope = LScopes.findLexicalScope(cast<MDNode>(DV->getOperand(1)));<br>
- }<br>
- }<br>
+ else if (MDNode *IA = DV.getInlinedAt())<br>
+ Scope = LScopes.findInlinedScope(DebugLoc::getFromDILocation(IA));<br>
+ else<br>
+ Scope = LScopes.findLexicalScope(cast<MDNode>(DV->getOperand(1)));<br>
// If variable scope is not found then skip this variable.<br>
if (!Scope)<br>
continue;<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=176838&r1=176837&r2=176838&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=176838&r1=176837&r2=176838&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Mon Mar 11 18:39:23 2013<br>
@@ -598,14 +598,6 @@ public:<br>
DwarfDebug(AsmPrinter *A, Module *M);<br>
~DwarfDebug();<br>
<br>
- /// \brief Collect debug info from named mdnodes such as llvm.dbg.enum<br>
- /// and llvm.dbg.ty<br>
- void collectInfoFromNamedMDNodes(const Module *M);<br>
-<br>
- /// \brief Collect debug info using DebugInfoFinder.<br>
- /// FIXME - Remove this when DragonEgg switches to DIBuilder.<br>
- bool collectLegacyDebugInfo(const Module *M);<br>
-<br>
/// \brief Emit all Dwarf sections that should come prior to the<br>
/// content.<br>
void beginModule();<br>
<br>
Modified: llvm/trunk/lib/IR/AsmWriter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=176838&r1=176837&r2=176838&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=176838&r1=176837&r2=176838&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)<br>
+++ llvm/trunk/lib/IR/AsmWriter.cpp Mon Mar 11 18:39:23 2013<br>
@@ -2094,7 +2094,7 @@ static void WriteMDNodeComment(const MDN<br>
return;<br>
<br>
DIDescriptor Desc(Node);<br>
- if (Desc.getVersion() < LLVMDebugVersion11)<br>
+ if (!Desc.Verify())<br>
return;<br>
<br>
unsigned Tag = Desc.getTag();<br>
<br>
Modified: llvm/trunk/lib/IR/DebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=176838&r1=176837&r2=176838&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=176838&r1=176837&r2=176838&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)<br>
+++ llvm/trunk/lib/IR/DebugInfo.cpp Mon Mar 11 18:39:23 2013<br>
@@ -51,6 +51,21 @@ DIDescriptor::DIDescriptor(const DIVaria<br>
DIDescriptor::DIDescriptor(const DIType F) : DbgNode(F.DbgNode) {<br>
}<br>
<br>
+bool DIDescriptor::Verify() const {<br>
+ return DbgNode &&<br>
+ (DIDerivedType(DbgNode).Verify() ||<br>
+ DICompositeType(DbgNode).Verify() || DIBasicType(DbgNode).Verify() ||<br>
+ DIVariable(DbgNode).Verify() || DISubprogram(DbgNode).Verify() ||<br>
+ DIGlobalVariable(DbgNode).Verify() || DIFile(DbgNode).Verify() ||<br>
+ DICompileUnit(DbgNode).Verify() || DINameSpace(DbgNode).Verify() ||<br>
+ DILexicalBlock(DbgNode).Verify() ||<br>
+ DILexicalBlockFile(DbgNode).Verify() ||<br>
+ DISubrange(DbgNode).Verify() || DIEnumerator(DbgNode).Verify() ||<br>
+ DIObjCProperty(DbgNode).Verify() ||<br>
+ DITemplateTypeParameter(DbgNode).Verify() ||<br>
+ DITemplateValueParameter(DbgNode).Verify());<br>
+}<br>
+<br>
StringRef<br>
DIDescriptor::getStringField(unsigned Elt) const {<br>
if (DbgNode == 0)<br>
@@ -135,17 +150,11 @@ void DIDescriptor::replaceFunctionField(<br>
}<br>
<br>
unsigned DIVariable::getNumAddrElements() const {<br>
- if (getVersion() <= LLVMDebugVersion8)<br>
- return DbgNode->getNumOperands()-6;<br>
- if (getVersion() == LLVMDebugVersion9)<br>
- return DbgNode->getNumOperands()-7;<br>
return DbgNode->getNumOperands()-8;<br>
}<br>
<br>
/// getInlinedAt - If this variable is inlined then return inline location.<br>
MDNode *DIVariable::getInlinedAt() const {<br>
- if (getVersion() <= LLVMDebugVersion9)<br>
- return NULL;<br>
return dyn_cast_or_null<MDNode>(DbgNode->getOperand(7));<br>
}<br>
<br>
@@ -392,31 +401,30 @@ bool DIType::isUnsignedDIType() {<br>
<br>
/// Verify - Verify that a compile unit is well formed.<br>
bool DICompileUnit::Verify() const {<br>
- if (!DbgNode)<br>
+ if (!isCompileUnit())<br>
return false;<br>
StringRef N = getFilename();<br>
if (N.empty())<br>
return false;<br>
// It is possible that directory and produce string is empty.<br>
- return true;<br>
+ return DbgNode->getNumOperands() == 15;<br>
}<br>
<br>
/// Verify - Verify that an ObjC property is well formed.<br>
bool DIObjCProperty::Verify() const {<br>
- if (!DbgNode)<br>
+ if (!isObjCProperty())<br>
return false;<br>
- unsigned Tag = getTag();<br>
- if (Tag != dwarf::DW_TAG_APPLE_property) return false;<br>
+<br>
DIType Ty = getType();<br>
if (!Ty.Verify()) return false;<br>
<br>
// Don't worry about the rest of the strings for now.<br>
- return true;<br>
+ return DbgNode->getNumOperands() == 8;<br>
}<br>
<br>
/// Verify - Verify that a type descriptor is well formed.<br>
bool DIType::Verify() const {<br>
- if (!DbgNode)<br>
+ if (!isType())<br>
return false;<br>
if (getContext() && !getContext().Verify())<br>
return false;<br>
@@ -437,27 +445,28 @@ bool DIType::Verify() const {<br>
<br>
/// Verify - Verify that a basic type descriptor is well formed.<br>
bool DIBasicType::Verify() const {<br>
- return isBasicType();<br>
+ return isBasicType() && DbgNode->getNumOperands() == 10;<br>
}<br>
<br>
/// Verify - Verify that a derived type descriptor is well formed.<br>
bool DIDerivedType::Verify() const {<br>
- return isDerivedType();<br>
+ return isDerivedType() && DbgNode->getNumOperands() >= 10 &&<br>
+ DbgNode->getNumOperands() <= 14;<br>
}<br>
<br>
/// Verify - Verify that a composite type descriptor is well formed.<br>
bool DICompositeType::Verify() const {<br>
- if (!DbgNode)<br>
+ if (!isCompositeType())<br>
return false;<br>
if (getContext() && !getContext().Verify())<br>
return false;<br>
<br>
- return true;<br>
+ return DbgNode->getNumOperands() >= 10 && DbgNode->getNumOperands() <= 14;<br>
}<br>
<br>
/// Verify - Verify that a subprogram descriptor is well formed.<br>
bool DISubprogram::Verify() const {<br>
- if (!DbgNode)<br>
+ if (!isSubprogram())<br>
return false;<br>
<br>
if (getContext() && !getContext().Verify())<br>
@@ -466,12 +475,12 @@ bool DISubprogram::Verify() const {<br>
DICompositeType Ty = getType();<br>
if (!Ty.Verify())<br>
return false;<br>
- return true;<br>
+ return DbgNode->getNumOperands() == 21;<br>
}<br>
<br>
/// Verify - Verify that a global variable descriptor is well formed.<br>
bool DIGlobalVariable::Verify() const {<br>
- if (!DbgNode)<br>
+ if (!isGlobalVariable())<br>
return false;<br>
<br>
if (getDisplayName().empty())<br>
@@ -487,12 +496,12 @@ bool DIGlobalVariable::Verify() const {<br>
if (!getGlobal() && !getConstant())<br>
return false;<br>
<br>
- return true;<br>
+ return DbgNode->getNumOperands() == 13;<br>
}<br>
<br>
/// Verify - Verify that a variable descriptor is well formed.<br>
bool DIVariable::Verify() const {<br>
- if (!DbgNode)<br>
+ if (!isVariable())<br>
return false;<br>
<br>
if (getContext() && !getContext().Verify())<br>
@@ -502,7 +511,7 @@ bool DIVariable::Verify() const {<br>
if (!Ty.Verify())<br>
return false;<br>
<br>
- return true;<br>
+ return DbgNode->getNumOperands() >= 8;<br>
}<br>
<br>
/// Verify - Verify that a location descriptor is well formed.<br>
@@ -515,9 +524,44 @@ bool DILocation::Verify() const {<br>
<br>
/// Verify - Verify that a namespace descriptor is well formed.<br>
bool DINameSpace::Verify() const {<br>
- if (!DbgNode)<br>
+ if (!isNameSpace())<br>
return false;<br>
- return true;<br>
+ return DbgNode->getNumOperands() == 5;<br>
+}<br>
+<br>
+/// \brief Verify that the file descriptor is well formed.<br>
+bool DIFile::Verify() const {<br>
+ return isFile() && DbgNode->getNumOperands() == 4;<br>
+}<br>
+<br>
+/// \brief Verify that the enumerator descriptor is well formed.<br>
+bool DIEnumerator::Verify() const {<br>
+ return isEnumerator() && DbgNode->getNumOperands() == 3;<br>
+}<br>
+<br>
+/// \brief Verify that the subrange descriptor is well formed.<br>
+bool DISubrange::Verify() const {<br>
+ return isSubrange() && DbgNode->getNumOperands() == 3;<br>
+}<br>
+<br>
+/// \brief Verify that the lexical block descriptor is well formed.<br>
+bool DILexicalBlock::Verify() const {<br>
+ return isLexicalBlock() && DbgNode->getNumOperands() == 6;<br>
+}<br>
+<br>
+/// \brief Verify that the file-scoped lexical block descriptor is well formed.<br>
+bool DILexicalBlockFile::Verify() const {<br>
+ return isLexicalBlockFile() && DbgNode->getNumOperands() == 3;<br>
+}<br>
+<br>
+/// \brief Verify that the template type parameter descriptor is well formed.<br>
+bool DITemplateTypeParameter::Verify() const {<br>
+ return isTemplateTypeParameter() && DbgNode->getNumOperands() == 7;<br>
+}<br>
+<br>
+/// \brief Verify that the template value parameter descriptor is well formed.<br>
+bool DITemplateValueParameter::Verify() const {<br>
+ return isTemplateValueParameter() && DbgNode->getNumOperands() == 8;<br>
}<br>
<br>
/// getOriginalTypeSize - If this type is derived from a base type then<br>
@@ -551,7 +595,7 @@ uint64_t DIDerivedType::getOriginalTypeS<br>
<br>
/// getObjCProperty - Return property node, if this ivar is associated with one.<br>
MDNode *DIDerivedType::getObjCProperty() const {<br>
- if (getVersion() <= LLVMDebugVersion11 || DbgNode->getNumOperands() <= 10)<br>
+ if (DbgNode->getNumOperands() <= 10)<br>
return NULL;<br>
return dyn_cast_or_null<MDNode>(DbgNode->getOperand(10));<br>
}<br>
@@ -803,71 +847,25 @@ void DebugInfoFinder::processModule(cons<br>
for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {<br>
DICompileUnit CU(CU_Nodes->getOperand(i));<br>
addCompileUnit(CU);<br>
- if (CU.getVersion() > LLVMDebugVersion10) {<br>
- DIArray GVs = CU.getGlobalVariables();<br>
- for (unsigned i = 0, e = GVs.getNumElements(); i != e; ++i) {<br>
- DIGlobalVariable DIG(GVs.getElement(i));<br>
- if (addGlobalVariable(DIG))<br>
- processType(DIG.getType());<br>
- }<br>
- DIArray SPs = CU.getSubprograms();<br>
- for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i)<br>
- processSubprogram(DISubprogram(SPs.getElement(i)));<br>
- DIArray EnumTypes = CU.getEnumTypes();<br>
- for (unsigned i = 0, e = EnumTypes.getNumElements(); i != e; ++i)<br>
- processType(DIType(EnumTypes.getElement(i)));<br>
- DIArray RetainedTypes = CU.getRetainedTypes();<br>
- for (unsigned i = 0, e = RetainedTypes.getNumElements(); i != e; ++i)<br>
- processType(DIType(RetainedTypes.getElement(i)));<br>
- return;<br>
- }<br>
- }<br>
- }<br>
-<br>
- for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I)<br>
- for (Function::const_iterator FI = (*I).begin(), FE = (*I).end();<br>
- FI != FE; ++FI)<br>
- for (BasicBlock::const_iterator BI = (*FI).begin(), BE = (*FI).end();<br>
- BI != BE; ++BI) {<br>
- if (const DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(BI))<br>
- processDeclare(DDI);<br>
-<br>
- DebugLoc Loc = BI->getDebugLoc();<br>
- if (Loc.isUnknown())<br>
- continue;<br>
-<br>
- LLVMContext &Ctx = BI->getContext();<br>
- DIDescriptor Scope(Loc.getScope(Ctx));<br>
-<br>
- if (Scope.isCompileUnit())<br>
- addCompileUnit(DICompileUnit(Scope));<br>
- else if (Scope.isSubprogram())<br>
- processSubprogram(DISubprogram(Scope));<br>
- else if (Scope.isLexicalBlockFile()) {<br>
- DILexicalBlockFile DBF = DILexicalBlockFile(Scope);<br>
- processLexicalBlock(DILexicalBlock(DBF.getScope()));<br>
- }<br>
- else if (Scope.isLexicalBlock())<br>
- processLexicalBlock(DILexicalBlock(Scope));<br>
-<br>
- if (MDNode *IA = Loc.getInlinedAt(Ctx))<br>
- processLocation(DILocation(IA));<br>
- }<br>
-<br>
- if (NamedMDNode *NMD = M.getNamedMetadata("llvm.dbg.gv")) {<br>
- for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {<br>
- DIGlobalVariable DIG(cast<MDNode>(NMD->getOperand(i)));<br>
- if (addGlobalVariable(DIG)) {<br>
- if (DIG.getVersion() <= LLVMDebugVersion10)<br>
- addCompileUnit(DIG.getCompileUnit());<br>
- processType(DIG.getType());<br>
+ DIArray GVs = CU.getGlobalVariables();<br>
+ for (unsigned i = 0, e = GVs.getNumElements(); i != e; ++i) {<br>
+ DIGlobalVariable DIG(GVs.getElement(i));<br>
+ if (addGlobalVariable(DIG))<br>
+ processType(DIG.getType());<br>
}<br>
+ DIArray SPs = CU.getSubprograms();<br>
+ for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i)<br>
+ processSubprogram(DISubprogram(SPs.getElement(i)));<br>
+ DIArray EnumTypes = CU.getEnumTypes();<br>
+ for (unsigned i = 0, e = EnumTypes.getNumElements(); i != e; ++i)<br>
+ processType(DIType(EnumTypes.getElement(i)));<br>
+ DIArray RetainedTypes = CU.getRetainedTypes();<br>
+ for (unsigned i = 0, e = RetainedTypes.getNumElements(); i != e; ++i)<br>
+ processType(DIType(RetainedTypes.getElement(i)));<br>
+ // FIXME: We really shouldn't be bailing out after visiting just one CU<br>
+ return;<br>
}<br>
}<br>
-<br>
- if (NamedMDNode *NMD = M.getNamedMetadata("llvm.dbg.sp"))<br>
- for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i)<br>
- processSubprogram(DISubprogram(NMD->getOperand(i)));<br>
}<br>
<br>
/// processLocation - Process DILocation.<br>
@@ -891,8 +889,6 @@ void DebugInfoFinder::processLocation(DI<br>
void DebugInfoFinder::processType(DIType DT) {<br>
if (!addType(DT))<br>
return;<br>
- if (DT.getVersion() <= LLVMDebugVersion10)<br>
- addCompileUnit(DT.getCompileUnit());<br>
if (DT.isCompositeType()) {<br>
DICompositeType DCT(DT);<br>
processType(DCT.getTypeDerivedFrom());<br>
@@ -927,8 +923,6 @@ void DebugInfoFinder::processLexicalBloc<br>
void DebugInfoFinder::processSubprogram(DISubprogram SP) {<br>
if (!addSubprogram(SP))<br>
return;<br>
- if (SP.getVersion() <= LLVMDebugVersion10)<br>
- addCompileUnit(SP.getCompileUnit());<br>
processType(SP.getType());<br>
}<br>
<br>
@@ -943,8 +937,6 @@ void DebugInfoFinder::processDeclare(con<br>
<br>
if (!NodesSeen.insert(DV))<br>
return;<br>
- if (DIVariable(N).getVersion() <= LLVMDebugVersion10)<br>
- addCompileUnit(DIVariable(N).getCompileUnit());<br>
processType(DIVariable(N).getType());<br>
}<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>