Skip to content
  1. Mar 12, 2019
    • Craig Topper's avatar
      [SanitizerCoverage] Avoid splitting critical edges when destination is a basic... · 03e93f51
      Craig Topper authored
      [SanitizerCoverage] Avoid splitting critical edges when destination is a basic block containing unreachable
      
      This patch adds a new option to SplitAllCriticalEdges and uses it to avoid splitting critical edges when the destination basic block ends with unreachable. Otherwise if we split the critical edge, sanitizer coverage will instrument the new block that gets inserted for the split. But since this block itself shouldn't be reachable this is pointless. These basic blocks will stick around and generate assembly, but they don't end in sane control flow and might get placed at the end of the function. This makes it look like one function has code that flows into the next function.
      
      This showed up while compiling the linux kernel with clang. The kernel has a tool called objtool that detected the code that appeared to flow from one function to the next. https://github.com/ClangBuiltLinux/linux/issues/351#issuecomment-461698884
      
      Differential Revision: https://reviews.llvm.org/D57982
      
      llvm-svn: 355947
      03e93f51
    • Fangrui Song's avatar
      [SimplifyLibCalls] Simplify optimizePuts · b1dfbebe
      Fangrui Song authored
      The code might intend to replace puts("") with putchar('\n') even if the
      return value is used. It failed because use_empty() was used to guard
      the whole block. While returning '\n' (putchar('\n')) is technically
      correct (puts is only required to return a nonnegative number on
      success), doing this looks weird and there is really little benefit to
      optimize puts whose return value is used. So don't do that.
      
      llvm-svn: 355921
      b1dfbebe
    • Fangrui Song's avatar
      f2609670
    • Sanjoy Das's avatar
      Reland "Relax constraints for reduction vectorization" · 3f5ce186
      Sanjoy Das authored
      Change from original commit: move test (that uses an X86 triple) into the X86
      subdirectory.
      
      Original description:
      Gating vectorizing reductions on *all* fastmath flags seems unnecessary;
      `reassoc` should be sufficient.
      
      Reviewers: tvvikram, mkuper, kristof.beyls, sdesmalen, Ayal
      
      Reviewed By: sdesmalen
      
      Subscribers: dcaballe, huntergr, jmolloy, mcrosier, jlebar, bixia, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D57728
      
      llvm-svn: 355889
      3f5ce186
  2. Mar 11, 2019
  3. Mar 08, 2019
    • Clement Courbet's avatar
      [SelectionDAG] Allow the user to specify a memeq function. · 8e16d733
      Clement Courbet authored
      Summary:
      Right now, when we encounter a string equality check,
      e.g. `if (memcmp(a, b, s) == 0)`, we try to expand to a comparison if `s` is a
      small compile-time constant, and fall back on calling `memcmp()` else.
      
      This is sub-optimal because memcmp has to compute much more than
      equality.
      
      This patch replaces `memcmp(a, b, s) == 0` by `bcmp(a, b, s) == 0` on platforms
      that support `bcmp`.
      
      `bcmp` can be made much more efficient than `memcmp` because equality
      compare is trivially parallel while lexicographic ordering has a chain
      dependency.
      
      Subscribers: fedor.sergeev, jyknight, ckennelly, gchatelet, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D56593
      
      llvm-svn: 355672
      8e16d733
  4. Mar 07, 2019
    • Nick Desaulniers's avatar
      [LoopRotate] fix crash encountered with callbr · 212c8ac2
      Nick Desaulniers authored
      Summary:
      While implementing inlining support for callbr
      (https://bugs.llvm.org/show_bug.cgi?id=40722), I hit a crash in Loop
      Rotation when trying to build the entire x86 Linux kernel
      (drivers/char/random.c). This is a small fix up to r353563.
      
      Test case is drivers/char/random.c (with callbr's inlined), then ran
      through creduce, then `opt -opt-bisect-limit=<limit>`, then bugpoint.
      
      Thanks to Craig Topper for immediately spotting the fix, and teaching me
      how to fish.
      
      Reviewers: craig.topper, jyknight
      
      Reviewed By: craig.topper
      
      Subscribers: hiraditya, llvm-commits, srhines
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D58929
      
      llvm-svn: 355564
      212c8ac2
  5. Feb 28, 2019
    • Chijun Sima's avatar
      Make MergeBlockIntoPredecessor conformant to the precondition of calling DTU.applyUpdates · 58618763
      Chijun Sima authored
      Summary:
      It is mentioned in the document of DTU that "It is illegal to submit any update that has already been submitted, i.e., you are supposed not to insert an existent edge or delete a nonexistent edge." It is dangerous to violet this rule because DomTree and PostDomTree occasionally crash on this scenario.
      
      This patch fixes `MergeBlockIntoPredecessor`, making it conformant to this precondition.
      
      Reviewers: kuhar, brzycki, chandlerc
      
      Reviewed By: brzycki
      
      Subscribers: hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D58444
      
      llvm-svn: 355105
      58618763
  6. Feb 22, 2019
    • Matt Arsenault's avatar
      BreakCriticalEdges: Update PostDominatorTree · 65b4ab99
      Matt Arsenault authored
      llvm-svn: 354673
      65b4ab99
    • Roman Tereshin's avatar
      [LowerSwitch][AMDGPU] Do not handle impossible values · 99a6672b
      Roman Tereshin authored
      This patch adds LazyValueInfo to LowerSwitch to compute the range of the
      value being switched over and reduce the size of the tree LowerSwitch
      builds to lower a switch.
      
      Reviewed By: arsenm
      
      Differential Revision: https://reviews.llvm.org/D58096
      
      llvm-svn: 354670
      99a6672b
    • Chijun Sima's avatar
      [DTU] Refine the interface and logic of applyUpdates · 70e97163
      Chijun Sima authored
      Summary:
      This patch separates two semantics of `applyUpdates`:
      1. User provides an accurate CFG diff and the dominator tree is updated according to the difference of `the number of edge insertions` and `the number of edge deletions` to infer the status of an edge before and after the update.
      2. User provides a sequence of hints. Updates mentioned in this sequence might never happened and even duplicated.
      
      Logic changes:
      
      Previously, removing invalid updates is considered a side-effect of deduplication and is not guaranteed to be reliable. To handle the second semantic, `applyUpdates` does validity checking before deduplication, which can cause updates that have already been applied to be submitted again. Then, different calls to `applyUpdates` might cause unintended consequences, for example,
      ```
      DTU(Lazy) and Edge A->B exists.
      1. DTU.applyUpdates({{Delete, A, B}, {Insert, A, B}}) // User expects these 2 updates result in a no-op, but {Insert, A, B} is queued
      2. Remove A->B
      3. DTU.applyUpdates({{Delete, A, B}}) // DTU cancels this update with {Insert, A, B} mentioned above together (Unintended)
      ```
      But by restricting the precondition that updates of an edge need to be strictly ordered as how CFG changes were made, we can infer the initial status of this edge to resolve this issue.
      
      Interface changes:
      The second semantic of `applyUpdates`  is separated to `applyUpdatesPermissive`.
      These changes enable DTU(Lazy) to use the first semantic if needed, which is quite useful in `transforms/utils`.
      
      Reviewers: kuhar, brzycki, dmgreen, grosser
      
      Reviewed By: brzycki
      
      Subscribers: hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D58170
      
      llvm-svn: 354669
      70e97163
    • Chijun Sima's avatar
      [DTU] Deprecate insertEdge*/deleteEdge* · f131d611
      Chijun Sima authored
      Summary: This patch converts all existing `insertEdge*/deleteEdge*` to `applyUpdates` and marks `insertEdge*/deleteEdge*` as deprecated.
      
      Reviewers: kuhar, brzycki
      
      Reviewed By: kuhar, brzycki
      
      Subscribers: hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D58443
      
      llvm-svn: 354652
      f131d611
  7. Feb 21, 2019
  8. Feb 20, 2019
    • Philip Reames's avatar
      [GVN] Small tweaks to comments, style, and missed vector handling · 79d5e16f
      Philip Reames authored
      Noticed these while doing a final sweep of the code to make sure I hadn't missed anything in my last couple of patches.  The (minor) missed optimization was noticed because of the stylistic fix to avoid an overly specific cast.
      
      llvm-svn: 354412
      79d5e16f
    • Philip Reames's avatar
      [GVN] Fix last crasher w/non-integral pointers · a259dc32
      Philip Reames authored
      Same case as for memset and memcpy, but this time for clobbering stores and loads.  We still can't allow coercion to or from non-integrals, regardless of the transform.
      
      Now that I'm done the whole little sequence, it seems apparent that we'd entirely missed reasoning about clobbers in the original GVN support for non-integral pointers.
      
      My appologies, I thought we'd upstreamed all of this, but it turns out we were still carrying a downstream hack which hid all of these issues.  My chanks to Cherry Zhang for helping debug.
      
      llvm-svn: 354407
      a259dc32
    • Philip Reames's avatar
      [GVN] Fix a crash bug w/non-integral pointers and memtransfers · 952d234d
      Philip Reames authored
      Problem is very similiar to the one fixed for memsets in r354399, we try to coerce a value to non-integral type, and then crash while try to do so.  Since we shouldn't be doing such coercions to start with, easy fix.  From inspection, I see two other cases which look to be similiar and will follow up with most test cases and fixes if confirmed.
      
      llvm-svn: 354403
      952d234d
    • Philip Reames's avatar
      [GVN] Fix a non-integral pointer bug w/vector types · 322eb766
      Philip Reames authored
      GVN generally doesn't forward structs or array types, but it *will* forward vector types to non-vectors and vice versa.  As demonstrated in tests, we need to inhibit the same set of transforms for vector of non-integral pointers as for non-integral pointers themselves.
      
      llvm-svn: 354401
      322eb766
    • Philip Reames's avatar
      [GVN] Fix a crash bug around non-integral pointers · 92756a80
      Philip Reames authored
      If we encountered a location where we tried to forward the value of a memset to a load of a non-integral pointer, we crashed.  Such a forward is not legal in general, but we can forward null pointers.  Test for both cases are included.
      
      llvm-svn: 354399
      92756a80
  9. Feb 15, 2019
  10. Feb 14, 2019
    • Florian Hahn's avatar
      [LoopUnrollPeel] Add case where we should forget the peeled loop from SCEV. · 6ab83b7d
      Florian Hahn authored
      The test case requires the peeled loop to be forgotten after peeling,
      even though it does not have a parent. When called via the unroller,
      SE->forgetTopmostLoop is also called, so the test case would also pass
      without any SCEV invalidation, but peelLoop is exposed as utility
      function. Also, in the test case, simplifyLoop will make changes,
      removing the loop from SCEV, but it is better to not rely on this
      behavior.
      
      Reviewers: sanjoy, mkazantsev
      
      Reviewed By: mkazantsev
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D58192
      
      llvm-svn: 354031
      6ab83b7d
  11. Feb 13, 2019
    • Vedant Kumar's avatar
      [CodeExtractor] Only lift lifetime markers present in the extraction region · 4b0cc9a7
      Vedant Kumar authored
      When CodeExtractor finds liftime markers referencing inputs to the
      extraction region, it lifts these markers out of the region and inserts
      them around the call to the extracted function (see r350420, PR39671).
      
      However, it should *only* lift lifetime markers that are actually
      present in the extraction region. I.e., if a start marker is present in
      the extraction region but a corresponding end marker isn't (or vice
      versa), only the start marker (or end marker, resp.) should be lifted.
      
      Differential Revision: https://reviews.llvm.org/D57834
      
      llvm-svn: 353973
      4b0cc9a7
  12. Feb 12, 2019
    • Jeremy Morse's avatar
      [DebugInfo] Don't salvage load operations (PR40628). · b33a5c73
      Jeremy Morse authored
      Salvaging a redundant load instruction into a debug expression hides a
      memory read from optimisation passes. Passes that alter memory behaviour
      (such as LICM promoting memory to a register) aren't aware of these debug
      memory reads and leave them unaltered, making the debug variable location
      point somewhere unsafe.
      
      Teaching passes to know about these debug memory reads would be challenging
      and probably incomplete. Finding dbg.value instructions that need to be fixed
      would likely be computationally expensive too, as more analysis would be
      required. It's better to not generate debug-memory-reads instead, alas.
      
      Changed tests:
       * DeadStoreElim: test for salvaging of intermediate operations contributing
         to the dead store, instead of salvaging of the redundant load,
       * GVN: remove debuginfo behaviour checks completely, this behaviour is still
         covered by other tests,
       * InstCombine: don't test for salvaged loads, we're removing that behaviour.
      
      Differential Revision: https://reviews.llvm.org/D57962
      
      llvm-svn: 353824
      b33a5c73
    • Max Kazantsev's avatar
      [NFC] Rename DontDeleteUselessPHIs --> KeepOneInputPHIs · 20b91899
      Max Kazantsev authored
      llvm-svn: 353801
      20b91899
    • Max Kazantsev's avatar
      [NFC] Add parameter for keeping one-input Phis in DeleteDeadBlock(s) · 0686d1ae
      Max Kazantsev authored
      llvm-svn: 353799
      0686d1ae
  13. Feb 11, 2019
  14. Feb 10, 2019
  15. Feb 08, 2019
    • Craig Topper's avatar
      Implementation of asm-goto support in LLVM · 784929d0
      Craig Topper authored
      This patch accompanies the RFC posted here:
      http://lists.llvm.org/pipermail/llvm-dev/2018-October/127239.html
      
      This patch adds a new CallBr IR instruction to support asm-goto
      inline assembly like gcc as used by the linux kernel. This
      instruction is both a call instruction and a terminator
      instruction with multiple successors. Only inline assembly
      usage is supported today.
      
      This also adds a new INLINEASM_BR opcode to SelectionDAG and
      MachineIR to represent an INLINEASM block that is also
      considered a terminator instruction.
      
      There will likely be more bug fixes and optimizations to follow
      this, but we felt it had reached a point where we would like to
      switch to an incremental development model.
      
      Patch by Craig Topper, Alexander Ivchenko, Mikhail Dvoretckii
      
      Differential Revision: https://reviews.llvm.org/D53765
      
      llvm-svn: 353563
      784929d0
    • Vedant Kumar's avatar
      [CodeExtractor] Restore outputs after creating exit stubs · 0e5dd512
      Vedant Kumar authored
      When CodeExtractor saves the result of InvokeInst at the first insertion
      point of the 'normal destination' basic block, this block can be omitted
      in the outlined region, so store is placed outside of the function. The
      suggested solution is to process saving outputs after creating exit
      stubs for new function, and stores will be placed in that blocks before
      return in this case.
      
      Patch by Sergei Kachkov!
      
      Fixes llvm.org/PR40455.
      
      Differential Revision: https://reviews.llvm.org/D57919
      
      llvm-svn: 353562
      0e5dd512
    • Carlos Alberto Enciso's avatar
      [DWARF] LLVM ERROR: Broken function found, while removing Debug Intrinsics. · 08dc50f2
      Carlos Alberto Enciso authored
      Check that when SimplifyCFG is flattening a 'br', all their debug intrinsic instructions are removed, including any dbg.label referencing a label associated with the basic blocks being removed.
      
      Differential Revision: https://reviews.llvm.org/D57444
      
      llvm-svn: 353511
      08dc50f2
    • Sergey Dmitriev's avatar
      [CodeExtractor] Update function's assumption cache after extracting blocks from it · 807960e6
      Sergey Dmitriev authored
      Summary: Assumption cache's self-updating mechanism does not correctly handle the case when blocks are extracted from the function by the CodeExtractor. As a result function's assumption cache may have stale references to the llvm.assume calls that were moved to the outlined function. This patch fixes this problem by removing extracted llvm.assume calls from the function’s assumption cache.
      
      Reviewers: hfinkel, vsk, fhahn, davidxl, sanjoy
      
      Reviewed By: hfinkel, vsk
      
      Subscribers: llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D57215
      
      llvm-svn: 353500
      807960e6
  16. Feb 06, 2019
Loading