Skip to content
  1. Jan 10, 2017
  2. Jan 05, 2017
  3. Dec 09, 2016
  4. Dec 08, 2016
    • Simon Pilgrim's avatar
      Wdocumentation fix · 97676403
      Simon Pilgrim authored
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289037 91177308-0d34-0410-b5e6-96231b3b80d8
      97676403
    • 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
    • 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 11, 2016
  7. Nov 10, 2016
  8. Jun 17, 2016
  9. Apr 18, 2016
    • Mehdi Amini's avatar
      [NFC] Header cleanup · f6071e14
      Mehdi Amini authored
      Removed some unused headers, replaced some headers with forward class declarations.
      
      Found using simple scripts like this one:
      clear && ack --cpp -l '#include "llvm/ADT/IndexedMap.h"' | xargs grep -L 'IndexedMap[<]' | xargs grep -n --color=auto 'IndexedMap'
      
      Patch by Eugene Kosov <claprix@yandex.ru>
      
      Differential Revision: http://reviews.llvm.org/D19219
      
      From: Mehdi Amini <mehdi.amini@apple.com>
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266595 91177308-0d34-0410-b5e6-96231b3b80d8
      f6071e14
  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. Jun 27, 2015
    • Duncan P. N. Exon Smith's avatar
      AsmPrinter: Document why DIEValueList uses a linked-list, NFC · 1f0cde9f
      Duncan P. N. Exon Smith authored
      There are two main reasons why a linked-list makes sense for
      `DIEValueList`.
      
       1. We want `DIE` to be on a `BumpPtrAllocator` to improve teardown
          efficiency.  Making `DIEValueList` array-based would make that much
          more complicated.
       2. The singly-linked list is fairly memory efficient.  The histogram
          [1] shows that most DIEs have relatively few values, so we often pay
          less than the 2/3-pointer static overhead of a vector.  Furthermore,
          we don't know ahead of time exactly how many values a `DIE` needs,
          so a vector-like scheme will on average over-allocate by ~50%.  As
          it happens, that's the same memory overhead as the linked list node.
      
      [1]: http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-May/085910.html
      
      The comment I added to the code is a little more succinct, but I think
      it's enough to give the idea.
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240868 91177308-0d34-0410-b5e6-96231b3b80d8
      1f0cde9f
  16. Jun 26, 2015
  17. 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
  18. Jun 24, 2015
  19. Jun 23, 2015
  20. Jun 19, 2015
  21. May 28, 2015
  22. May 27, 2015
    • Duncan P. N. Exon Smith's avatar
      AsmPrinter: Return added DIE from DIE::addChild() · 59be554d
      Duncan P. N. Exon Smith authored
      Change `DIE::addChild()` to return a reference to the just-added node,
      and update consumers to use it directly.  An upcoming commit will
      abstract away (and eventually change) the underlying storage of
      `DIE::Children`.
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238372 91177308-0d34-0410-b5e6-96231b3b80d8
      59be554d
    • 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
    • Duncan P. N. Exon Smith's avatar
      AsmPrinter: Reorganize DIE.h, NFC · 3e7c30ad
      Duncan P. N. Exon Smith authored
      An upcoming commit will switch to storing `DIEValue`s by value in a
      `DIE`, so move the `DIE` down below all the subclasses it can.  Two
      subclasses inherit from `DIE`, so drop those down below `DIE`.
      
      `DIEValue` will become a discriminated union, which contains an instance
      of one of the classes that are currently subclasses.  "Big" ones, such
      as those that inherit from `DIE`, will continue to be stored by pointer.
      This commit does as much of the code motion ahead of time as possible.
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238346 91177308-0d34-0410-b5e6-96231b3b80d8
      3e7c30ad
  23. May 24, 2015
  24. May 23, 2015
    • Duncan P. N. Exon Smith's avatar
      AsmPrinter: Remove the vtable-entry from DIEValue · b5f8c9b2
      Duncan P. N. Exon Smith authored
      Remove all virtual functions from `DIEValue`, dropping the vtable
      pointer from its layout.  Instead, create "impl" functions on the
      subclasses, and use the `DIEValue::Type` to implement the dynamic
      dispatch.
      
      This is necessary -- obviously not sufficient -- for passing `DIEValue`s
      around by value.  However, this change stands on its own: we make tons
      of these.  I measured a drop in memory usage from 888 MB down to 860 MB,
      or around 3.2%.
      
      (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@238084 91177308-0d34-0410-b5e6-96231b3b80d8
      b5f8c9b2