Skip to content
  1. Apr 23, 2016
  2. Apr 22, 2016
    • Adam Nemet's avatar
      [LoopUtils] Extend findStringMetadataForLoop to return the value for metadata · fe3def7c
      Adam Nemet authored
      E.g. for:
      
        !1 = {"llvm.distribute", i32 1}
      
      it now returns the MDOperand for 1.
      
      I will use this in LoopDistribution to check the value of the metadata.
      
      Note that the change is backward-compatible with its current use in
      LoopVersioningLICM.  An Optional implicitly converts to a bool depending
      whether it contains a value or not.
      
      llvm-svn: 267190
      fe3def7c
    • Geoff Berry's avatar
      [MemorySSA] Fix bug in CachingMemorySSAWalker::invalidateInfo · 9fe26e6d
      Geoff Berry authored
      Summary:
      CachingMemorySSAWalker::invalidateInfo was using IsCall to determine
      which cache map needed to be cleared of entries referring to the invalidated
      MemoryAccess, but there could also be entries referring to it in the
      other cache map (value entries, not key entries).  This change just
      clears both tables to be conservatively correct.
      
      Also add a verifyRemoved() function, called when expensive
      checks (i.e. XDEBUG) are enabled to verify that the invalidated
      MemoryAccess object is not referenced in any of the caches.
      
      Reviewers: dberlin, george.burgess.iv
      
      Subscribers: mcrosier, llvm-commits
      
      Differential Revision: http://reviews.llvm.org/D19388
      
      llvm-svn: 267157
      9fe26e6d
    • Vedant Kumar's avatar
      Revert "Initial implementation of optimization bisect support." · 6013f45f
      Vedant Kumar authored
      This reverts commit r267022, due to an ASan failure:
      
        http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/1549
      
      llvm-svn: 267115
      6013f45f
    • Duncan P. N. Exon Smith's avatar
      ValueMapper/Enumerator: Clean up code in post-order traversals, NFC · 71480bd0
      Duncan P. N. Exon Smith authored
      Re-layer the functions in the new (i.e., newly correct) post-order
      traversals in ValueEnumerator (r266947) and ValueMapper (r266949).
      Instead of adding a node to the worklist in a helper function and
      returning a flag to say what happened, return the node itself.  This
      makes the code way cleaner: the worklist is local to the main function,
      there is no flag for an early loop exit (since we can cleanly bury the
      loop), and it's perfectly clear when pointers into the worklist might be
      invalidated.
      
      I'm fixing both algorithms in the same commit to avoid repeating the
      commit message; if you take the time to understand one the other should
      be easy.  The diff itself isn't entirely obvious since the traversals
      have some noise (i.e., things to do), but here's the high-level change:
      
          auto helper = [&WL](T *Op) {     auto helper = [](T **&I, T **E) {
                                       =>    while (I != E) {
            if (shouldVisit(Op)) {             T *Op = *I++;
              WL.push(Op, Op->begin());        if (shouldVisit(Op)) {
              return true;                       return Op;
            }                                }
            return false;                    return nullptr;
          };                               };
                                       =>
          WL.push(S, S->begin());          WL.push(S, S->begin());
          while (!empty()) {               while (!empty()) {
            auto *N = WL.top().N;            auto *N = WL.top().N;
            auto *&I = WL.top().I;           auto *&I = WL.top().I;
            bool DidChange = false;
            while (I != N->end())
              if (helper(*I++)) {      =>    if (T *Op = helper(I, N->end()) {
                DidChange = true;              WL.push(Op, Op->begin());
                break;                         continue;
              }                              }
            if (DidChange)
              continue;
      
            POT.push(WL.pop());        =>    POT.push(WL.pop());
          }                                }
      
      Thanks to Mehdi for helping me find a better way to layer this.
      
      llvm-svn: 267099
      71480bd0
  3. Apr 21, 2016
    • Andrew Kaylor's avatar
      Initial implementation of optimization bisect support. · f0f27929
      Andrew Kaylor authored
      This patch implements a optimization bisect feature, which will allow optimizations to be selectively disabled at compile time in order to track down test failures that are caused by incorrect optimizations.
      
      The bisection is enabled using a new command line option (-opt-bisect-limit).  Individual passes that may be skipped call the OptBisect object (via an LLVMContext) to see if they should be skipped based on the bisect limit.  A finer level of control (disabling individual transformations) can be managed through an addition OptBisect method, but this is not yet used.
      
      The skip checking in this implementation is based on (and replaces) the skipOptnoneFunction check.  Where that check was being called, a new call has been inserted in its place which checks the bisect limit and the optnone attribute.  A new function call has been added for module and SCC passes that behaves in a similar way.
      
      Differential Revision: http://reviews.llvm.org/D19172
      
      llvm-svn: 267022
      f0f27929
    • Adam Nemet's avatar
      [LoopUtils] Fix typo in comment · 6dcf0788
      Adam Nemet authored
      llvm-svn: 267016
      6dcf0788
    • Adam Nemet's avatar
      [LoopUtils] Add asserts to findStringMetadataForLoop. NFC · 293be666
      Adam Nemet authored
      These ensure that operand array has at least one element and it is the
      self-reference.
      
      llvm-svn: 267015
      293be666
    • Adam Nemet's avatar
      [LoopUtils] Move def of findStringMetadataForLoop to LoopUtils.cpp. NFC · 963341c8
      Adam Nemet authored
      The decl is in LoopUtils.h.  I think that this was added to
      LoopVersioningLICM.cpp by mistake.
      
      llvm-svn: 267014
      963341c8
    • Sanjoy Das's avatar
      [SimplifyCFG] Fold `llvm.guard(false)` to unreachable · 54a3a006
      Sanjoy Das authored
      Summary:
      `llvm.guard(false)` always bails out of the current compilation unit, so
      we can prune any control flow following it.
      
      Reviewers: hfinkel, pcc, reames
      
      Subscribers: majnemer, reames, mcrosier, llvm-commits
      
      Differential Revision: http://reviews.llvm.org/D19245
      
      llvm-svn: 266955
      54a3a006
    • Duncan P. N. Exon Smith's avatar
      ValueMapper: Map uniqued nodes in post-order · 0ab44dbf
      Duncan P. N. Exon Smith authored
      The iteratitive algorithm from r265456 claimed but failed to create a
      post-order traversal.  It had the same error that was fixed in the
      ValueEnumerator in r266947: now, instead of pushing all operands on the
      worklist at once, we pause whenever an operand gets pushed in order to
      go depth-first (I know, it sounds obvious).
      
      Sadly, I have no idea how to observe this from outside the algorithm and
      so I haven't written a test.  The output should be the same; it should
      just use fewer temporary nodes now.  I've added some comments that I
      hope make the current logic clear enough it's unlikely to regress.
      
      llvm-svn: 266949
      0ab44dbf
  4. Apr 20, 2016
  5. Apr 19, 2016
  6. Apr 18, 2016
    • Mehdi Amini's avatar
      [NFC] Header cleanup · b550cb17
      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>
      llvm-svn: 266595
      b550cb17
  7. Apr 17, 2016
    • Duncan P. N. Exon Smith's avatar
      Transforms: Try harder to fix bootstrap after r266565 · 724c5034
      Duncan P. N. Exon Smith authored
      This catches two nullptr insertions into the ValueMap I missed in
      r266567.  I missed CloneFunction becuase it never calls RemapInstruction
      directly.  Here's one of the still-failing bots:
        http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/11496
      
      llvm-svn: 266570
      724c5034
    • Duncan P. N. Exon Smith's avatar
      Linker: Don't double-schedule appending variables · 0fdaf8c9
      Duncan P. N. Exon Smith authored
      Add an assertion to ValueMapper that prevents double-scheduling of
      GlobalValues to remap, and fix the one place it happened.  There are
      tons of tests that fail with this assertion in place and without the
      code change, so I'm not adding another.
      
      Although it looks related, r266563 was, indeed, removing dead code.
      AFAICT, this cross-file double-scheduling started in r266510 when the
      cross-file recursion was removed.
      
      llvm-svn: 266569
      0fdaf8c9
    • Duncan P. N. Exon Smith's avatar
      Transforms: Fix bootstrap after r266565 · a71301be
      Duncan P. N. Exon Smith authored
      Apparently there isn't test coverage for all of these.  I'd appreciate
      if someone with could reproduce and send me something to reduce, but for
      now I've just looked for users of RemapInstruction and MapValue and
      ensured they don't accidentally insert nullptr.  Here is one of the
      bootstraps that caught:
      
        http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/11494
      
      llvm-svn: 266567
      a71301be
    • Duncan P. N. Exon Smith's avatar
      ValueMapper: Don't allow explicit null mappings of Values, NFC · 3d555ac9
      Duncan P. N. Exon Smith authored
      As a follow-up to r123058, assert that there are no null mappings in the
      ValueMap instead of just ignoring them when they are there.  There were
      a couple of accidental insertions in CloneFunction so I cleaned those up
      (caught by testcases).
      
      llvm-svn: 266565
      3d555ac9
    • Duncan P. N. Exon Smith's avatar
      IR: Use an explicit map for debug info type uniquing · 5ab2be09
      Duncan P. N. Exon Smith authored
      Rather than relying on the structural equivalence of DICompositeType to
      merge type definitions, use an explicit map on the LLVMContext that
      LLParser and BitcodeReader consult when constructing new nodes.
      Each non-forward-declaration DICompositeType with a non-empty
      'identifier:' field is stored/loaded from the type map, and the first
      definiton will "win".
      
      This map is opt-in: clients that expect ODR types from different modules
      to be merged must call LLVMContext::ensureDITypeMap.
      
        - Clients that just happen to load more than one Module in the same
          LLVMContext won't magically merge types.
      
        - Clients (like LTO) that want to continue to merge types based on ODR
          identifiers should opt-in immediately.
      
      I have updated LTOCodeGenerator.cpp, the two "linking" spots in
      gold-plugin.cpp, and llvm-link (unless -disable-debug-info-type-map) to
      set this.
      
      With this in place, it will be straightforward to remove the DITypeRef
      concept (i.e., referencing types by their 'identifier:' string rather
      than pointing at them directly).
      
      llvm-svn: 266549
      5ab2be09
  8. Apr 16, 2016
    • Duncan P. N. Exon Smith's avatar
      ValueMapper: Separate mapping of distinct and uniqued nodes (again) · 694ab4e9
      Duncan P. N. Exon Smith authored
      Since the result of a mapped distinct node is known up front, it's more
      efficient to map them separately from uniqued nodes.  This commit pulls
      them out of the post-order traversal and stores them in a worklist to be
      remapped at the top-level.
      
      This is essentially reapplying r244181 ("ValueMapper: Rotate distinct
      node remapping algorithm") to the new iterative algorithm from r265456
      ("ValueMapper: Rewrite Mapper::mapMetadata without recursion").
      
      Now that the traversal logic only handles uniqued MDNodes, it's much
      simpler to inline it all into MDNodeMapper::createPOT (I've killed the
      MDNodeMapper::push and MDNodeMapper::tryToPop helpers and localized the
      traversal worklist).
      
      The resulting high-level algorithm for MDNodeMapper::map now looks like
      this:
      
        - Distinct nodes are immediately mapped and added to
          MDNodeMapper::DistinctWorklist using MDNodeMapper::mapDistinctNode.
      
        - Uniqued nodes are mapped via MDNodeMapper::mapTopLevelUniquedNode,
          which traverses the transitive uniqued subgraph of a node to
          calculate uniqued node mappings in bulk.
      
            - This is a simplified version of MDNodeMapper::map from before
              this commit (originally r265456) that doesn't traverse through
              any distinct nodes.
      
            - Distinct nodes are added to MDNodeMapper::DistinctWorklist via
              MDNodeMapper::mapDistinctNode.
      
            - This uses MDNodeMapper::createPOT to fill a
              MDNodeMapper::UniquedGraph (a post-order traversal and side
              table), UniquedGraph::propagateChanges to track which uniqued
              nodes need to change, and MDNodeMapper::mapNodesInPOT to create
              the uniqued nodes.
      
            - Placeholders for forward references are now only needed when
              there's a uniquing cycle (a cycle of uniqued nodes unbroken by
              distinct nodes).  This is the key functionality change that
              we're reintroducing (from r244181).  As of r265456, a temporary
              forward reference might be needed for any cycle that involved
              uniqued nodes.
      
        - After mapping the first node appropriately, MDNodeMapper::map works
          through MDNodeMapper::DistinctWorklist.  For each distinct node, its
          operands are remapped with MDNodeMapper::mapDistinctNode and
          MDNodeMapper::mapTopLevelUniquedNode until all nodes have been
          mapped.
      
      Sadly there's nothing observable I can test here; no real functionality
      change, just a compile-time speedup from reduced malloc traffic.
      
      llvm-svn: 266537
      694ab4e9
    • Duncan P. N. Exon Smith's avatar
      ValueMapper: Only put cyclic nodes into CyclicNodes, NFCI · 0cb5c344
      Duncan P. N. Exon Smith authored
      As a minor fixup to r266258, only track nodes that needed a placeholder
      in CyclicNodes in MDNodeMapper::mapUniquedNodes.  There should be no
      observable functionality change, just some local memory savings because
      CyclicNodes only needs to grow to accommodate nodes that are actually
      involved in cycles.  (This was the original intent of r266258, or else
      the vector would have been called "ChangedNodes".)
      
      llvm-svn: 266536
      0cb5c344
    • Simon Atanasyan's avatar
      ValueMapper: Fix unused var warning. NFC · e12bef7e
      Simon Atanasyan authored
      llvm-svn: 266529
      e12bef7e
    • Duncan P. N. Exon Smith's avatar
      ValueMapper: Stop memoizing ConstantAsMetadata · a77d0733
      Duncan P. N. Exon Smith authored
      Stop memoizing ConstantAsMetadata in ValueMapper::mapMetadata.  Now we
      have to recompute it, but these metadata aren't particularly common, and
      it restricts the lifetime of the Metadata map unnecessarily.
      
      (The motivation is that I have a patch which uses a single Metadata map
      for the lifetime of IRMover.  Mehdi profiled r266446 with the patch
      applied and we saw a pretty big speedup in lib/Linker.)
      
      llvm-svn: 266513
      a77d0733
    • Duncan P. N. Exon Smith's avatar
      Reapply "ValueMapper: Eliminate cross-file co-recursion, NFC" · 39423b02
      Duncan P. N. Exon Smith authored
      This reverts commit r266507, reapplying r266503 (and r266505
      "ValueMapper: Use API from r266503 in unit tests, NFC") completely
      unchanged.
      
      I reverted because of a bot failure here:
        http://lab.llvm.org:8011/builders/lld-x86_64-freebsd/builds/16810/
      
      However, looking more closely, the failure was from a host-compiler
      crash (clang 3.7.1) when building:
        lib/CodeGen/AsmPrinter/CMakeFiles/LLVMAsmPrinter.dir/DwarfAccelTable.cpp.o
      
      I didn't modify that file, or anything it includes, with that commit.
      
      The next build (which hadn't picked up my revert) got past it:
        http://lab.llvm.org:8011/builders/lld-x86_64-freebsd/builds/16811/
      
      I think this was just unfortunate timing.  I suppose the bot must be
      flakey.
      
      llvm-svn: 266510
      39423b02
    • Duncan P. N. Exon Smith's avatar
      Revert "ValueMapper: Eliminate cross-file co-recursion, NFC" · 6fe1ff26
      Duncan P. N. Exon Smith authored
      This reverts commit r266503, in case it's the root cause of this bot
      failure:
      
        http://lab.llvm.org:8011/builders/lld-x86_64-freebsd/builds/16810
      
      I'm also reverting r266505 -- "ValueMapper: Use API from r266503 in unit
      tests, NFC" -- since it's in the way.
      
      llvm-svn: 266507
      6fe1ff26
    • Duncan P. N. Exon Smith's avatar
      ValueMapper: Eliminate cross-file co-recursion, NFC · f0d73f95
      Duncan P. N. Exon Smith authored
      Eliminate co-recursion of Mapper::mapValue through
      ValueMaterializer::materializeInitFor, through a major redesign of the
      ValueMapper.cpp interface.
      
        - Expose a ValueMapper class that controls the entry points to the
          mapping algorithms.
        - Change IRLinker to use ValueMapper directly, rather than
          llvm::RemapInstruction, llvm::MapValue, etc.
        - Use (e.g.) ValueMapper::scheduleMapGlobalInit to add mapping work to
          a worklist in ValueMapper instead of recursing.
      
      There were two fairly major complications.
      
      Firstly, IRLinker::linkAppendingVarProto incorporates an on-the-fly IR
      ugprade that I had to split apart.  Long-term, this upgrade should be
      done in the bitcode reader (and we should only accept the "new" form),
      but for now I've just made it work and added a FIXME.  The hold-op is
      that we need to deprecate C API that relies on this.
      
      Secondly, IRLinker has special logic to correctly implement aliases with
      comdats, and uses two ValueToValueMapTy instances and two
      ValueMaterializers.  I supported this by allowing clients to register an
      alternate mapping context, whose MCID can be passed in when scheduling
      new work.
      
      While out of scope for this commit, it should now be straightforward to
      remove recursion from Mapper::mapValue.
      
      llvm-svn: 266503
      f0d73f95
    • Duncan P. N. Exon Smith's avatar
      ValueMapper: Hide Mapper::VM behind an accessor, NFC · db6861e7
      Duncan P. N. Exon Smith authored
      Change Mapper::VM to a pointer and add a `getVM()` accessor for it.
      While this has no functionality change, it minimizes the diff on an
      upcoming patch that allows switching between instances of
      ValueToValueMapTy on a single Mapper instance.
      
      llvm-svn: 266490
      db6861e7
  9. Apr 15, 2016
    • Adrian Prantl's avatar
      [PR27284] Reverse the ownership between DICompileUnit and DISubprogram. · 75819aed
      Adrian Prantl authored
      Currently each Function points to a DISubprogram and DISubprogram has a
      scope field. For member functions the scope is a DICompositeType. DIScopes
      point to the DICompileUnit to facilitate type uniquing.
      
      Distinct DISubprograms (with isDefinition: true) are not part of the type
      hierarchy and cannot be uniqued. This change removes the subprograms
      list from DICompileUnit and instead adds a pointer to the owning compile
      unit to distinct DISubprograms. This would make it easy for ThinLTO to
      strip unneeded DISubprograms and their transitively referenced debug info.
      
      Motivation
      ----------
      
      Materializing DISubprograms is currently the most expensive operation when
      doing a ThinLTO build of clang.
      
      We want the DISubprogram to be stored in a separate Bitcode block (or the
      same block as the function body) so we can avoid having to expensively
      deserialize all DISubprograms together with the global metadata. If a
      function has been inlined into another subprogram we need to store a
      reference the block containing the inlined subprogram.
      
      Attached to https://llvm.org/bugs/show_bug.cgi?id=27284 is a python script
      that updates LLVM IR testcases to the new format.
      
      http://reviews.llvm.org/D19034
      <rdar://problem/25256815>
      
      llvm-svn: 266446
      75819aed
    • Sanjay Patel's avatar
      [SimplifyCFG] propagate branch metadata when creating select (PR27344) · f11ab05b
      Sanjay Patel authored
      This is almost identical to:
      http://reviews.llvm.org/rL264527
      
      This doesn't solve PR27344; it just allows the profile weights to survive. 
      To solve the bug, we need to use the profile weights in the backend.
      
      llvm-svn: 266442
      f11ab05b
  10. Apr 14, 2016
  11. Apr 13, 2016
  12. Apr 12, 2016
Loading