<div dir="ltr">David, <div><br></div><div>I observe a use-of-uninitialized somewhere near the code you were touching in the recent changes. </div><div>Could you please take a look?</div><div>This causes asan to SEGV: </div>
<div><div>./bin/llc /home/kcc/llvm/test/DebugInfo/X86/generate-odr-hash.ll -split-dwarf=Enable -o test/DebugInfo/X86/Output/generate-odr-hash.ll.tmp -filetype=obj -O0 -generate-type-units -mtriple=x86_64-unknown-linux-gnu </div>
<div>ASAN:SIGSEGV</div><div>=================================================================</div><div>==22210==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x000001879397 sp 0x7fff102262c0 bp 0x7fff102263b0 T0)</div>
<div>    #0 0x1879396 in getOffset /home/kcc/llvm/lib/CodeGen/AsmPrinter/DIE.h:145</div><div>    #1 0x1879396 in llvm::DwarfTypeUnit::emitHeader(llvm::MCSection const*, llvm::MCSymbol const*) const /home/kcc/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp:1991</div>
<div>    #2 0x182e3c7 in llvm::DwarfFile::emitUnits(llvm::DwarfDebug*, llvm::MCSection const*, llvm::MCSymbol const*) /home/kcc/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:2123</div><div>    #3 0x180f651 in emitDebugInfo /home/kcc/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:2134</div>
<div>    #4 0x180f651 in llvm::DwarfDebug::endModule() /home/kcc/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:1144</div><div>    #5 0x17d604f in llvm::AsmPrinter::doFinalization(llvm::Module&) /home/kcc/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:918</div>
<div>    #6 0x2bc94f8 in llvm::FPPassManager::doFinalization(llvm::Module&) /home/kcc/llvm/lib/IR/LegacyPassManager.cpp:1575</div><div>    #7 0x2bca102 in runOnModule /home/kcc/llvm/lib/IR/LegacyPassManager.cpp:1632</div>
<div>    #8 0x2bca102 in llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/kcc/llvm/lib/IR/LegacyPassManager.cpp:1710</div><div>    #9 0x62bb93 in compileModule /home/kcc/llvm/tools/llc/llc.cpp:376</div><div>    #10 0x62bb93 in main /home/kcc/llvm/tools/llc/llc.cpp:197</div>
</div><div><br></div><div>valgrind tells this: </div><div><div>==22278== Conditional jump or move depends on uninitialised value(s)</div><div>==22278==    at 0xA6C55C: llvm::DwarfTypeUnit::emitHeader(llvm::MCSection const*, llvm::MCSymbol const*) const </div>
<div>==22278==    by 0xA56250: llvm::DwarfFile::emitUnits(llvm::DwarfDebug*, llvm::MCSection const*, llvm::MCSymbol const*) </div><div>==22278==    by 0xA4E186: llvm::DwarfDebug::endModule() </div><div>==22278==    by 0xA3E7E7: llvm::AsmPrinter::doFinalization(llvm::Module&) </div>
<div>==22278==    by 0x101C03D: llvm::FPPassManager::doFinalization(llvm::Module&) </div><div>==22278==    by 0x101C578: llvm::legacy::PassManagerImpl::run(llvm::Module&) </div><div>==22278==    by 0x101C7E9: llvm::legacy::PassManager::run(llvm::Module&) </div>
<div>==22278==    by 0x55D088: main </div><div>==22278==  Uninitialised value was created by a heap allocation</div><div>==22278==    at 0x4C2C9EE: operator new(unsigned long) (vg_replace_malloc.c:319)</div><div>==22278==    by 0xA5714A: llvm::DwarfDebug::addDwarfTypeUnitType(llvm::DICompileUnit, llvm::StringRef, llvm::DIE*, llvm::DICompositeType) </div>
<div>==22278==    by 0xA66DE6: llvm::DwarfUnit::getOrCreateTypeDIE(llvm::MDNode const*) </div><div>==22278==    by 0xA6920D: llvm::DwarfUnit::addType(llvm::DIE*, llvm::DIType, llvm::dwarf::Attribute) </div><div>==22278==    by 0xA6AC04: llvm::DwarfCompileUnit::createGlobalVariableDIE(llvm::DIGlobalVariable) </div>
<div>==22278==    by 0xA49104: llvm::DwarfDebug::beginModule() </div><div>==22278==    by 0xA48DAE: llvm::DwarfDebug::DwarfDebug(llvm::AsmPrinter*, llvm::Module*) </div><div>==22278==    by 0xA3A3EB: llvm::AsmPrinter::doInitialization(llvm::Module&) </div>
<div>==22278==    by 0x101BF75: llvm::FPPassManager::doInitialization(llvm::Module&) </div><div>==22278==    by 0x101C36D: llvm::legacy::PassManagerImpl::run(llvm::Module&) </div><div>==22278==    by 0x101C7E9: llvm::legacy::PassManager::run(llvm::Module&) </div>
<div>==22278==    by 0x55D088: main</div></div><div><br></div><div>(our msan bot is down, I suspect msan would catch this as well)</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Thu, Jan 9, 2014 at 9:08 AM, 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: Wed Jan  8 23:08:28 2014<br>
New Revision: 198851<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=198851&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=198851&view=rev</a><br>
Log:<br>
Prototype of skeleton type units for fission<br>
<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp<br>
    llvm/trunk/lib/MC/MCObjectFileInfo.cpp<br>
    llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll<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=198851&r1=198850&r2=198851&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=198851&r1=198850&r2=198851&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Jan  8 23:08:28 2014<br>
@@ -2976,6 +2976,21 @@ DwarfCompileUnit *DwarfDebug::constructS<br>
   return NewCU;<br>
 }<br>
<br>
+// This DIE has the following attributes: DW_AT_comp_dir, DW_AT_dwo_name,<br>
+// DW_AT_addr_base.<br>
+DwarfTypeUnit *DwarfDebug::constructSkeletonTU(const DwarfTypeUnit *TU) {<br>
+<br>
+  DIE *Die = new DIE(dwarf::DW_TAG_type_unit);<br>
+  DwarfTypeUnit *NewTU = new DwarfTypeUnit(<br>
+      TU->getUniqueID(), Die, TU->getCUNode(), Asm, this, &SkeletonHolder);<br>
+  NewTU->setTypeSignature(TU->getTypeSignature());<br>
+  NewTU->initSection(<br>
+      Asm->getObjFileLowering().getDwarfTypesSection(TU->getTypeSignature()));<br>
+<br>
+  initSkeletonUnit(TU, Die, NewTU);<br>
+  return NewTU;<br>
+}<br>
+<br>
 // Emit the .debug_info.dwo section for separated dwarf. This contains the<br>
 // compile units that would normally be in debug_info.<br>
 void DwarfDebug::emitDebugInfoDWO() {<br>
@@ -3018,8 +3033,6 @@ void DwarfDebug::addDwarfTypeUnitType(DI<br>
     NewTU->addUInt(UnitDie, dwarf::DW_AT_language, dwarf::DW_FORM_data2,<br>
                    CUNode.getLanguage());<br>
<br>
-    DIE *Die = NewTU->createTypeDIE(CTy);<br>
-<br>
     MD5 Hash;<br>
     Hash.update(Identifier);<br>
     // ... take the least significant 8 bytes and return those. Our MD5<br>
@@ -3029,7 +3042,10 @@ void DwarfDebug::addDwarfTypeUnitType(DI<br>
     Hash.final(Result);<br>
     uint64_t Signature = *reinterpret_cast<support::ulittle64_t *>(Result + 8);<br>
     NewTU->setTypeSignature(Signature);<br>
-    NewTU->setType(Die);<br>
+    if (useSplitDwarf())<br>
+      NewTU->setSkeleton(constructSkeletonTU(NewTU));<br>
+<br>
+    NewTU->setType(NewTU->createTypeDIE(CTy));<br>
<br>
     NewTU->initSection(<br>
         useSplitDwarf()<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=198851&r1=198850&r2=198851&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=198851&r1=198850&r2=198851&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Jan  8 23:08:28 2014<br>
@@ -596,6 +596,10 @@ class DwarfDebug : public AsmPrinterHand<br>
   /// section.<br>
   DwarfCompileUnit *constructSkeletonCU(const DwarfCompileUnit *CU);<br>
<br>
+  /// \brief Construct the split debug info compile unit for the debug info<br>
+  /// section.<br>
+  DwarfTypeUnit *constructSkeletonTU(const DwarfTypeUnit *TU);<br>
+<br>
   /// \brief Emit the debug info dwo section.<br>
   void emitDebugInfoDWO();<br>
<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=198851&r1=198850&r2=198851&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=198851&r1=198850&r2=198851&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Wed Jan  8 23:08:28 2014<br>
@@ -1987,7 +1987,9 @@ void DwarfTypeUnit::emitHeader(const MCS<br>
   Asm->OutStreamer.AddComment("Type Signature");<br>
   Asm->OutStreamer.EmitIntValue(TypeSignature, sizeof(TypeSignature));<br>
   Asm->OutStreamer.AddComment("Type DIE Offset");<br>
-  Asm->OutStreamer.EmitIntValue(Ty->getOffset(), sizeof(Ty->getOffset()));<br>
+  // In a skeleton type unit there is no type DIE so emit a zero offset.<br>
+  Asm->OutStreamer.EmitIntValue(Ty ? Ty->getOffset() : 0,<br>
+                                sizeof(Ty->getOffset()));<br>
 }<br>
<br>
 void DwarfTypeUnit::initSection(const MCSection *Section) {<br>
<br>
Modified: llvm/trunk/lib/MC/MCObjectFileInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectFileInfo.cpp?rev=198851&r1=198850&r2=198851&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectFileInfo.cpp?rev=198851&r1=198850&r2=198851&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/MC/MCObjectFileInfo.cpp (original)<br>
+++ llvm/trunk/lib/MC/MCObjectFileInfo.cpp Wed Jan  8 23:08:28 2014<br>
@@ -726,8 +726,9 @@ const MCSection *MCObjectFileInfo::getDw<br>
<br>
 const MCSection *<br>
 MCObjectFileInfo::getDwarfTypesDWOSection(uint64_t Hash) const {<br>
-  return Ctx->getELFSection(".debug_types.dwo", ELF::SHT_GROUP, 0,<br>
-                            SectionKind::getMetadata(), 0, utostr(Hash));<br>
+  return Ctx->getELFSection(".debug_types.dwo", ELF::SHT_PROGBITS,<br>
+                            ELF::SHF_GROUP, SectionKind::getMetadata(), 0,<br>
+                            utostr(Hash));<br>
 }<br>
<br>
 void MCObjectFileInfo::InitEHFrameSection() {<br>
<br>
Modified: llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll?rev=198851&r1=198850&r2=198851&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll?rev=198851&r1=198850&r2=198851&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll Wed Jan  8 23:08:28 2014<br>
@@ -1,7 +1,10 @@<br>
 ; REQUIRES: object-emission<br>
<br>
 ; RUN: llc %s -o %t -filetype=obj -O0 -generate-type-units -mtriple=x86_64-unknown-linux-gnu<br>
-; RUN: llvm-dwarfdump %t | FileCheck %s<br>
+; RUN: llvm-dwarfdump %t | FileCheck --check-prefix=CHECK --check-prefix=SINGLE %s<br>
+<br>
+; RUN: llc %s -split-dwarf=Enable -o %t -filetype=obj -O0 -generate-type-units -mtriple=x86_64-unknown-linux-gnu<br>
+; RUN: llvm-dwarfdump %t | FileCheck --check-prefix=CHECK --check-prefix=FISSION %s<br>
<br>
 ; Generated from:<br>
 ; struct bar {};<br>
@@ -43,7 +46,8 @@<br>
<br>
 ; wombat wom;<br>
<br>
-; CHECK-LABEL: .debug_info contents:<br>
+; SINGLE-LABEL: .debug_info contents:<br>
+; FISSION-LABEL: .debug_info.dwo contents:<br>
 ; CHECK: Compile Unit: length = [[CU_SIZE:[0-9a-f]+]]<br>
<br>
 ; CHECK: DW_TAG_structure_type<br>
@@ -53,18 +57,32 @@<br>
<br>
 ; Ensure the CU-local type 'walrus' is not placed in a type unit.<br>
 ; CHECK: DW_TAG_structure_type<br>
-; CHECK-NEXT: debug_str{{.*}}"walrus"<br>
+; CHECK-NEXT: DW_AT_name{{.*}}"walrus"<br>
 ; CHECK-NEXT: DW_AT_byte_size<br>
 ; CHECK-NEXT: DW_AT_decl_file<br>
 ; CHECK-NEXT: DW_AT_decl_line<br>
<br>
-; CHECK-LABEL: .debug_types contents:<br>
+; FISSION-LABEL: .debug_types contents:<br>
+; FISSION-NOT: type_signature<br>
+; FISSION-LABEL: type_signature = 0x1d02f3be30cc5688<br>
+; FISSION: DW_TAG_type_unit<br>
+; FISSION: DW_AT_GNU_dwo_name{{.*}}"bar.dwo"<br>
+; FISSION: DW_AT_comp_dir{{.*}}"/tmp/dbginfo"<br>
+; FISSION-NOT: type_signature<br>
+; FISSION-LABEL: type_signature = 0xb04af47397402e77<br>
+; FISSION-NOT: type_signature<br>
+; FISSION-LABEL: type_signature = 0xfd756cee88f8a118<br>
+; FISSION-NOT: type_signature<br>
+; FISSION-LABEL: type_signature = 0xe94f6d3843e62d6b<br>
+<br>
+; SINGLE-LABEL: .debug_types contents:<br>
+; FISSION-LABEL: .debug_types.dwo contents:<br>
<br>
 ; Check that we generate a hash for bar and the value.<br>
 ; CHECK-NOT: type_signature<br>
 ; CHECK-LABEL: type_signature = 0x1d02f3be30cc5688<br>
 ; CHECK: DW_TAG_structure_type<br>
-; CHECK-NEXT: debug_str{{.*}}"bar"<br>
+; CHECK-NEXT: DW_AT_name{{.*}}"bar"<br>
<br>
<br>
 ; Check that we generate a hash for fluffy and the value.<br>
@@ -72,13 +90,13 @@<br>
 ; CHECK-LABEL: type_signature = 0xb04af47397402e77<br>
 ; CHECK-NOT: DW_AT_GNU_odr_signature [DW_FORM_data8]   (0x9a0124d5a0c21c52)<br>
 ; CHECK: DW_TAG_namespace<br>
-; CHECK-NEXT: debug_str{{.*}}"echidna"<br>
+; CHECK-NEXT: DW_AT_name{{.*}}"echidna"<br>
 ; CHECK: DW_TAG_namespace<br>
-; CHECK-NEXT: debug_str{{.*}}"capybara"<br>
+; CHECK-NEXT: DW_AT_name{{.*}}"capybara"<br>
 ; CHECK: DW_TAG_namespace<br>
-; CHECK-NEXT: debug_str{{.*}}"mongoose"<br>
+; CHECK-NEXT: DW_AT_name{{.*}}"mongoose"<br>
 ; CHECK: DW_TAG_class_type<br>
-; CHECK-NEXT: debug_str{{.*}}"fluffy"<br>
+; CHECK-NEXT: DW_AT_name{{.*}}"fluffy"<br>
<br>
 ; Check that we generate a hash for wombat and the value, but not for the<br>
 ; anonymous type contained within.<br>
@@ -86,7 +104,7 @@<br>
 ; CHECK-LABEL: type_signature = 0xfd756cee88f8a118<br>
 ; CHECK-NOT: DW_AT_GNU_odr_signature [DW_FORM_data8] (0x685bcc220141e9d7)<br>
 ; CHECK: DW_TAG_structure_type<br>
-; CHECK-NEXT: debug_str{{.*}}"wombat"<br>
+; CHECK-NEXT: DW_AT_name{{.*}}"wombat"<br>
<br>
 ; CHECK-NOT: type_signature<br>
 ; CHECK-LABEL: type_signature = 0xe94f6d3843e62d6b<br>
@@ -100,7 +118,7 @@<br>
 ; CHECK-NOT: DW_AT_name<br>
 ; CHECK-NOT: DW_AT_GNU_odr_signature<br>
 ; CHECK: DW_TAG_member<br>
-; CHECK-NEXT: debug_str{{.*}}"a"<br>
+; CHECK-NEXT: DW_AT_name{{.*}}"a"<br>
<br>
 ; Use the unit size as a rough hash/identifier for the unit we're dealing with<br>
 ; it happens to be unambiguous at the moment, but it's hardly ideal.<br>
@@ -110,17 +128,21 @@<br>
 ; CHECK-NEXT: Offset Name<br>
 ; CHECK-NEXT: "walrus"<br>
 ; Type unit for 'bar'<br>
-; CHECK-NEXT: unit_size = 0x00000023<br>
+; SINGLE-NEXT: unit_size = 0x00000023<br>
+; FISSION-NEXT: unit_size = 0x00000024<br>
 ; CHECK-NEXT: Offset Name<br>
 ; CHECK-NEXT: "bar"<br>
-; CHECK-NEXT: unit_size = 0x0000005d<br>
+; SINGLE-NEXT: unit_size = 0x0000005d<br>
+; FISSION-NEXT: unit_size = 0x00000024<br>
 ; CHECK-NEXT: Offset Name<br>
 ; CHECK-NEXT: "int"<br>
 ; CHECK-NEXT: "echidna::capybara::mongoose::fluffy"<br>
-; CHECK-NEXT: unit_size = 0x0000003a<br>
+; SINGLE-NEXT: unit_size = 0x0000003a<br>
+; FISSION-NEXT: unit_size = 0x00000024<br>
 ; CHECK-NEXT: Offset Name<br>
 ; CHECK-NEXT: "wombat"<br>
-; CHECK-NEXT: unit_size = 0x0000004b<br>
+; SINGLE-NEXT: unit_size = 0x0000004b<br>
+; FISSION-NEXT: unit_size = 0x00000024<br>
 ; CHECK-NEXT: Offset Name<br>
 ; CHECK-NEXT: "int"<br>
<br>
@@ -179,7 +201,7 @@ attributes #1 = { nounwind readnone }<br>
 !llvm.module.flags = !{!42, !54}<br>
 !llvm.ident = !{!43}<br>
<br>
-!0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !3, metadata !20, metadata !37, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/tmp/dbginfo/bar.cpp] [DW_LANG_C_plus_plus]<br>

+!0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !3, metadata !20, metadata !37, metadata !2, metadata !"bar.dwo"} ; [ DW_TAG_compile_unit ] [/tmp/dbginfo/bar.cpp] [DW_LANG_C_plus_plus]<br>

 !1 = metadata !{metadata !"bar.cpp", metadata !"/tmp/dbginfo"}<br>
 !2 = metadata !{i32 0}<br>
 !3 = metadata !{metadata !4, metadata !5, metadata !13, metadata !16}<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>