diff options
author | Eli Bendersky <eliben@google.com> | 2012-12-03 18:45:45 +0000 |
---|---|---|
committer | Eli Bendersky <eliben@google.com> | 2012-12-03 18:45:45 +0000 |
commit | d4a05e0c2c871a0acbadfe572abbdb99158871bd (patch) | |
tree | feb4685a9fb202a5350fc286f72bd02678c54199 /lib/CodeGen/AsmPrinter/DwarfDebug.cpp | |
parent | c69908695af9cf509bf498a492854db5f0556e0f (diff) |
Fix PR12942: Allow two CUs to be generated from the same source file.
Thanks Eric for the review.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169142 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 585332d97c..d008f0b296 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -156,7 +156,7 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) : Asm(A), MMI(Asm->MMI), FirstCU(0), FissionCU(0), AbbreviationsSet(InitAbbreviationsSetSize), SourceIdMap(DIEValueAllocator), StringPool(DIEValueAllocator), - PrevLabel(NULL) { + PrevLabel(NULL), GlobalCUIndexCount(0) { NextStringPoolNumber = 0; DwarfInfoSectionSym = DwarfAbbrevSectionSym = 0; @@ -615,11 +615,13 @@ CompileUnit *DwarfDebug::constructCompileUnit(const MDNode *N) { DICompileUnit DIUnit(N); StringRef FN = DIUnit.getFilename(); CompilationDir = DIUnit.getDirectory(); - unsigned ID = getOrCreateSourceID(FN, CompilationDir); + // Call this to emit a .file directive if it wasn't emitted for the source + // file this CU comes from yet. + getOrCreateSourceID(FN, CompilationDir); DIE *Die = new DIE(dwarf::DW_TAG_compile_unit); - CompileUnit *NewCU = new CompileUnit(ID, DIUnit.getLanguage(), Die, - Asm, this); + CompileUnit *NewCU = new CompileUnit(GlobalCUIndexCount++, + DIUnit.getLanguage(), Die, Asm, this); NewCU->addString(Die, dwarf::DW_AT_producer, DIUnit.getProducer()); NewCU->addUInt(Die, dwarf::DW_AT_language, dwarf::DW_FORM_data2, DIUnit.getLanguage()); @@ -1819,7 +1821,7 @@ void DwarfDebug::emitCompileUnits(const MCSection *Section) { // Emit the compile units header. Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("info_begin", - TheCU->getID())); + TheCU->getUniqueID())); // Emit size of content not including length itself unsigned ContentSize = Die->getSize() + @@ -1838,7 +1840,8 @@ void DwarfDebug::emitCompileUnits(const MCSection *Section) { Asm->EmitInt8(Asm->getDataLayout().getPointerSize()); emitDIE(Die); - Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("info_end", TheCU->getID())); + Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("info_end", + TheCU->getUniqueID())); } } @@ -2031,22 +2034,25 @@ void DwarfDebug::emitDebugPubTypes() { Asm->getObjFileLowering().getDwarfPubTypesSection()); Asm->OutStreamer.AddComment("Length of Public Types Info"); Asm->EmitLabelDifference( - Asm->GetTempSymbol("pubtypes_end", TheCU->getID()), - Asm->GetTempSymbol("pubtypes_begin", TheCU->getID()), 4); + Asm->GetTempSymbol("pubtypes_end", TheCU->getUniqueID()), + Asm->GetTempSymbol("pubtypes_begin", TheCU->getUniqueID()), 4); Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("pubtypes_begin", - TheCU->getID())); + TheCU->getUniqueID())); if (Asm->isVerbose()) Asm->OutStreamer.AddComment("DWARF Version"); Asm->EmitInt16(dwarf::DWARF_VERSION); Asm->OutStreamer.AddComment("Offset of Compilation Unit Info"); - Asm->EmitSectionOffset(Asm->GetTempSymbol("info_begin", TheCU->getID()), + Asm->EmitSectionOffset(Asm->GetTempSymbol("info_begin", + TheCU->getUniqueID()), DwarfInfoSectionSym); Asm->OutStreamer.AddComment("Compilation Unit Length"); - Asm->EmitLabelDifference(Asm->GetTempSymbol("info_end", TheCU->getID()), - Asm->GetTempSymbol("info_begin", TheCU->getID()), + Asm->EmitLabelDifference(Asm->GetTempSymbol("info_end", + TheCU->getUniqueID()), + Asm->GetTempSymbol("info_begin", + TheCU->getUniqueID()), 4); const StringMap<DIE*> &Globals = TheCU->getGlobalTypes(); @@ -2066,7 +2072,7 @@ void DwarfDebug::emitDebugPubTypes() { Asm->OutStreamer.AddComment("End Mark"); Asm->EmitInt32(0); Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("pubtypes_end", - TheCU->getID())); + TheCU->getUniqueID())); } } @@ -2317,11 +2323,10 @@ CompileUnit *DwarfDebug::constructFissionCU(const MDNode *N) { DICompileUnit DIUnit(N); StringRef FN = DIUnit.getFilename(); CompilationDir = DIUnit.getDirectory(); - unsigned ID = getOrCreateSourceID(FN, CompilationDir); DIE *Die = new DIE(dwarf::DW_TAG_compile_unit); - CompileUnit *NewCU = new CompileUnit(ID, DIUnit.getLanguage(), Die, - Asm, this); + CompileUnit *NewCU = new CompileUnit(GlobalCUIndexCount++, + DIUnit.getLanguage(), Die, Asm, this); // FIXME: This should be the .dwo file. NewCU->addString(Die, dwarf::DW_AT_GNU_dwo_name, FN); @@ -2350,7 +2355,7 @@ void DwarfDebug::emitFissionSkeletonCU(const MCSection *Section) { // Emit the compile units header. Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("skel_info_begin", - FissionCU->getID())); + FissionCU->getUniqueID())); // Emit size of content not including length itself unsigned ContentSize = Die->getSize() + @@ -2369,7 +2374,8 @@ void DwarfDebug::emitFissionSkeletonCU(const MCSection *Section) { Asm->EmitInt8(Asm->getDataLayout().getPointerSize()); emitDIE(Die); - Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("skel_info_end", FissionCU->getID())); + Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("skel_info_end", + FissionCU->getUniqueID())); } |