Skip to content
  1. Mar 28, 2018
  2. Mar 27, 2018
    • Max Kazantsev's avatar
      [LoopUnroll][NFC] Remove redundant canPeel check · b1ad66ff
      Max Kazantsev authored
      We check `canPeel` twice: when evaluating the number of iterations to be peeled
      and within the method `peelLoop` that performs peeling. This method is only
      executed if the calculated peel count is positive. Thus, the check in `peelLoop` can
      never fail. This patch replaces this check with an assert.
      
      Differential Revision: https://reviews.llvm.org/D44919
      Reviewed By: fhahn
      
      llvm-svn: 328615
      b1ad66ff
  3. Mar 26, 2018
    • Max Kazantsev's avatar
      [LoopUnroll] Fix dangling pointers in SCEV · a5574931
      Max Kazantsev authored
      Current logic of loop SCEV invalidation in Loop Unroller implicitly relies on
      fact that exit count of outer loops cannot rely on exiting blocks of
      inner loops, which is true in current implementation of backedge taken count
      calculation but is wrong in general. As result, when we only forget the loop that
      we have just unrolled, we may still have cached data for its outer loops (in particular,
      exit counts) which keeps references on blocks of inner loop that could have been
      changed or even deleted.
      
      The attached test demonstrates a situaton when after unrolling of innermost loop
      the outermost loop contains a dangling pointer on non-existant block. The problem
      shows up when we apply patch https://reviews.llvm.org/D44677 that makes SCEV
      smarter about exit count calculation. I am not sure if the bug exists without this patch,
      it appears that now it is accidentally correct just because in practice exact backedge
      taken count for outer loops with complex control flow inside is never calculated.
      But when SCEV learns to do so, this problem shows up.
      
      This patch replaces existing logic of SCEV loop invalidation with a correct one, which
      happens to be invalidation of outermost loop (which also leads to invalidation of all
      loops inside of it). It is the only way to ensure that no outer loop keeps dangling pointers
      on removed blocks, or just outdated information that has changed after unrolling.
      
      Differential Revision: https://reviews.llvm.org/D44818
      Reviewed By: samparker
      
      llvm-svn: 328483
      a5574931
  4. Mar 24, 2018
  5. Mar 23, 2018
  6. Mar 22, 2018
  7. Mar 21, 2018
    • David Blaikie's avatar
      Fix a couple of layering violations in Transforms · 2be39228
      David Blaikie authored
      Remove #include of Transforms/Scalar.h from Transform/Utils to fix layering.
      
      Transforms depends on Transforms/Utils, not the other way around. So
      remove the header and the "createStripGCRelocatesPass" function
      declaration (& definition) that is unused and motivated this dependency.
      
      Move Transforms/Utils/Local.h into Analysis because it's used by
      Analysis/MemoryBuiltins.cpp.
      
      llvm-svn: 328165
      2be39228
  8. Mar 20, 2018
  9. Mar 17, 2018
    • Oren Ben Simhon's avatar
      [X86] Added support for nocf_check attribute for indirect Branch Tracking · fdd72fd5
      Oren Ben Simhon authored
      X86 Supports Indirect Branch Tracking (IBT) as part of Control-Flow Enforcement Technology (CET).
      IBT instruments ENDBR instructions used to specify valid targets of indirect call / jmp.
      The `nocf_check` attribute has two roles in the context of X86 IBT technology:
      	1. Appertains to a function - do not add ENDBR instruction at the beginning of the function.
      	2. Appertains to a function pointer - do not track the target function of this pointer by adding nocf_check prefix to the indirect-call instruction.
      
      This patch implements `nocf_check` context for Indirect Branch Tracking.
      It also auto generates `nocf_check` prefixes before indirect branchs to jump tables that are guarded by range checks.
      
      Differential Revision: https://reviews.llvm.org/D41879
      
      llvm-svn: 327767
      fdd72fd5
  10. Mar 16, 2018
  11. Mar 15, 2018
    • Florian Hahn's avatar
      [LoopUnroll] Peel off iterations if it makes conditions true/false. · fc97b617
      Florian Hahn authored
      If the loop body contains conditions of the form IndVar < #constant, we
      can remove the checks by peeling off #constant iterations.
      
      This improves codegen for PR34364.
      
      Reviewers: mkuper, mkazantsev, efriedma
      
      Reviewed By: mkazantsev
      
      Differential Revision: https://reviews.llvm.org/D43876
      
      llvm-svn: 327671
      fc97b617
    • Philip Reames's avatar
      [LICM] Ignore exits provably not taken on first iteration when computing must execute · a21d5f1e
      Philip Reames authored
      It is common to have conditional exits within a loop which are known not to be taken on some iterations, but not necessarily all. This patches extends our reasoning around guaranteed to execute (used when establishing whether it's safe to dereference a location from the preheader) to handle the case where an exit is known not to be taken on the first iteration and the instruction of interest *is* known to be taken on the first iteration.
      
      This case comes up in two major ways:
      * If we have a range check which we've been unable to eliminate, we frequently know that it doesn't fail on the first iteration.
      * Pass ordering. We may have a check which will be eliminated through some sequence of other passes, but depending on the exact pass sequence we might never actually do so or we might miss other optimizations from passes run before the check is finally eliminated.
      
      The initial version (here) is implemented via InstSimplify. At the moment, it catches a few cases, but misses a lot too. I added test cases for missing cases in InstSimplify which I'll follow up on separately. Longer term, we should probably wire SCEV through to here to get much smarter loop aware simplification of the first iteration predicate.
      
      Differential Revision: https://reviews.llvm.org/D44287
      
      llvm-svn: 327664
      a21d5f1e
    • Ulrich Weigand's avatar
      [Debug] Retain both copies of debug intrinsics in HoistThenElseCodeToIf · f4ceef8d
      Ulrich Weigand authored
      When hoisting common code from the "then" and "else" branches of a condition
      to before the "if", the HoistThenElseCodeToIf routine will attempt to merge
      the debug location associated with the two original copies of the hoisted
      instruction.
      
      This is a problem in the special case where the hoisted instruction is a
      debug info intrinsic, since for those the debug location is considered
      part of the intrinsic and attempting to modify it may resut in invalid
      IR.  This is the underlying cause of PR36410.
      
      This patch fixes the problem by handling debug info intrinsics specially:
      instead of hoisting one copy and merging the two locations, the code now
      simply hoists both copies, each with its original location intact.  Note
      that this is still only done in the case where both original copies are
      otherwise (i.e. apart from location metadata) identical.
      
      Reviewed By: aprantl
      
      Differential Revision: https://reviews.llvm.org/D44312
      
      llvm-svn: 327622
      f4ceef8d
  12. Mar 13, 2018
  13. Mar 09, 2018
    • Ulrich Weigand's avatar
      Revert "[Debug] Retain both sets of debug intrinsics in HoistThenElseCodeToIf" · 019dd231
      Ulrich Weigand authored
      This reverts commit r327175 as problems in debug info generation were shown.
      
      llvm-svn: 327176
      019dd231
    • Ulrich Weigand's avatar
      [Debug] Retain both sets of debug intrinsics in HoistThenElseCodeToIf · fa4e63c0
      Ulrich Weigand authored
      When hoisting common code from the "then" and "else" branches of a condition
      to before the "if", there is no need to require that debug intrinsics match
      before moving them (and merging them).  Instead, we can simply always keep
      all debug intrinsics from both sides of the "if".
      
      This fixes PR36410, which describes a problem where as a result of the attempt
      to merge debug locations for two debug intrinsics we end up with an invalid
      intrinsic, where the scope indicated in the !dbg location no longer matches
      the scope of the variable tracked by the intrinsic.
      
      In addition, this has the benefit that we no longer throw away information
      that is actually still valid, helping to generate better debug data.
      
      Reviewed By: vsk
      
      Differential Revision: https://reviews.llvm.org/D44312
      
      llvm-svn: 327175
      fa4e63c0
    • Adrian Prantl's avatar
      LowerDbgDeclare: ignore dbg.declares for allocas with volatile access · 5b477be7
      Adrian Prantl authored
      There is no point in lowering a dbg.declare describing an alloca that
      has volatile loads or stores as users, since the alloca cannot be
      elided. Lowering the dbg.declare will result in larger debug info that
      may also have worse coverage than just describing the alloca.
      
      rdar://problem/34496278
      
      llvm-svn: 327092
      5b477be7
  14. Mar 08, 2018
  15. Mar 06, 2018
  16. Mar 02, 2018
    • Vedant Kumar's avatar
      [Utils] Salvage debug info in block simplification · f69baf64
      Vedant Kumar authored
      In stage2 -O3 builds of llc, this results in small but measurable
      increases in the number of variables with locations, and in the number
      of unique source variables overall.
      
      (According to llvm-dwarfdump --statistics, there are 123 additional
      variables with locations, which is just a 0.006% improvement).
      
      The size of the .debug_loc section of the llc dsym increases by 0.004%.
      
      llvm-svn: 326629
      f69baf64
    • Vedant Kumar's avatar
      [Utils] Salvage debug info in recursive inst deletion · 334fa574
      Vedant Kumar authored
      In stage2 -O3 builds of llc, this results in a 0.3% increase in the
      number of variables with locations, and a 0.2% increase in the number of
      unique source variables overall.
      
      The size of the .debug_loc section of the llc dsym increases by 0.5%.
      
      llvm-svn: 326621
      334fa574
  17. Mar 01, 2018
  18. Feb 28, 2018
  19. Feb 23, 2018
    • Matt Davis's avatar
      [Debug] Add dbg.value intrinsics for PHIs created during LCSSA. · 523c656e
      Matt Davis authored
      Summary:
      This patch is an enhancement to propagate dbg.value information when Phis are created on behalf of LCSSA.
      I noticed a case where a value carried across a loop was reported as <optimized out>.
      
      Specifically this case:
      ```
      int bar(int x, int y) {
        return x + y;
      }
      
      int foo(int size) {
        int val = 0;
        for (int i = 0; i < size; ++i) {
          val = bar(val, i);  // Both val and i are correct
        }
        return val; // <optimized out>
      }
      ```
      
      In the above case, after all of the interesting computation completes our value
      is reported as "optimized out." This change will add a dbg.value to correct this.
      
      This patch also moves the dbg.value insertion routine from LoopRotation.cpp 
      into Local.cpp, so that we can share it in both places (LoopRotation and LCSSA).
      
      Reviewers: mzolotukhin, aprantl, vsk, davide
      
      Reviewed By: aprantl, vsk
      
      Subscribers: dberlin, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D42551
      
      llvm-svn: 325926
      523c656e
  20. Feb 22, 2018
    • Vedant Kumar's avatar
      [Utils] Avoid a hash table lookup in salvageDI, NFC · 1ceabcf0
      Vedant Kumar authored
      According to the current coverage report salvageDebugInfo() is called
      5.12 million times during testing and almost always returns early.
      
      The early return depends on LocalAsMetadata::getIfExists returning null,
      which involves a DenseMap lookup in an LLVMContextImpl. We can probably
      speed this up by simply checking the IsUsedByMD bit in Value.
      
      llvm-svn: 325738
      1ceabcf0
  21. Feb 19, 2018
    • Brian Gesiak's avatar
      Revert "[mem2reg] Use range loops (NFCI)" · d1eabb18
      Brian Gesiak authored
      This reverts commit r325532.
      
      llvm-svn: 325539
      d1eabb18
    • Brian Gesiak's avatar
      [mem2reg] Use range loops (NFCI) · 49a9d1a4
      Brian Gesiak authored
      Summary:
      Several for loops in PromoteMemoryToRegister.cpp leave their increment
      expression empty, instead incrementing the iterator within the for loop
      body. I believe this is because these loops were previously implemented
      as while loops; see https://reviews.llvm.org/rL188327.
      
      Incrementing the iterator within the body of the for loop instead of
      in its increment expression makes it seem like the iterator will be
      modified or conditionally incremented within the loop, but that is not
      the case in these loops.
      
      Instead, use range loops.
      
      Test Plan: `check-llvm`
      
      Reviewers: davide, bkramer
      
      Reviewed By: davide, bkramer
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D43473
      
      llvm-svn: 325532
      49a9d1a4
  22. Feb 15, 2018
  23. Feb 14, 2018
    • Rafael Espindola's avatar
      Pass a module reference to CloneModule. · 71867532
      Rafael Espindola authored
      It can never be null and most callers were already using references or
      std::unique_ptr.
      
      llvm-svn: 325160
      71867532
    • David Green's avatar
      Move llvm::computeLoopSafetyInfo from LICM.cpp to LoopUtils.cpp. NFC · 0d5f9651
      David Green authored
      Move computeLoopSafetyInfo, defined in Transforms/Utils/LoopUtils.h,
      into the corresponding LoopUtils.cpp, as opposed to LICM where it resides
      at the moment. This will allow other functions from Transforms/Utils
      to reference it.
      
      llvm-svn: 325151
      0d5f9651
    • Petar Jovanovic's avatar
      [Utils] Salvage the debug info of DCE'ed 'and' instructions · 1768957c
      Petar Jovanovic authored
      Preserve debug info from a dead 'and' instruction with a constant.
      
      Patch by Djordje Todorovic.
      
      Differential Revision: https://reviews.llvm.org/D43163
      
      llvm-svn: 325119
      1768957c
    • Elena Demikhovsky's avatar
      Adding a width of the GEP index to the Data Layout. · 945b7e5a
      Elena Demikhovsky authored
      Making a width of GEP Index, which is used for address calculation, to be one of the pointer properties in the Data Layout.
      p[address space]:size:memory_size:alignment:pref_alignment:index_size_in_bits.
      The index size parameter is optional, if not specified, it is equal to the pointer size.
      
      Till now, the InstCombiner normalized GEPs and extended the Index operand to the pointer width.
      It works fine if you can convert pointer to integer for address calculation and all registered targets do this.
      But some ISAs have very restricted instruction set for the pointer calculation. During discussions were desided to retrieve information for GEP index from the Data Layout.
      http://lists.llvm.org/pipermail/llvm-dev/2018-January/120416.html
      
      I added an interface to the Data Layout and I changed the InstCombiner and some other passes to take the Index width into account.
      This change does not affect any in-tree target. I added tests to cover data layouts with explicitly specified index size.
      
      Differential Revision: https://reviews.llvm.org/D42123
      
      llvm-svn: 325102
      945b7e5a
  24. Feb 13, 2018
Loading