Changes in directory llvm/lib/CodeGen:
DwarfWriter.cpp updated: 1.29 -> 1.30 MachineDebugInfo.cpp updated: 1.17 -> 1.18 --- Log message: Add pointer and reference types. Added short-term code to ignore NULL types (to allow llvm-gcc4 to build.) --- Diffs of the changes: (+52 -29) DwarfWriter.cpp | 43 ++++++++++++++++++++++++++++++------------- MachineDebugInfo.cpp | 38 ++++++++++++++++++++++---------------- 2 files changed, 52 insertions(+), 29 deletions(-) Index: llvm/lib/CodeGen/DwarfWriter.cpp diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.29 llvm/lib/CodeGen/DwarfWriter.cpp:1.30 --- llvm/lib/CodeGen/DwarfWriter.cpp:1.29 Thu Feb 23 16:37:30 2006 +++ llvm/lib/CodeGen/DwarfWriter.cpp Fri Feb 24 10:46:40 2006 @@ -1235,6 +1235,9 @@ /// NewType - Create a new type DIE. /// DIE *DwarfWriter::NewType(DIE *Unit, TypeDesc *TyDesc) { + // FIXME - hack to get around NULL types short term. + if (!TyDesc) return NewBasicType(Unit, Type::IntTy); + // Check for pre-existence. DIE *&Slot = DescToDieMap[TyDesc]; if (Slot) return Slot; @@ -1246,29 +1249,43 @@ DIE *Ty = NULL; - // Determine how to handle. if (BasicTypeDesc *BasicTy = dyn_cast<BasicTypeDesc>(TyDesc)) { + // Fundamental types like int, float, bool Slot = Ty = new DIE(DW_TAG_base_type); unsigned Encoding = BasicTy->getEncoding(); Ty->AddUInt (DW_AT_encoding, DW_FORM_data1, Encoding); - } else if (TypedefDesc *TypedefTy = dyn_cast<TypedefDesc>(TyDesc)) { - Slot = Ty = new DIE(DW_TAG_typedef); - TypeDesc *FromTy = TypedefTy->getFromType(); - DIE *FromTyDie = NewType(Unit, FromTy); - CompileUnitDesc *File = TypedefTy->getFile(); - unsigned FileID = DebugInfo->RecordSource(File); - int Line = TypedefTy->getLine(); - - Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4, FromTyDie); - Ty->AddUInt (DW_AT_decl_file, 0, FileID); - Ty->AddUInt (DW_AT_decl_line, 0, Line); + } else if (DerivedTypeDesc *DerivedTy = dyn_cast<DerivedTypeDesc>(TyDesc)) { + // Determine which derived type. + unsigned T = 0; + switch (DerivedTy->getTag()) { + case DI_TAG_typedef: T = DW_TAG_typedef; break; + case DI_TAG_pointer: T = DW_TAG_pointer_type; break; + case DI_TAG_reference: T = DW_TAG_reference_type; break; + default: assert( 0 && "Unknown tag on derived type"); + } + + // Create specific DIE. + Slot = Ty = new DIE(T); + + // Map to main type, void will not have a type. + if (TypeDesc *FromTy = DerivedTy->getFromType()) { + Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4, NewType(Unit, FromTy)); + } } assert(Ty && "Type not supported yet"); - // Add common information. + // Add size if non-zero (derived types don't have a size.) if (Size) Ty->AddUInt(DW_AT_byte_size, 0, Size); + // Add name if not anonymous or intermediate type. if (!Name.empty()) Ty->AddString(DW_AT_name, DW_FORM_string, Name); + // Add source line info if present. + if (CompileUnitDesc *File = TyDesc->getFile()) { + unsigned FileID = DebugInfo->RecordSource(File); + int Line = TyDesc->getLine(); + Ty->AddUInt(DW_AT_decl_file, 0, FileID); + Ty->AddUInt(DW_AT_decl_line, 0, Line); + } // Add to context owner. Unit->AddChild(Ty); Index: llvm/lib/CodeGen/MachineDebugInfo.cpp diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.17 llvm/lib/CodeGen/MachineDebugInfo.cpp:1.18 --- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.17 Thu Feb 23 16:37:30 2006 +++ llvm/lib/CodeGen/MachineDebugInfo.cpp Fri Feb 24 10:46:40 2006 @@ -430,7 +430,9 @@ case DI_TAG_global_variable: return new GlobalVariableDesc(); case DI_TAG_subprogram: return new SubprogramDesc(); case DI_TAG_basictype: return new BasicTypeDesc(); - case DI_TAG_typedef: return new TypedefDesc(); + case DI_TAG_typedef: return new DerivedTypeDesc(DI_TAG_typedef); + case DI_TAG_pointer: return new DerivedTypeDesc(DI_TAG_pointer); + case DI_TAG_reference: return new DerivedTypeDesc(DI_TAG_reference); default: break; } return NULL; @@ -566,16 +568,19 @@ : DebugInfoDesc(T) , Context(NULL) , Name("") +, File(NULL) , Size(0) {} -/// ApplyToFields - Target the visitor to the fields of the TypeDesc. +/// ApplyToFields - Target the visitor to the fields of the TypeDesc. /// void TypeDesc::ApplyToFields(DIVisitor *Visitor) { DebugInfoDesc::ApplyToFields(Visitor); Visitor->Apply(Context); Visitor->Apply(Name); + Visitor->Apply((DebugInfoDesc *&)File); + Visitor->Apply(Line); Visitor->Apply(Size); } @@ -597,6 +602,8 @@ << "Tag(" << getTag() << "), " << "Context(" << Context << "), " << "Name(\"" << Name << "\"), " + << "File(" << File << "), " + << "Line(" << Line << "), " << "Size(" << Size << ")\n"; } #endif @@ -608,7 +615,7 @@ , Encoding(0) {} -/// ApplyToFields - Target the visitor to the fields of the BasicTypeDesc. +/// ApplyToFields - Target the visitor to the fields of the BasicTypeDesc. /// void BasicTypeDesc::ApplyToFields(DIVisitor *Visitor) { TypeDesc::ApplyToFields(Visitor); @@ -628,33 +635,32 @@ #endif //===----------------------------------------------------------------------===// -TypedefDesc::TypedefDesc() -: TypeDesc(DI_TAG_typedef) +DerivedTypeDesc::DerivedTypeDesc(unsigned T) +: TypeDesc(T) , FromType(NULL) -, File(NULL) -, Line(0) -{} +{ + assert((T == DI_TAG_typedef || T == DI_TAG_pointer || T == DI_TAG_reference)&& + "Unknown derived type."); +} -/// ApplyToFields - Target the visitor to the fields of the TypedefDesc. +/// ApplyToFields - Target the visitor to the fields of the DerivedTypeDesc. /// -void TypedefDesc::ApplyToFields(DIVisitor *Visitor) { +void DerivedTypeDesc::ApplyToFields(DIVisitor *Visitor) { TypeDesc::ApplyToFields(Visitor); Visitor->Apply((DebugInfoDesc *&)FromType); - Visitor->Apply((DebugInfoDesc *&)File); - Visitor->Apply(Line); } #ifndef NDEBUG -void TypedefDesc::dump() { +void DerivedTypeDesc::dump() { std::cerr << getDescString() << " " << "Tag(" << getTag() << "), " << "Context(" << getContext() << "), " << "Name(\"" << getName() << "\"), " << "Size(" << getSize() << "), " - << "FromType(" << FromType << "), " - << "File(" << File << "), " - << "Line(" << Line << ")\n"; + << "File(" << getFile() << "), " + << "Line(" << getLine() << "), " + << "FromType(" << FromType << ")\n"; } #endif _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits