Skip to content
  1. Jan 22, 2021
  2. Jan 20, 2021
  3. Jan 16, 2021
  4. Dec 17, 2020
  5. Dec 12, 2020
  6. Dec 03, 2020
  7. Nov 30, 2020
    • Mircea Trofin's avatar
      [llvm][inliner] Reuse the inliner pass to implement 'always inliner' · 5fe10263
      Mircea Trofin authored
      Enable performing mandatory inlinings upfront, by reusing the same logic
      as the full inliner, instead of the AlwaysInliner. This has the
      following benefits:
      - reduce code duplication - one inliner codebase
      - open the opportunity to help the full inliner by performing additional
      function passes after the mandatory inlinings, but before th full
      inliner. Performing the mandatory inlinings first simplifies the problem
      the full inliner needs to solve: less call sites, more contextualization, and,
      depending on the additional function optimization passes run between the
      2 inliners, higher accuracy of cost models / decision policies.
      
      Note that this patch does not yet enable much in terms of post-always
      inline function optimization.
      
      Differential Revision: https://reviews.llvm.org/D91567
      5fe10263
  8. Nov 13, 2020
  9. Nov 11, 2020
    • Arthur Eubanks's avatar
      [CGSCC][Inliner] Handle new non-trivial edges in updateCGAndAnalysisManagerForPass · d9cbceb0
      Arthur Eubanks authored
      Previously the inliner did a bit of a hack by adding ref edges for all
      new edges introduced by performing an inline before calling
      updateCGAndAnalysisManagerForPass(). This was because
      updateCGAndAnalysisManagerForPass() didn't handle new non-trivial call
      edges.
      
      This adds handling of non-trivial call edges to
      updateCGAndAnalysisManagerForPass().  The inliner called
      updateCGAndAnalysisManagerForFunctionPass() since it was handling adding
      newly introduced edges (so updateCGAndAnalysisManagerForPass() would
      only have to handle promotion), but now it needs to call
      updateCGAndAnalysisManagerForCGSCCPass() since
      updateCGAndAnalysisManagerForPass() is now handling the new call edges
      and function passes cannot add new edges.
      
      We follow the previous path of adding trivial ref edges then letting promotion
      handle changing the ref edges to call edges and the CGSCC updates. So
      this still does not allow adding call edges that result in an addition
      of a non-trivial ref edge.
      
      This is in preparation for better detecting devirtualization. Previously
      since the inliner itself would add ref edges,
      updateCGAndAnalysisManagerForPass() would think that promotion and thus
      devirtualization had happened after any sort of inlining.
      
      Reviewed By: asbirlea
      
      Differential Revision: https://reviews.llvm.org/D91046
      d9cbceb0
  10. Oct 24, 2020
  11. Oct 23, 2020
    • Arthur Eubanks's avatar
      [Inliner] Run always-inliner in inliner-wrapper · 0291e2c9
      Arthur Eubanks authored
      An alwaysinline function may not get inlined in inliner-wrapper due to
      the inlining order.
      
      Previously for the following, the inliner would first inline @a() into @b(),
      
      ```
      define void @a() {
      entry:
        call void @b()
        ret void
      }
      
      define void @b() alwaysinline {
      entry:
        br label %for.cond
      
      for.cond:
        call void @a()
        br label %for.cond
      }
      ```
      
      making @b() recursive and unable to be inlined into @a(), ending at
      
      ```
      define void @a() {
      entry:
        call void @b()
        ret void
      }
      
      define void @b() alwaysinline {
      entry:
        br label %for.cond
      
      for.cond:
        call void @b()
        br label %for.cond
      }
      ```
      
      Running always-inliner first makes sure that we respect alwaysinline in more cases.
      
      Fixes https://bugs.llvm.org/show_bug.cgi?id=46945.
      
      Reviewed By: davidxl, rnk
      
      Differential Revision: https://reviews.llvm.org/D86988
      0291e2c9
  12. Jul 07, 2020
  13. Jul 02, 2020
  14. Jun 01, 2020
    • Mircea Trofin's avatar
      [llvm][NFC] Cache FAM in InlineAdvisor · 999ea25a
      Mircea Trofin authored
      Summary:
      This simplifies the interface by storing the function analysis manager
      with the InlineAdvisor, and, thus, not requiring it be passed each time
      we inquire for an advice.
      
      Reviewers: davidxl, asbirlea
      
      Subscribers: eraman, hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D80405
      999ea25a
  15. May 18, 2020
  16. May 16, 2020
  17. May 15, 2020
  18. May 13, 2020
  19. May 11, 2020
  20. May 05, 2020
    • Kazu Hirata's avatar
      [Inlining] Teach shouldBeDeferred to take the total cost into account · e8984fe6
      Kazu Hirata authored
      Summary:
      This patch teaches shouldBeDeferred to take into account the total
      cost of inlining.
      
      Suppose we have a call hierarchy {A1,A2,A3,...}->B->C.  (Each of A1,
      A2, A3, ... calls B, which in turn calls C.)
      
      Without this patch, shouldBeDeferred essentially returns true if
      
        TotalSecondaryCost < IC.getCost()
      
      where TotalSecondaryCost is the total cost of inlining B into As.
      This means that if B is a small wraper function, for example, it would
      get inlined into all of As.  In turn, C gets inlined into all of As.
      In other words, shouldBeDeferred ignores the cost of inlining C into
      each of As.
      
      This patch adds an option, inline-deferral-scale, to replace the
      expression above with:
      
        TotalCost < Allowance
      
      where
      
      - TotalCost is TotalSecondaryCost + IC.getCost() * # of As, and
      - Allowance is IC.getCost() * Scale
      
      For now, the new option defaults to -1, disabling the new scheme.
      
      Reviewers: davidxl
      
      Subscribers: eraman, hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D79138
      e8984fe6
  21. May 03, 2020
  22. May 02, 2020
    • Mircea Trofin's avatar
      [llvm][NFC] Rename variable as per https://reviews.llvm.org/D79215 · 3dbc612c
      Mircea Trofin authored
      Operator error - performed the rename and didn't save.
      3dbc612c
    • Mircea Trofin's avatar
      [llvm][NFC] Inliner: simplify inlining decision logic · e1c4a7cb
      Mircea Trofin authored
      Summary:
      shouldInline makes a decision based on the InlineCost of a call site, as
      well as an evaluation on whether the site should be deferred. This means
      it's possible for the decision to be not to inline, even for an
      InlineCost that would otherwise allow it.
      
      Both uses of shouldInline performed the exact same logic after calling
      it. In addition, the decision on whether to inline or not was
      communicated through two values of the Option<InlineCost> return value:
      None, or an InlineCost evaluating to false.
      
      Simplified by:
      - encapsulating the decision in the return object. The bool it evaluates
      to communicates unambiguously the decision. The InlineCost is also
      available.
      - encapsulated the common post-shouldInline code into shouldInline.
      
      Reviewers: davidxl, echristo, eraman
      
      Subscribers: hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D79215
      e1c4a7cb
  23. Apr 30, 2020
  24. Apr 29, 2020
  25. Apr 14, 2020
  26. Apr 12, 2020
    • Mircea Trofin's avatar
      [llvm][NFC] Refactor uses of CallSite to CallBase - call promotion · d2f1cd5d
      Mircea Trofin authored
      Summary:
      Updated CallPromotionUtils and impacted sites. Parameters that are
      expected to be non-null, and return values that are guranteed non-null,
      were replaced with CallBase references rather than pointers.
      
      Left FIXME in places where more changes are facilitated by CallBase, but
      aren't CallSites: Instruction* parameters or return values, for example,
      where the contract that they are actually CallBase values.
      
      Reviewers: davidxl, dblaikie, wmi
      
      Reviewed By: dblaikie
      
      Subscribers: arsenm, jvesely, nhaehnle, eraman, hiraditya, kerbowa, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D77930
      d2f1cd5d
  27. Apr 11, 2020
    • Mircea Trofin's avatar
      [llvm][NFC] Inliner.cpp: ensure InlineHistory ID is always initialized; · da9bcdaa
      Mircea Trofin authored
      Summary:
      The inline history is associated with a call site. There are two locations
      we fetch inline history. In one, we fetch it together with the call
      site. In the other, we initialize it under certain conditions, use it
      later under same conditions (different if check), and otherwise is
      uninitialized. Although currently there is no uninitialized use, the
      code is more challenging to maintain correctly, than if the value were
      always initialized.
      
      Changed to the upfront initialization pattern already present in this
      file.
      
      Reviewers: davidxl, dblaikie
      
      Subscribers: eraman, hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D77877
      da9bcdaa
  28. Apr 10, 2020
  29. Apr 03, 2020
    • Hongtao Yu's avatar
      Fix a bug in the inliner that causes subsequent double inlining · 88da0199
      Hongtao Yu authored
      Summary:
      A recent change in the instruction simplifier enables a call to a function that just returns one of its parameter to be simplified as simply loading the parameter. This exposes a bug in the inliner where double inlining may be involved which in turn may cause compiler ICE when an already-inlined callsite is reused for further inlining.
      To put it simply, in the following-like C program, when the function call second(t) is inlined, its code t = third(t) will be reduced to just loading the return value of the callsite first(). This causes the inliner internal data structure to register the first() callsite for the call edge representing the third() call, therefore incurs a double inlining when both call edges are considered an inline candidate. I'm making a fix to break the inliner from reusing a callsite for new call edges.
      
      ```
      void top()
      {
          int t = first();
          second(t);
      }
      
      void second(int t)
      {
         t = third(t);
         fourth(t);
      }
      
      void third(int t)
      {
         return t;
      }
      ```
      The actual failing case is much trickier than the example here and is only reproducible with the legacy inliner. The way the legacy inliner works is to process each SCC in a bottom-up order. That means in reality function first may be already inlined into top, or function third is either inlined to second or is folded into nothing. To repro the failure seen from building a large application, we need to figure out a way to confuse the inliner so that the bottom-up inlining is not fulfilled. I'm doing this by making the second call indirect so that the alias analyzer fails to figure out the right call graph edge from top to second and top can be processed before second during the bottom-up.  We also need to tweak the test code so that when the inlining of top happens, the function body of second is not that optimized, by delaying the pass of function attribute deducer (i.e, which tells function third has no side effect and just returns its parameter). Since the CGSCC pass is iterative, additional calls are added to top to postpone the inlining of second to the second round right after the first function attribute deducing pass is done. I haven't been able to repro the failure with the new pass manager since the processing order of ininlined callsites is a bit different, but in theory the issue could happen there too.
      
      Note that this fix could introduce a side effect that blocks the simplification of inlined code, specifically for a call site that can be folded to another call site. I hope this can probably be complemented by subsequent inlining or folding, as shown in the attached unit test. The ideal fix should be to separate the use of VMap. However, in reality this failing pattern shouldn't happen often. And even if it happens, there should be a good chance that the non-folded call site will be refolded by iterative inlining or subsequent simplification.
      
      Reviewers: wenlei, davidxl, tejohnson
      
      Reviewed By: wenlei, davidxl
      
      Subscribers: eraman, nikic, hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D76248
      88da0199
  30. Feb 28, 2020
Loading