From 9b12559c4fc9b64fdd4ba3fe1f844fcf6754d223 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Tue, 10 Aug 2010 20:01:20 +0000 Subject: [PATCH] Do not forget debug info for enums. Use named mdnode to keep track of these types. llvm-svn: 110712 --- lib/Analysis/DebugInfo.cpp | 17 +++++++++++++++-- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 5 +++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp index 337dc3fc3d2..2bf87da5fa4 100644 --- a/lib/Analysis/DebugInfo.cpp +++ b/lib/Analysis/DebugInfo.cpp @@ -923,7 +923,14 @@ DICompositeType DIFactory::CreateCompositeType(unsigned Tag, ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang), ContainingType }; - return DICompositeType(MDNode::get(VMContext, &Elts[0], 13)); + + MDNode *Node = MDNode::get(VMContext, &Elts[0], 13); + // Create a named metadata so that we do not lose this enum info. + if (Tag == dwarf::DW_TAG_enumeration_type) { + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.enum"); + NMD->addOperand(Node); + } + return DICompositeType(Node); } @@ -955,7 +962,13 @@ DICompositeType DIFactory::CreateCompositeTypeEx(unsigned Tag, Elements, ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang) }; - return DICompositeType(MDNode::get(VMContext, &Elts[0], 12)); + MDNode *Node = MDNode::get(VMContext, &Elts[0], 12); + // Create a named metadata so that we do not lose this enum info. + if (Tag == dwarf::DW_TAG_enumeration_type) { + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.enum"); + NMD->addOperand(Node); + } + return DICompositeType(Node); } diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index e0a43a93d4f..e236c1b227e 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -2019,6 +2019,11 @@ void DwarfDebug::beginModule(Module *M) { E = DbgFinder.global_variable_end(); I != E; ++I) constructGlobalVariableDIE(*I); + //getOrCreateTypeDIE + if (NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.enum")) + for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) + getOrCreateTypeDIE(DIType(NMD->getOperand(i))); + // Prime section data. SectionMap.insert(Asm->getObjFileLowering().getTextSection());