Skip to content
  1. Jun 17, 2020
    • Nick Desaulniers's avatar
      BreakCriticalEdges for callbr indirect dests · 88c965ba
      Nick Desaulniers authored
      Summary:
      llvm::SplitEdge was failing an assertion that the BasicBlock only had
      one successor (for BasicBlocks terminated by CallBrInst, we typically
      have multiple successors).  It was surprising that the earlier call to
      SplitCriticalEdge did not handle the critical edge (there was an early
      return).  Removing that triggered another assertion relating to creating
      a BlockAddress for a BasicBlock that did not (yet) have a parent, which
      is a simple order of operations issue in llvm::SplitCriticalEdge (a
      freshly constructed BasicBlock must be inserted into a Function's basic
      block list to have a parent).
      
      Thanks to @nathanchance for the report.
      Fixes: https://github.com/ClangBuiltLinux/linux/issues/1018
      
      Reviewers: craig.topper, jyknight, void, fhahn, efriedma
      
      Reviewed By: efriedma
      
      Subscribers: eli.friedman, rnk, efriedma, fhahn, hiraditya, llvm-commits, nathanchance, srhines
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D81607
      88c965ba
  2. Apr 06, 2020
  3. Apr 02, 2020
  4. May 29, 2019
  5. May 26, 2019
  6. May 25, 2019
  7. Apr 17, 2019
  8. Nov 29, 2018
  9. Nov 14, 2018
  10. Nov 13, 2018
    • Florian Hahn's avatar
      [CSP, Cloning] Update DuplicateInstructionsInSplitBetween to use DomTreeUpdater. · 107d0a87
      Florian Hahn authored
      This patch updates DuplicateInstructionsInSplitBetween to update a DTU
      instead of applying updates to the DT directly.
      
      Given that there only are 2 users, also updated them in this patch to
      avoid churn.
      
      I slightly moved the code in CallSiteSplitting around to reduce the
      places where we have to pass in DTU. If necessary, I could split those
      changes in a separate patch.
      
      This fixes missing DT updates when dealing with musttail calls in
      CallSiteSplitting, by using DTU->deleteBB.
      
      Reviewers: junbuml, kuhar, NutshellySima, indutny, brzycki
      
      Reviewed By: NutshellySima
      
      llvm-svn: 346769
      107d0a87
  11. Nov 09, 2018
  12. Sep 11, 2018
    • Florian Hahn's avatar
      [CallSiteSplitting] Add debug location to created PHI nodes. · 5b7e21a6
      Florian Hahn authored
      There are 2 cases when we create PHI nodes:
       * For the result of the call that was duplicated in the split blocks.
         Those PHI nodes should have the debug location of the call.
      
       * For values produced before the call. Those instructions need to be
         duplicated in the split blocks and the PHI nodes should have the
         debug locations of those instructions.
      
      Fixes PR37962.
      
      Reviewers: junbuml, gbedwell, vsk
      
      Reviewed By: junbuml
      
      Tags: #debug-info
      
      Differential Revision: https://reviews.llvm.org/D51919
      
      llvm-svn: 341970
      5b7e21a6
  13. Apr 23, 2018
  14. Apr 05, 2018
    • Taewook Oh's avatar
      [CallSiteSplitting] Do not perform callsite splitting inside landing pad · e0db533f
      Taewook Oh authored
      Summary:
      If the callsite is inside landing pad, do not perform callsite splitting.
      
      Callsite splitting uses utility function llvm::DuplicateInstructionsInSplitBetween, which eventually calls llvm::SplitEdge. llvm::SplitEdge calls llvm::SplitCriticalEdge with an assumption that the function returns nullptr only when the target edge is not a critical edge (and further assumes that if the return value was not nullptr, the predecessor of the original target edge always has a single successor because critical edge splitting was successful). However, this assumtion is not true because SplitCriticalEdge returns nullptr if the destination block is a landing pad. This invalid assumption results assertion failure.
      
      Fundamental solution might be fixing llvm::SplitEdge to not to rely on the invalid assumption. However, it'll involve a lot of work because current API assumes that llvm::SplitEdge never fails. Instead, this patch makes callsite splitting to not to attempt splitting if the callsite is in a landing pad.
      
      Attached test case will crash with assertion failure without the fix.
      
      Reviewers: fhahn, junbuml, dberlin
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D45130
      
      llvm-svn: 329250
      e0db533f
  15. Mar 06, 2018
  16. Mar 03, 2018
    • Fedor Indutny's avatar
      [CallSiteSplitting] properly split musttail calls · f9e09c1d
      Fedor Indutny authored
      Summary:
      `musttail` calls can't be naively splitted. The split blocks must
      include not only the call instruction itself, but also (optional)
      `bitcast` and `return` instructions that follow it.
      
      Clone `bitcast` and `ret`, place them into the split blocks, and
      remove the tail block when done.
      
      Reviewers: junbuml, mcrosier, davidxl, davide, fhahn
      
      Reviewed By: fhahn
      
      Subscribers: JDevlieghere, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D43729
      
      llvm-svn: 326666
      f9e09c1d
  17. Feb 14, 2018
  18. Feb 13, 2018
  19. Jan 26, 2018
  20. Jan 16, 2018
  21. Dec 23, 2017
  22. Dec 13, 2017
    • Florian Hahn's avatar
      [CallSiteSplitting] Refactor creating callsites. · beda7d51
      Florian Hahn authored
      Summary:
      This change makes the call site creation more general if any of the
      arguments is predicated on a condition in the call site's predecessors.
      
      If we find a callsite, that potentially can be split, we collect the set
      of conditions for the call site's predecessors (currently only 2
      predecessors are allowed). To do that, we traverse each predecessor's
      predecessors as long as it only has single predecessors and record the
      condition, if it is relevant to the call site. For each condition, we
      also check if the condition is taken or not. In case it is not taken,
      we record the inverse predicate.
      
      We use the recorded conditions to create the new call sites and split
      the basic block.
      
      This has 2 benefits: (1) it is slightly easier to see what is going on
      (IMO) and (2) we can easily extend it to handle more complex control
      flow.
      
      Reviewers: davidxl, junbuml
      
      Reviewed By: junbuml
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D40728
      
      llvm-svn: 320547
      beda7d51
  23. Dec 12, 2017
  24. Nov 18, 2017
  25. Nov 03, 2017
    • Jun Bum Lim's avatar
      Recommit r317351 : Add CallSiteSplitting pass · 0c99007d
      Jun Bum Lim authored
      This recommit r317351 after fixing a buildbot failure.
      
      Original commit message:
      
          Summary:
          This change add a pass which tries to split a call-site to pass
          more constrained arguments if its argument is predicated in the control flow
          so that we can expose better context to the later passes (e.g, inliner, jump
          threading, or IPA-CP based function cloning, etc.).
          As of now we support two cases :
      
          1) If a call site is dominated by an OR condition and if any of its arguments
          are predicated on this OR condition, try to split the condition with more
          constrained arguments. For example, in the code below, we try to split the
          call site since we can predicate the argument (ptr) based on the OR condition.
      
          Split from :
                if (!ptr || c)
                  callee(ptr);
          to :
                if (!ptr)
                  callee(null ptr)  // set the known constant value
                else if (c)
                  callee(nonnull ptr)  // set non-null attribute in the argument
      
          2) We can also split a call-site based on constant incoming values of a PHI
          For example,
          from :
                BB0:
                 %c = icmp eq i32 %i1, %i2
                 br i1 %c, label %BB2, label %BB1
                BB1:
                 br label %BB2
                BB2:
                 %p = phi i32 [ 0, %BB0 ], [ 1, %BB1 ]
                 call void @bar(i32 %p)
          to
                BB0:
                 %c = icmp eq i32 %i1, %i2
                 br i1 %c, label %BB2-split0, label %BB1
                BB1:
                 br label %BB2-split1
                BB2-split0:
                 call void @bar(i32 0)
                 br label %BB2
                BB2-split1:
                 call void @bar(i32 1)
                 br label %BB2
                BB2:
                 %p = phi i32 [ 0, %BB2-split0 ], [ 1, %BB2-split1 ]
      
      llvm-svn: 317362
      0c99007d
    • Jun Bum Lim's avatar
      Revert "Add CallSiteSplitting pass" · 0eb1c2d6
      Jun Bum Lim authored
      Revert due to Buildbot failure.
      
      This reverts commit r317351.
      
      llvm-svn: 317353
      0eb1c2d6
    • Jun Bum Lim's avatar
      Add CallSiteSplitting pass · 2a589335
      Jun Bum Lim authored
      Summary:
      This change add a pass which tries to split a call-site to pass
      more constrained arguments if its argument is predicated in the control flow
      so that we can expose better context to the later passes (e.g, inliner, jump
      threading, or IPA-CP based function cloning, etc.).
      As of now we support two cases :
      
      1) If a call site is dominated by an OR condition and if any of its arguments
      are predicated on this OR condition, try to split the condition with more
      constrained arguments. For example, in the code below, we try to split the
      call site since we can predicate the argument (ptr) based on the OR condition.
      
      Split from :
            if (!ptr || c)
              callee(ptr);
      to :
            if (!ptr)
              callee(null ptr)  // set the known constant value
            else if (c)
              callee(nonnull ptr)  // set non-null attribute in the argument
      
      2) We can also split a call-site based on constant incoming values of a PHI
      For example,
      from :
            BB0:
             %c = icmp eq i32 %i1, %i2
             br i1 %c, label %BB2, label %BB1
            BB1:
             br label %BB2
            BB2:
             %p = phi i32 [ 0, %BB0 ], [ 1, %BB1 ]
             call void @bar(i32 %p)
      to
            BB0:
             %c = icmp eq i32 %i1, %i2
             br i1 %c, label %BB2-split0, label %BB1
            BB1:
             br label %BB2-split1
            BB2-split0:
             call void @bar(i32 0)
             br label %BB2
            BB2-split1:
             call void @bar(i32 1)
             br label %BB2
            BB2:
             %p = phi i32 [ 0, %BB2-split0 ], [ 1, %BB2-split1 ]
      
      Reviewers: davidxl, huntergr, chandlerc, mcrosier, eraman, davide
      
      Reviewed By: davidxl
      
      Subscribers: sdesmalen, ashutosh.nema, fhahn, mssimpso, aemerson, mgorny, mehdi_amini, kristof.beyls, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D39137
      
      llvm-svn: 317351
      2a589335
Loading