Skip to content
  1. Jan 10, 2017
  2. Jan 02, 2017
  3. Dec 09, 2016
  4. Dec 08, 2016
    • Keno Fischer's avatar
      Revert "[CodeGen] Fix invalid DWARF info on Win64" · 3f98c183
      Keno Fischer authored
      Appears to break on build bots. Reverting pending investigation.
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289014 91177308-0d34-0410-b5e6-96231b3b80d8
      3f98c183
    • Keno Fischer's avatar
      [CodeGen] Fix invalid DWARF info on Win64 · 94c20c0a
      Keno Fischer authored
      The relocations for `DIEEntry::EmitValue` were wrong for Win64
      (emitting FK_Data_4 instead of FK_SecRel_4). This corrects that
      oversight so that the DWARF data is correct in Win64 COFF files.
      
      Fixes PR15393.
      
      Patch by Jameson Nash <jameson@juliacomputing.com> based on a patch
      by David Majnemer.
      
      Differential Revision: https://reviews.llvm.org/D21731
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289013 91177308-0d34-0410-b5e6-96231b3b80d8
      94c20c0a
    • Greg Clayton's avatar
      Make a DWARF generator so we can unit test DWARF APIs with gtest. · 777b5c3c
      Greg Clayton authored
      The only tests we have for the DWARF parser are the tests that use llvm-dwarfdump and expect output from textual dumps.
      
      More DWARF parser modification are coming in the next few weeks and I wanted to add tests that can verify that we can encode and decode all form types, as well as test some other basic DWARF APIs where we ask DIE objects for their children and siblings.
      
      DwarfGenerator.cpp was added in the lib/CodeGen directory. This file contains the code necessary to easily create DWARF for tests:
      
      dwarfgen::Generator DG;
      Triple Triple("x86_64--");
      bool success = DG.init(Triple, Version);
      if (!success)
        return;
      dwarfgen::CompileUnit &CU = DG.addCompileUnit();
      dwarfgen::DIE CUDie = CU.getUnitDIE();
      
      CUDie.addAttribute(DW_AT_name, DW_FORM_strp, "/tmp/main.c");
      CUDie.addAttribute(DW_AT_language, DW_FORM_data2, DW_LANG_C);
      
      dwarfgen::DIE SubprogramDie = CUDie.addChild(DW_TAG_subprogram);
      SubprogramDie.addAttribute(DW_AT_name, DW_FORM_strp, "main");
      SubprogramDie.addAttribute(DW_AT_low_pc, DW_FORM_addr, 0x1000U);
      SubprogramDie.addAttribute(DW_AT_high_pc, DW_FORM_addr, 0x2000U);
      
      dwarfgen::DIE IntDie = CUDie.addChild(DW_TAG_base_type);
      IntDie.addAttribute(DW_AT_name, DW_FORM_strp, "int");
      IntDie.addAttribute(DW_AT_encoding, DW_FORM_data1, DW_ATE_signed);
      IntDie.addAttribute(DW_AT_byte_size, DW_FORM_data1, 4);
      
      dwarfgen::DIE ArgcDie = SubprogramDie.addChild(DW_TAG_formal_parameter);
      ArgcDie.addAttribute(DW_AT_name, DW_FORM_strp, "argc");
      // ArgcDie.addAttribute(DW_AT_type, DW_FORM_ref4, IntDie);
      ArgcDie.addAttribute(DW_AT_type, DW_FORM_ref_addr, IntDie);
      
      StringRef FileBytes = DG.generate();
      MemoryBufferRef FileBuffer(FileBytes, "dwarf");
      auto Obj = object::ObjectFile::createObjectFile(FileBuffer);
      EXPECT_TRUE((bool)Obj);
      DWARFContextInMemory DwarfContext(*Obj.get());
      This code is backed by the AsmPrinter code that emits DWARF for the actual compiler.
      
      While adding unit tests it was discovered that DIEValue that used DIEEntry as their values had bugs where DW_FORM_ref1, DW_FORM_ref2, DW_FORM_ref8, and DW_FORM_ref_udata forms were not supported. These are all now supported. Added support for DW_FORM_string so we can emit inlined C strings.
      
      Centralized the code to unique abbreviations into a new DIEAbbrevSet class and made both the dwarfgen::Generator and the llvm::DwarfFile classes use the new class.
      
      Fixed comments in the llvm::DIE class so that the Offset is known to be the compile/type unit offset.
      
      DIEInteger now supports more DW_FORM values.
      
      There are also unit tests that cover:
      
      Encoding and decoding all form types and values
      Encoding and decoding all reference types (DW_FORM_ref1, DW_FORM_ref2, DW_FORM_ref4, DW_FORM_ref8, DW_FORM_ref_udata, DW_FORM_ref_addr) including cross compile unit references with that go forward one compile unit and backward on compile unit.
      
      Differential Revision: https://reviews.llvm.org/D27326
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289010 91177308-0d34-0410-b5e6-96231b3b80d8
      777b5c3c
  5. Dec 01, 2016
    • David Blaikie's avatar
      [debug info] Minor cleanup from D27170/r288399 · e348b776
      David Blaikie authored
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288421 91177308-0d34-0410-b5e6-96231b3b80d8
      e348b776
    • Benjamin Kramer's avatar
      Fix unused variable warning in Release builds. NFC. · a849108a
      Benjamin Kramer authored
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288401 91177308-0d34-0410-b5e6-96231b3b80d8
      a849108a
    • Greg Clayton's avatar
      This change removes the dependency on DwarfDebug that was used for... · fc1fc8ba
      Greg Clayton authored
      This change removes the dependency on DwarfDebug that was used for DW_FORM_ref_addr by making a new DIEUnit class in DIE.cpp.
      
      The DIEUnit class represents a compile or type unit and it owns the unit DIE as an instance variable. This allows anyone with a DIE, to get the unit DIE, and then get back to its DIEUnit without adding any new ivars to the DIE class. Why was this needed? The DIE class has an Offset that is always the CU relative DIE offset, not the "offset in debug info section" as was commented in the header file (the comment has been corrected). This is great for performance because most DIE references are compile unit relative and this means most code that accessed the DIE's offset didn't need to make it into a compile unit relative offset because it already was. When we needed to emit a DW_FORM_ref_addr though, we needed to find the absolute offset of the DIE by finding the DIE's compile/type unit. This class did have the absolute debug info/type offset and could be added to the CU relative offset to compute the absolute offset. With this change we can easily get back to a DIE's DIEUnit which will have this needed offset. Prior to this is required having a DwarfDebug and required calling:
      
      DwarfCompileUnit *DwarfDebug::lookupUnit(const DIE *CU) const;
      Now we can use the DIEUnit class to do so without needing DwarfDebug. All clients now use DIEUnit objects (the DwarfDebug stack and the DwarfLinker). A follow on patch for the DWARF generator will also take advantage of this.
      
      Differential Revision: https://reviews.llvm.org/D27170
      
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288399 91177308-0d34-0410-b5e6-96231b3b80d8
      fc1fc8ba
  6. Nov 23, 2016
  7. Oct 05, 2016
  8. Oct 04, 2016
  9. Aug 17, 2016
  10. Feb 11, 2016
    • Peter Collingbourne's avatar
      DwarfDebug: emit type units immediately. · cb444063
      Peter Collingbourne authored
      Rather than storing type units in a vector and emitting them at the end
      of code generation, emit them immediately and destroy them, reclaiming the
      memory we were using for their DIEs.
      
      In one benchmark carried out against Chromium's 50 largest (by bitcode
      file size) translation units, total peak memory consumption with type units
      decreased by median 17%, or by 7% when compared against disabling type units.
      
      Tested using check-{llvm,clang}, the GDB 7.5 test suite (with
      '-fdebug-types-section') and by eyeballing llvm-dwarfdump output on those
      Chromium translation units with split DWARF both disabled and enabled, and
      verifying that the only changes were to addresses and abbreviation ordering.
      
      Differential Revision: http://reviews.llvm.org/D17118
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260578 91177308-0d34-0410-b5e6-96231b3b80d8
      cb444063
  11. Feb 01, 2016
  12. Jan 07, 2016
  13. Nov 24, 2015
  14. Aug 02, 2015
  15. Jul 16, 2015
  16. Jun 25, 2015
    • Duncan P. N. Exon Smith's avatar
      AsmPrinter: Use an intrusively linked list for DIE::Children · 2da1484e
      Duncan P. N. Exon Smith authored
      Replace the `std::vector<>` for `DIE::Children` with an intrusively
      linked list.  This is a strict memory improvement: it requires no
      auxiliary storage, and reduces `sizeof(DIE)` by one pointer.  It also
      factors out the DIE-related malloc traffic.
      
      This drops llc memory usage from 735 MB down to 718 MB, or ~2.3%.
      
      (I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`;
      see r236629 for details.)
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240736 91177308-0d34-0410-b5e6-96231b3b80d8
      2da1484e
    • Duncan P. N. Exon Smith's avatar
      AsmPrinter: Convert DIE::Values to a linked list · 73e3fb6b
      Duncan P. N. Exon Smith authored
      Change `DIE::Values` to a singly linked list, where each node is
      allocated on a `BumpPtrAllocator`.  In order to support `push_back()`,
      the list is circular, and points at the tail element instead of the
      head.  I abstracted the core list logic out to `IntrusiveBackList` so
      that it can be reused for `DIE::Children`, which also cares about
      `push_back()`.
      
      This drops llc memory usage from 799 MB down to 735 MB, about 8%.
      
      (I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`;
      see r236629 for details.)
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240733 91177308-0d34-0410-b5e6-96231b3b80d8
      73e3fb6b
  17. Jun 24, 2015
  18. Jun 16, 2015
    • Rafael Espindola's avatar
      Rename and improve emitSectionOffset. · 3fea1651
      Rafael Espindola authored
      Different object formats represent references from dwarf in different ways.
      
      ELF uses a relocation to the referenced point (except for .dwo) and
      COFF/MachO use the offset of the referenced point inside its section.
      
      This patch renames emitSectionOffset because
      
      * It doesn't produce an offset on ELF.
      * It changes behavior depending on how DWARF is represented, so adding
      dwarf to its name is probably a good thing.
      
      The patch also adds an option to force the use of offsets.That avoids
      funny looking code like
      
        if (!UseOffsets)
          Asm->emitSectionOffset....
      
      It was correct, but read as if the ! was inverted.
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239866 91177308-0d34-0410-b5e6-96231b3b80d8
      3fea1651
  19. May 27, 2015
    • Duncan P. N. Exon Smith's avatar
      AsmPrinter: Stop exposing underlying DIEValue list, NFC · 636aba5b
      Duncan P. N. Exon Smith authored
      Change the `DIE` API to hide the implementation of the list of
      `DIEValue`s.
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238369 91177308-0d34-0410-b5e6-96231b3b80d8
      636aba5b
    • Duncan P. N. Exon Smith's avatar
      AsmPrinter: Store abbreviation data directly in DIE and DIEValue · 611a2f23
      Duncan P. N. Exon Smith authored
      Stop storing a `DIEAbbrev` in `DIE`, since the data fits neatly inside
      the `DIEValue` list.  Besides being a cleaner data structure (avoiding
      the parallel arrays), this gives us more freedom to rearrange the
      `DIEValue` list.
      
      This fixes the temporary memory regression from 845 MB up to 879 MB, and
      drops it further to 829 MB for a net memory decrease of around 1.9%
      (incremental decrease around 5.7%).
      
      (I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`;
      see r236629 for details.)
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238364 91177308-0d34-0410-b5e6-96231b3b80d8
      611a2f23
    • Duncan P. N. Exon Smith's avatar
      Reapply "AsmPrinter: Change DIEValue to be stored by value" · 09fe4bf7
      Duncan P. N. Exon Smith authored
      This reverts commit r238350, effectively reapplying r238349 after fixing
      (all?) the problems, all somehow related to how I was using
      `AlignedArrayCharUnion<>` inside `DIEValue`:
      
        - MSVC can only handle `sizeof()` on types, not values.  Change the
          assert.
        - GCC doesn't know the `is_trivially_copyable` type trait.  Instead of
          asserting it, add destructors.
        - Call placement new even when constructing POD (i.e., the pointers).
        - Instead of copying the char buffer, copy the casted classes.
      
      I've left in a couple of `static_assert`s that I think both MSVC and GCC
      know how to handle.  If the bots disagree with me, I'll remove them.
      
        - Check that the constructed type is either standard layout or a
          pointer.  This protects against a programming error: we really want
          the "small" `DIEValue`s to be small and simple, so don't
          accidentally change them not to be.
        - Similarly, check that the size of the buffer is no bigger than a
          `uint64_t` or a pointer.  (I thought checking against
          `sizeof(uint64_t)` would be good enough, but Chandler suggested that
          pointers might sometimes be bigger than that in the context of
          sanitizers.)
      
      I've also committed r238359 in the meantime, which introduces a
      DIEValue.def to simplify dispatching between the various types (thanks
      to a review comment by David Blaikie).  Without that, this commit would
      be almost unintelligible.
      
      Here's the original commit message:
      --
      Change `DIEValue` to be stored/passed/etc. by value, instead of
      reference.  It's now a discriminated union, with a `Val` field storing
      the actual type.  The classes that used to inherit from `DIEValue` no
      longer do.  There are two categories of these:
      
        - Small values fit in a single pointer and are stored by value.
        - Large values require auxiliary storage, and are stored by reference.
      
      The only non-mechanical change is to tools/dsymutil/DwarfLinker.cpp.  It
      was relying on `DIEInteger`s being passed around by reference, so I
      replaced that assumption with a `PatchLocation` type that stores a safe
      reference to where the `DIEInteger` lives instead.
      
      This commit causes a temporary regression in memory usage, since I've
      left merging `DIEAbbrevData` into `DIEValue` for a follow-up commit.  I
      measured an increase from 845 MB to 879 MB, around 3.9%.  The follow-up
      drops it lower than the starting point, and I've only recently brought
      the memory this low anyway, so I'm committing these changes separately
      to keep them incremental.  (I also considered swapping the commits, but
      the other one first would cause a lot more code churn.)
      
      (I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`;
      see r236629 for details.)
      --
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238362 91177308-0d34-0410-b5e6-96231b3b80d8
      09fe4bf7
    • Duncan P. N. Exon Smith's avatar
      AsmPrinter: Introduce DIEValue.def, NFC · 344593ce
      Duncan P. N. Exon Smith authored
      Use a .def macro file to iterate through the various subclasses of
      `DIEValue`.
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238359 91177308-0d34-0410-b5e6-96231b3b80d8
      344593ce
    • Duncan P. N. Exon Smith's avatar
      Revert "AsmPrinter: Change DIEValue to be stored by value" · 3c41ae83
      Duncan P. N. Exon Smith authored
      This reverts commit r238349, since it caused some errors on bots:
        - std::is_trivially_copyable isn't available until GCC 5.0.
        - It was complaining about strict aliasing with my use of
          ArrayCharUnion.
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238350 91177308-0d34-0410-b5e6-96231b3b80d8
      3c41ae83
    • Duncan P. N. Exon Smith's avatar
      AsmPrinter: Change DIEValue to be stored by value · b9d92c6a
      Duncan P. N. Exon Smith authored
      Change `DIEValue` to be stored/passed/etc. by value, instead of
      reference.  It's now a discriminated union, with a `Val` field storing
      the actual type.  The classes that used to inherit from `DIEValue` no
      longer do.  There are two categories of these:
      
        - Small values fit in a single pointer and are stored by value.
        - Large values require auxiliary storage, and are stored by reference.
      
      The only non-mechanical change is to tools/dsymutil/DwarfLinker.cpp.  It
      was relying on `DIEInteger`s being passed around by reference, so I
      replaced that assumption with a `PatchLocation` type that stores a safe
      reference to where the `DIEInteger` lives instead.
      
      This commit causes a temporary regression in memory usage, since I've
      left merging `DIEAbbrevData` into `DIEValue` for a follow-up commit.  I
      measured an increase from 845 MB to 879 MB, around 3.9%.  The follow-up
      drops it lower than the starting point, and I've only recently brought
      the memory this low anyway, so I'm committing these changes separately
      to keep them incremental.  (I also considered swapping the commits, but
      the other one first would cause a lot more code churn.)
      
      (I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`;
      see r236629 for details.)
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238349 91177308-0d34-0410-b5e6-96231b3b80d8
      b9d92c6a
    • Rafael Espindola's avatar
      Use operator<< instead of print in a few more places. · eac1f664
      Rafael Espindola authored
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238315 91177308-0d34-0410-b5e6-96231b3b80d8
      eac1f664
  20. May 24, 2015
    • Duncan P. N. Exon Smith's avatar
      AsmPrinter: Make DIEString small · 24ad5c9e
      Duncan P. N. Exon Smith authored
      Expose the `DwarfStringPool` entry in a header, and store a pointer to
      it directly in `DIEString`.  Instead of choosing at creation time how to
      emit it, use the `dwarf::Form` to determine that at emission time.
      Besides avoiding the other `DIEValue`, this shaves two pointers off of
      `DIEString`; the data is now a single pointer.  This is a nice cleanup
      on its own -- and drops memory usage from 861 MB down to 853 MB, around
      0.9% -- but it's also preparation for passing `DIEValue`s by value.
      
      (I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`;
      see r236629 for details.)
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238117 91177308-0d34-0410-b5e6-96231b3b80d8
      24ad5c9e
  21. May 23, 2015
  22. Apr 24, 2015
  23. Apr 17, 2015
    • Duncan P. N. Exon Smith's avatar
      AsmPrinter: Create a unified .debug_loc stream · 1186e7ae
      Duncan P. N. Exon Smith authored
      This commit removes `DebugLocList` and replaces it with
      `DebugLocStream`.
      
        - `DebugLocEntry` no longer contains its byte/comment streams.
        - The `DebugLocEntry` list for a variable/inlined-at pair is allocated
          on the stack, and released right after `DebugLocEntry::finalize()`
          (possible because of the refactoring in r231023).  Now, only one
          list is in memory at a time now.
        - There's a single unified stream for the `.debug_loc` section that
          persists, stored in the new `DebugLocStream` data structure.
      
      The last point is important: this collapses the nested `SmallVector<>`s
      from `DebugLocList` into unified streams.  We previously had something
      like the following:
      
          vec<tuple<Label, CU,
                    vec<tuple<BeginSym, EndSym,
                              vec<Value>,
                              vec<char>,
                              vec<string>>>>>
      
      A `SmallVector` can avoid allocations, but is statically fairly large
      for a vector: three pointers plus the size of the small storage, which
      is the number of elements in small mode times the element size).
      Nesting these is expensive, since an inner vector's size contributes to
      the element size of an outer one.  (Nesting any vector is expensive...)
      
      In the old data structure, the outer vector's *element* size was 632B,
      excluding allocation costs for when the middle and inner vectors
      exceeded their small sizes.  312B of this was for the "three" pointers
      in the vector-tree beneath it.  If you assume 1M functions with an
      average of 10 variable/inlined-at pairs each (in an LTO scenario),
      that's almost 6GB (besides inner allocations), with almost 3GB for the
      "three" pointers.
      
      This came up in a heap profile a little while ago of a `clang -flto -g`
      bootstrap, with `DwarfDebug::collectVariableInfo()` using something like
      10-15% of the total memory.
      
      With this commit, we have:
      
          tuple<vec<tuple<Label, CU, Offset>>,
                vec<tuple<BeginSym, EndSym, Offset, Offset>>,
                vec<char>,
                vec<string>>
      
      The offsets are used to create `ArrayRef` slices of adjacent
      `SmallVector`s.  This reduces the number of vectors to four (unrelated
      to the number of variable/inlined-at pairs), and caps the number of
      allocations at the same number.
      
      Besides saving memory and limiting allocations, this is NFC.
      
      I don't know my way around this code very well yet, but I wonder if we
      could go further: why stream to a side-table, instead of directly to the
      output stream?
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235229 91177308-0d34-0410-b5e6-96231b3b80d8
      1186e7ae