[llvm] r198851 - Prototype of skeleton type units for fission

Kostya Serebryany kcc at google.com
Thu Jan 9 01:40:22 PST 2014


msan bootstrap bot is up and finds this bug too:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/1611/steps/check-llvm%20msan/logs/stdio


On Thu, Jan 9, 2014 at 12:27 PM, Kostya Serebryany <kcc at google.com> wrote:

> David,
>
> I observe a use-of-uninitialized somewhere near the code you were touching
> in the recent changes.
> Could you please take a look?
> This causes asan to SEGV:
> ./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
> ASAN:SIGSEGV
> =================================================================
> ==22210==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000
> (pc 0x000001879397 sp 0x7fff102262c0 bp 0x7fff102263b0 T0)
>     #0 0x1879396 in getOffset
> /home/kcc/llvm/lib/CodeGen/AsmPrinter/DIE.h:145
>     #1 0x1879396 in llvm::DwarfTypeUnit::emitHeader(llvm::MCSection
> const*, llvm::MCSymbol const*) const
> /home/kcc/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp:1991
>     #2 0x182e3c7 in llvm::DwarfFile::emitUnits(llvm::DwarfDebug*,
> llvm::MCSection const*, llvm::MCSymbol const*)
> /home/kcc/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:2123
>     #3 0x180f651 in emitDebugInfo
> /home/kcc/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:2134
>     #4 0x180f651 in llvm::DwarfDebug::endModule()
> /home/kcc/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:1144
>     #5 0x17d604f in llvm::AsmPrinter::doFinalization(llvm::Module&)
> /home/kcc/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:918
>     #6 0x2bc94f8 in llvm::FPPassManager::doFinalization(llvm::Module&)
> /home/kcc/llvm/lib/IR/LegacyPassManager.cpp:1575
>     #7 0x2bca102 in runOnModule
> /home/kcc/llvm/lib/IR/LegacyPassManager.cpp:1632
>     #8 0x2bca102 in llvm::legacy::PassManagerImpl::run(llvm::Module&)
> /home/kcc/llvm/lib/IR/LegacyPassManager.cpp:1710
>     #9 0x62bb93 in compileModule /home/kcc/llvm/tools/llc/llc.cpp:376
>     #10 0x62bb93 in main /home/kcc/llvm/tools/llc/llc.cpp:197
>
> valgrind tells this:
> ==22278== Conditional jump or move depends on uninitialised value(s)
> ==22278==    at 0xA6C55C: llvm::DwarfTypeUnit::emitHeader(llvm::MCSection
> const*, llvm::MCSymbol const*) const
> ==22278==    by 0xA56250: llvm::DwarfFile::emitUnits(llvm::DwarfDebug*,
> llvm::MCSection const*, llvm::MCSymbol const*)
> ==22278==    by 0xA4E186: llvm::DwarfDebug::endModule()
> ==22278==    by 0xA3E7E7: llvm::AsmPrinter::doFinalization(llvm::Module&)
> ==22278==    by 0x101C03D:
> llvm::FPPassManager::doFinalization(llvm::Module&)
> ==22278==    by 0x101C578:
> llvm::legacy::PassManagerImpl::run(llvm::Module&)
> ==22278==    by 0x101C7E9: llvm::legacy::PassManager::run(llvm::Module&)
> ==22278==    by 0x55D088: main
> ==22278==  Uninitialised value was created by a heap allocation
> ==22278==    at 0x4C2C9EE: operator new(unsigned long)
> (vg_replace_malloc.c:319)
> ==22278==    by 0xA5714A:
> llvm::DwarfDebug::addDwarfTypeUnitType(llvm::DICompileUnit,
> llvm::StringRef, llvm::DIE*, llvm::DICompositeType)
> ==22278==    by 0xA66DE6: llvm::DwarfUnit::getOrCreateTypeDIE(llvm::MDNode
> const*)
> ==22278==    by 0xA6920D: llvm::DwarfUnit::addType(llvm::DIE*,
> llvm::DIType, llvm::dwarf::Attribute)
> ==22278==    by 0xA6AC04:
> llvm::DwarfCompileUnit::createGlobalVariableDIE(llvm::DIGlobalVariable)
> ==22278==    by 0xA49104: llvm::DwarfDebug::beginModule()
> ==22278==    by 0xA48DAE: llvm::DwarfDebug::DwarfDebug(llvm::AsmPrinter*,
> llvm::Module*)
> ==22278==    by 0xA3A3EB:
> llvm::AsmPrinter::doInitialization(llvm::Module&)
> ==22278==    by 0x101BF75:
> llvm::FPPassManager::doInitialization(llvm::Module&)
> ==22278==    by 0x101C36D:
> llvm::legacy::PassManagerImpl::run(llvm::Module&)
> ==22278==    by 0x101C7E9: llvm::legacy::PassManager::run(llvm::Module&)
> ==22278==    by 0x55D088: main
>
> (our msan bot is down, I suspect msan would catch this as well)
>
>
>
>
> On Thu, Jan 9, 2014 at 9:08 AM, David Blaikie <dblaikie at gmail.com> wrote:
>
>> Author: dblaikie
>> Date: Wed Jan  8 23:08:28 2014
>> New Revision: 198851
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=198851&view=rev
>> Log:
>> Prototype of skeleton type units for fission
>>
>> Modified:
>>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
>>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
>>     llvm/trunk/lib/MC/MCObjectFileInfo.cpp
>>     llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll
>>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=198851&r1=198850&r2=198851&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Jan  8 23:08:28
>> 2014
>> @@ -2976,6 +2976,21 @@ DwarfCompileUnit *DwarfDebug::constructS
>>    return NewCU;
>>  }
>>
>> +// This DIE has the following attributes: DW_AT_comp_dir, DW_AT_dwo_name,
>> +// DW_AT_addr_base.
>> +DwarfTypeUnit *DwarfDebug::constructSkeletonTU(const DwarfTypeUnit *TU) {
>> +
>> +  DIE *Die = new DIE(dwarf::DW_TAG_type_unit);
>> +  DwarfTypeUnit *NewTU = new DwarfTypeUnit(
>> +      TU->getUniqueID(), Die, TU->getCUNode(), Asm, this,
>> &SkeletonHolder);
>> +  NewTU->setTypeSignature(TU->getTypeSignature());
>> +  NewTU->initSection(
>> +
>>  Asm->getObjFileLowering().getDwarfTypesSection(TU->getTypeSignature()));
>> +
>> +  initSkeletonUnit(TU, Die, NewTU);
>> +  return NewTU;
>> +}
>> +
>>  // Emit the .debug_info.dwo section for separated dwarf. This contains
>> the
>>  // compile units that would normally be in debug_info.
>>  void DwarfDebug::emitDebugInfoDWO() {
>> @@ -3018,8 +3033,6 @@ void DwarfDebug::addDwarfTypeUnitType(DI
>>      NewTU->addUInt(UnitDie, dwarf::DW_AT_language, dwarf::DW_FORM_data2,
>>                     CUNode.getLanguage());
>>
>> -    DIE *Die = NewTU->createTypeDIE(CTy);
>> -
>>      MD5 Hash;
>>      Hash.update(Identifier);
>>      // ... take the least significant 8 bytes and return those. Our MD5
>> @@ -3029,7 +3042,10 @@ void DwarfDebug::addDwarfTypeUnitType(DI
>>      Hash.final(Result);
>>      uint64_t Signature = *reinterpret_cast<support::ulittle64_t
>> *>(Result + 8);
>>      NewTU->setTypeSignature(Signature);
>> -    NewTU->setType(Die);
>> +    if (useSplitDwarf())
>> +      NewTU->setSkeleton(constructSkeletonTU(NewTU));
>> +
>> +    NewTU->setType(NewTU->createTypeDIE(CTy));
>>
>>      NewTU->initSection(
>>          useSplitDwarf()
>>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=198851&r1=198850&r2=198851&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Jan  8 23:08:28
>> 2014
>> @@ -596,6 +596,10 @@ class DwarfDebug : public AsmPrinterHand
>>    /// section.
>>    DwarfCompileUnit *constructSkeletonCU(const DwarfCompileUnit *CU);
>>
>> +  /// \brief Construct the split debug info compile unit for the debug
>> info
>> +  /// section.
>> +  DwarfTypeUnit *constructSkeletonTU(const DwarfTypeUnit *TU);
>> +
>>    /// \brief Emit the debug info dwo section.
>>    void emitDebugInfoDWO();
>>
>>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=198851&r1=198850&r2=198851&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Wed Jan  8 23:08:28
>> 2014
>> @@ -1987,7 +1987,9 @@ void DwarfTypeUnit::emitHeader(const MCS
>>    Asm->OutStreamer.AddComment("Type Signature");
>>    Asm->OutStreamer.EmitIntValue(TypeSignature, sizeof(TypeSignature));
>>    Asm->OutStreamer.AddComment("Type DIE Offset");
>> -  Asm->OutStreamer.EmitIntValue(Ty->getOffset(),
>> sizeof(Ty->getOffset()));
>> +  // In a skeleton type unit there is no type DIE so emit a zero offset.
>> +  Asm->OutStreamer.EmitIntValue(Ty ? Ty->getOffset() : 0,
>> +                                sizeof(Ty->getOffset()));
>>  }
>>
>>  void DwarfTypeUnit::initSection(const MCSection *Section) {
>>
>> Modified: llvm/trunk/lib/MC/MCObjectFileInfo.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectFileInfo.cpp?rev=198851&r1=198850&r2=198851&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/MC/MCObjectFileInfo.cpp (original)
>> +++ llvm/trunk/lib/MC/MCObjectFileInfo.cpp Wed Jan  8 23:08:28 2014
>> @@ -726,8 +726,9 @@ const MCSection *MCObjectFileInfo::getDw
>>
>>  const MCSection *
>>  MCObjectFileInfo::getDwarfTypesDWOSection(uint64_t Hash) const {
>> -  return Ctx->getELFSection(".debug_types.dwo", ELF::SHT_GROUP, 0,
>> -                            SectionKind::getMetadata(), 0, utostr(Hash));
>> +  return Ctx->getELFSection(".debug_types.dwo", ELF::SHT_PROGBITS,
>> +                            ELF::SHF_GROUP, SectionKind::getMetadata(),
>> 0,
>> +                            utostr(Hash));
>>  }
>>
>>  void MCObjectFileInfo::InitEHFrameSection() {
>>
>> Modified: llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll?rev=198851&r1=198850&r2=198851&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll (original)
>> +++ llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll Wed Jan  8
>> 23:08:28 2014
>> @@ -1,7 +1,10 @@
>>  ; REQUIRES: object-emission
>>
>>  ; RUN: llc %s -o %t -filetype=obj -O0 -generate-type-units
>> -mtriple=x86_64-unknown-linux-gnu
>> -; RUN: llvm-dwarfdump %t | FileCheck %s
>> +; RUN: llvm-dwarfdump %t | FileCheck --check-prefix=CHECK
>> --check-prefix=SINGLE %s
>> +
>> +; RUN: llc %s -split-dwarf=Enable -o %t -filetype=obj -O0
>> -generate-type-units -mtriple=x86_64-unknown-linux-gnu
>> +; RUN: llvm-dwarfdump %t | FileCheck --check-prefix=CHECK
>> --check-prefix=FISSION %s
>>
>>  ; Generated from:
>>  ; struct bar {};
>> @@ -43,7 +46,8 @@
>>
>>  ; wombat wom;
>>
>> -; CHECK-LABEL: .debug_info contents:
>> +; SINGLE-LABEL: .debug_info contents:
>> +; FISSION-LABEL: .debug_info.dwo contents:
>>  ; CHECK: Compile Unit: length = [[CU_SIZE:[0-9a-f]+]]
>>
>>  ; CHECK: DW_TAG_structure_type
>> @@ -53,18 +57,32 @@
>>
>>  ; Ensure the CU-local type 'walrus' is not placed in a type unit.
>>  ; CHECK: DW_TAG_structure_type
>> -; CHECK-NEXT: debug_str{{.*}}"walrus"
>> +; CHECK-NEXT: DW_AT_name{{.*}}"walrus"
>>  ; CHECK-NEXT: DW_AT_byte_size
>>  ; CHECK-NEXT: DW_AT_decl_file
>>  ; CHECK-NEXT: DW_AT_decl_line
>>
>> -; CHECK-LABEL: .debug_types contents:
>> +; FISSION-LABEL: .debug_types contents:
>> +; FISSION-NOT: type_signature
>> +; FISSION-LABEL: type_signature = 0x1d02f3be30cc5688
>> +; FISSION: DW_TAG_type_unit
>> +; FISSION: DW_AT_GNU_dwo_name{{.*}}"bar.dwo"
>> +; FISSION: DW_AT_comp_dir{{.*}}"/tmp/dbginfo"
>> +; FISSION-NOT: type_signature
>> +; FISSION-LABEL: type_signature = 0xb04af47397402e77
>> +; FISSION-NOT: type_signature
>> +; FISSION-LABEL: type_signature = 0xfd756cee88f8a118
>> +; FISSION-NOT: type_signature
>> +; FISSION-LABEL: type_signature = 0xe94f6d3843e62d6b
>> +
>> +; SINGLE-LABEL: .debug_types contents:
>> +; FISSION-LABEL: .debug_types.dwo contents:
>>
>>  ; Check that we generate a hash for bar and the value.
>>  ; CHECK-NOT: type_signature
>>  ; CHECK-LABEL: type_signature = 0x1d02f3be30cc5688
>>  ; CHECK: DW_TAG_structure_type
>> -; CHECK-NEXT: debug_str{{.*}}"bar"
>> +; CHECK-NEXT: DW_AT_name{{.*}}"bar"
>>
>>
>>  ; Check that we generate a hash for fluffy and the value.
>> @@ -72,13 +90,13 @@
>>  ; CHECK-LABEL: type_signature = 0xb04af47397402e77
>>  ; CHECK-NOT: DW_AT_GNU_odr_signature [DW_FORM_data8]
>> (0x9a0124d5a0c21c52)
>>  ; CHECK: DW_TAG_namespace
>> -; CHECK-NEXT: debug_str{{.*}}"echidna"
>> +; CHECK-NEXT: DW_AT_name{{.*}}"echidna"
>>  ; CHECK: DW_TAG_namespace
>> -; CHECK-NEXT: debug_str{{.*}}"capybara"
>> +; CHECK-NEXT: DW_AT_name{{.*}}"capybara"
>>  ; CHECK: DW_TAG_namespace
>> -; CHECK-NEXT: debug_str{{.*}}"mongoose"
>> +; CHECK-NEXT: DW_AT_name{{.*}}"mongoose"
>>  ; CHECK: DW_TAG_class_type
>> -; CHECK-NEXT: debug_str{{.*}}"fluffy"
>> +; CHECK-NEXT: DW_AT_name{{.*}}"fluffy"
>>
>>  ; Check that we generate a hash for wombat and the value, but not for the
>>  ; anonymous type contained within.
>> @@ -86,7 +104,7 @@
>>  ; CHECK-LABEL: type_signature = 0xfd756cee88f8a118
>>  ; CHECK-NOT: DW_AT_GNU_odr_signature [DW_FORM_data8] (0x685bcc220141e9d7)
>>  ; CHECK: DW_TAG_structure_type
>> -; CHECK-NEXT: debug_str{{.*}}"wombat"
>> +; CHECK-NEXT: DW_AT_name{{.*}}"wombat"
>>
>>  ; CHECK-NOT: type_signature
>>  ; CHECK-LABEL: type_signature = 0xe94f6d3843e62d6b
>> @@ -100,7 +118,7 @@
>>  ; CHECK-NOT: DW_AT_name
>>  ; CHECK-NOT: DW_AT_GNU_odr_signature
>>  ; CHECK: DW_TAG_member
>> -; CHECK-NEXT: debug_str{{.*}}"a"
>> +; CHECK-NEXT: DW_AT_name{{.*}}"a"
>>
>>  ; Use the unit size as a rough hash/identifier for the unit we're
>> dealing with
>>  ; it happens to be unambiguous at the moment, but it's hardly ideal.
>> @@ -110,17 +128,21 @@
>>  ; CHECK-NEXT: Offset Name
>>  ; CHECK-NEXT: "walrus"
>>  ; Type unit for 'bar'
>> -; CHECK-NEXT: unit_size = 0x00000023
>> +; SINGLE-NEXT: unit_size = 0x00000023
>> +; FISSION-NEXT: unit_size = 0x00000024
>>  ; CHECK-NEXT: Offset Name
>>  ; CHECK-NEXT: "bar"
>> -; CHECK-NEXT: unit_size = 0x0000005d
>> +; SINGLE-NEXT: unit_size = 0x0000005d
>> +; FISSION-NEXT: unit_size = 0x00000024
>>  ; CHECK-NEXT: Offset Name
>>  ; CHECK-NEXT: "int"
>>  ; CHECK-NEXT: "echidna::capybara::mongoose::fluffy"
>> -; CHECK-NEXT: unit_size = 0x0000003a
>> +; SINGLE-NEXT: unit_size = 0x0000003a
>> +; FISSION-NEXT: unit_size = 0x00000024
>>  ; CHECK-NEXT: Offset Name
>>  ; CHECK-NEXT: "wombat"
>> -; CHECK-NEXT: unit_size = 0x0000004b
>> +; SINGLE-NEXT: unit_size = 0x0000004b
>> +; FISSION-NEXT: unit_size = 0x00000024
>>  ; CHECK-NEXT: Offset Name
>>  ; CHECK-NEXT: "int"
>>
>> @@ -179,7 +201,7 @@ attributes #1 = { nounwind readnone }
>>  !llvm.module.flags = !{!42, !54}
>>  !llvm.ident = !{!43}
>>
>> -!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]
>> +!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]
>>  !1 = metadata !{metadata !"bar.cpp", metadata !"/tmp/dbginfo"}
>>  !2 = metadata !{i32 0}
>>  !3 = metadata !{metadata !4, metadata !5, metadata !13, metadata !16}
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140109/c8d9709d/attachment.html>


More information about the llvm-commits mailing list