Skip to content
  1. Apr 14, 2020
  2. 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
  3. 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
  4. Apr 10, 2020
  5. 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
  6. Feb 28, 2020
    • Hiroshi Yamauchi's avatar
      Devirtualize a call on alloca without waiting for post inline cleanup and next... · f16d2bec
      Hiroshi Yamauchi authored
      Devirtualize a call on alloca without waiting for post inline cleanup and next DevirtSCCRepeatedPass iteration.
      
      This aims to fix a missed inlining case.
      
      If there's a virtual call in the callee on an alloca (stack allocated object) in
      the caller, and the callee is inlined into the caller, the post-inline cleanup
      would devirtualize the virtual call, but if the next iteration of
      DevirtSCCRepeatedPass doesn't happen (under the new pass manager), which is
      based on a heuristic to determine whether to reiterate, we may miss inlining the
      devirtualized call.
      
      This enables inlining in clang/test/CodeGenCXX/member-function-pointer-calls.cpp.
      
      This is a second commit after a revert
      https://reviews.llvm.org/rG4569b3a86f8a4b1b8ad28fe2321f936f9d7ffd43 and a fix
      https://reviews.llvm.org/rG41e06ae7ba91.
      
      Differential Revision: https://reviews.llvm.org/D69591
      f16d2bec
    • Teresa Johnson's avatar
      [Inliner] Inlining should honor nobuiltin attributes · f9ca75f1
      Teresa Johnson authored
      Summary:
      Final patch in series to fix inlining between functions with different
      nobuiltin attributes/options, which was specifically an issue in LTO.
      See discussion on D61634 for background.
      
      The prior patch in this series (D67923) enabled per-Function TLI
      construction that identified the nobuiltin attributes.
      
      Here I have allowed inlining to proceed if the callee's nobuiltins are a
      subset of the caller's nobuiltins, but not in the reverse case, which
      should be conservatively correct. This is controlled by a new option,
      -inline-caller-superset-nobuiltin, which is enabled by default.
      
      Reviewers: hfinkel, gchatelet, chandlerc, davidxl
      
      Subscribers: arsenm, jvesely, nhaehnle, mehdi_amini, eraman, hiraditya, haicheng, dexonsmith, kerbowa, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D74162
      f9ca75f1
  7. Feb 27, 2020
  8. Feb 26, 2020
    • Hiroshi Yamauchi's avatar
      Devirtualize a call on alloca without waiting for post inline cleanup and next · 59fb9cde
      Hiroshi Yamauchi authored
      DevirtSCCRepeatedPass iteration.  Needs ReviewPublic
      
      This aims to fix a missed inlining case.
      
      If there's a virtual call in the callee on an alloca (stack allocated object) in
      the caller, and the callee is inlined into the caller, the post-inline cleanup
      would devirtualize the virtual call, but if the next iteration of
      DevirtSCCRepeatedPass doesn't happen (under the new pass manager), which is
      based on a heuristic to determine whether to reiterate, we may miss inlining the
      devirtualized call.
      
      This enables inlining in clang/test/CodeGenCXX/member-function-pointer-calls.cpp.
      59fb9cde
  9. Jan 15, 2020
    • Mircea Trofin's avatar
      [NFC] Refactor InlineResult for readability · 5466597f
      Mircea Trofin authored
      Summary:
      InlineResult is used both in APIs assessing whether a call site is
      inlinable (e.g. llvm::isInlineViable) as well as in the function
      inlining utility (llvm::InlineFunction). It means slightly different
      things (can/should inlining happen, vs did it happen), and the
      implicit casting may introduce ambiguity (casting from 'false' in
      InlineFunction will default a message about hight costs,
      which is incorrect here).
      
      The change renames the type to a more generic name, and disables
      implicit constructors.
      
      Reviewers: eraman, davidxl
      
      Reviewed By: davidxl
      
      Subscribers: kerbowa, arsenm, jvesely, nhaehnle, eraman, hiraditya, haicheng, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D72744
      5466597f
  10. Sep 30, 2019
  11. Sep 07, 2019
    • Teresa Johnson's avatar
      Change TargetLibraryInfo analysis passes to always require Function · 9c27b59c
      Teresa Johnson authored
      Summary:
      This is the first change to enable the TLI to be built per-function so
      that -fno-builtin* handling can be migrated to use function attributes.
      See discussion on D61634 for background. This is an enabler for fixing
      handling of these options for LTO, for example.
      
      This change should not affect behavior, as the provided function is not
      yet used to build a specifically per-function TLI, but rather enables
      that migration.
      
      Most of the changes were very mechanical, e.g. passing a Function to the
      legacy analysis pass's getTLI interface, or in Module level cases,
      adding a callback. This is similar to the way the per-function TTI
      analysis works.
      
      There was one place where we were looking for builtins but not in the
      context of a specific function. See FindCXAAtExit in
      lib/Transforms/IPO/GlobalOpt.cpp. I'm somewhat concerned my workaround
      could provide the wrong behavior in some corner cases. Suggestions
      welcome.
      
      Reviewers: chandlerc, hfinkel
      
      Subscribers: arsenm, dschuff, jvesely, nhaehnle, mehdi_amini, javed.absar, sbc100, jgravelle-google, eraman, aheejin, steven_wu, george.burgess.iv, dexonsmith, jfb, asbirlea, gchatelet, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D66428
      
      llvm-svn: 371284
      9c27b59c
  12. Aug 15, 2019
  13. Apr 23, 2019
  14. Apr 19, 2019
  15. Apr 05, 2019
  16. Apr 03, 2019
  17. Feb 21, 2019
    • Wei Mi's avatar
      [Inliner] Pass nullptr for the ORE param of getInlineCost if RemarkEnabled · 500606f2
      Wei Mi authored
      is false.
      
      Right now for inliner and partial inliner, we always pass the address of a
      valid ORE object to getInlineCost even if RemarkEnabled is false because of
      no -Rpass is specified. Since ComputeFullInlineCost will be set to true if
      ORE is non-null in getInlineCost, this introduces the problem that in
      getInlineCost we cannot return early even if we already know the cost is
      definitely higher than the threshold. It is a general problem for compile
      time.
      
      This patch fixes that by pass nullptr as the ORE argument if RemarkEnabled is
      false.
      
      Differential Revision: https://reviews.llvm.org/D58399
      
      llvm-svn: 354542
      500606f2
  18. Jan 19, 2019
    • Chandler Carruth's avatar
      Update the file headers across all of the LLVM projects in the monorepo · 2946cd70
      Chandler Carruth authored
      to reflect the new license.
      
      We understand that people may be surprised that we're moving the header
      entirely to discuss the new license. We checked this carefully with the
      Foundation's lawyer and we believe this is the correct approach.
      
      Essentially, all code in the project is now made available by the LLVM
      project under our new license, so you will see that the license headers
      include that license only. Some of our contributors have contributed
      code under our old license, and accordingly, we have retained a copy of
      our old license notice in the top-level files in each project and
      repository.
      
      llvm-svn: 351636
      2946cd70
  19. Jan 05, 2019
    • Easwaran Raman's avatar
      [Inliner] Optimize shouldBeDeferred · 366a873f
      Easwaran Raman authored
      This has some minor optimizations to shouldBeDeferred. This is not
      strictly NFC because the early exit inside the loop assumes
      TotalSecondaryCost is monotonically non-decreasing, which is not true if
      the threshold used by CostAnalyzer is negative. AFAICT the thresholds do
      not go below 0 for the default values of the various options we use.
      
      llvm-svn: 350456
      366a873f
  20. Nov 19, 2018
    • Vedant Kumar's avatar
      [ProfileSummary] Standardize methods and fix comment · e7b789b5
      Vedant Kumar authored
      Every Analysis pass has a get method that returns a reference of the Result of
      the Analysis, for example, BlockFrequencyInfo
      &BlockFrequencyInfoWrapperPass::getBFI().  I believe that
      ProfileSummaryInfo::getPSI() is the only exception to that, as it was returning
      a pointer.
      
      Another change is renaming isHotBB and isColdBB to isHotBlock and isColdBlock,
      respectively.  Most methods use BB as the argument of variable names while
      methods usually refer to Basic Blocks as Blocks, instead of BB.  For example,
      Function::getEntryBlock, Loop:getExitBlock, etc.
      
      I also fixed one of the comments.
      
      Patch by Rodrigo Caetano Rocha!
      
      Differential Revision: https://reviews.llvm.org/D54669
      
      llvm-svn: 347182
      e7b789b5
  21. Oct 24, 2018
    • Wei Mi's avatar
      [PM] keeping history when original SCC split and then merge into itself · 80a0c97e
      Wei Mi authored
      in the same round of SCC update.
      
      In https://reviews.llvm.org/rL309784, inline history is added to prevent
      infinite inlining across multiple run of inliner and SCC update, but the
      history will only be kept when new SCC is actually generated during SCC update.
      
      We found a case that SCC can be split and then merge into itself in the same
      round of SCC update, so the same SCC will be pop out from UR.CWorklist and
      then added back immediately, without any new SCC generated, that is why the
      existing patch cannot catch the infinite inline case.
      
      What the patch does is even if no new SCC is generated, if only the current
      SCC appears in UR.CWorklist again, then keep the inline history.
      
      Differential Revision: https://reviews.llvm.org/D52915
      
      llvm-svn: 345103
      80a0c97e
  22. Aug 28, 2018
    • David Bolvansky's avatar
      [Inliner] Attribute callsites with inline remarks · c1b27b56
      David Bolvansky authored
      Summary:
      Sometimes reading an output *.ll file it is not easy to understand why some callsites are not inlined. We can read output of inline remarks (option --pass-remarks-missed=inline) and try correlating its messages with the callsites.
      
      An easier way proposed by this patch is to add to every callsite processed by Inliner an attribute with the latest message that describes the cause of not inlining this callsite. The attribute is called //inline-remark//. By default this feature is off. It can be switched on by the option //-inline-remark-attribute//.
      
      For example in the provided test the result method //@test1// has two callsites //@bar// and inline remarks report different inlining missed reasons:
        remark: <unknown>:0:0: bar not inlined into test1 because too costly to inline (cost=-5, threshold=-6)
        remark: <unknown>:0:0: bar not inlined into test1 because it should never be inlined (cost=never): recursive
      
      It is not clear which remark correspond to which callsite. With the inline remark attribute enabled we get the reasons attached to their callsites:
        define void @test1() {
          call void @bar(i1 true) #0
          call void @bar(i1 false) #2
          ret void
        }
        attributes #0 = { "inline-remark"="(cost=-5, threshold=-6)" }
        ..
        attributes #2 = { "inline-remark"="(cost=never): recursive" }
      
      Patch by: yrouban (Yevgeny Rouban)
      
      Reviewers: xbolva00, tejohnson, apilipenko
      
      Reviewed By: xbolva00, tejohnson
      
      Subscribers: eraman, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D50435
      
      llvm-svn: 340834
      c1b27b56
  23. Aug 24, 2018
    • David Bolvansky's avatar
      Revert [Inliner] Attribute callsites with inline remarks · 1ccbddca
      David Bolvansky authored
      llvm-svn: 340619
      1ccbddca
    • David Bolvansky's avatar
      [Inliner] Attribute callsites with inline remarks · 7c0537a3
      David Bolvansky authored
      Summary:
      Sometimes reading an output *.ll file it is not easy to understand why some callsites are not inlined. We can read output of inline remarks (option --pass-remarks-missed=inline) and try correlating its messages with the callsites.
      
      An easier way proposed by this patch is to add to every callsite processed by Inliner an attribute with the latest message that describes the cause of not inlining this callsite. The attribute is called //inline-remark//. By default this feature is off. It can be switched on by the option //-inline-remark-attribute//.
      
      For example in the provided test the result method //@test1// has two callsites //@bar// and inline remarks report different inlining missed reasons:
        remark: <unknown>:0:0: bar not inlined into test1 because too costly to inline (cost=-5, threshold=-6)
        remark: <unknown>:0:0: bar not inlined into test1 because it should never be inlined (cost=never): recursive
      
      It is not clear which remark correspond to which callsite. With the inline remark attribute enabled we get the reasons attached to their callsites:
        define void @test1() {
          call void @bar(i1 true) #0
          call void @bar(i1 false) #2
          ret void
        }
        attributes #0 = { "inline-remark"="(cost=-5, threshold=-6)" }
        ..
        attributes #2 = { "inline-remark"="(cost=never): recursive" }
      
      Patch by: yrouban (Yevgeny Rouban)
      
      Reviewers: xbolva00, tejohnson, apilipenko
      
      Reviewed By: xbolva00, tejohnson
      
      Subscribers: eraman, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D50435
      
      llvm-svn: 340618
      7c0537a3
  24. Aug 14, 2018
  25. Aug 06, 2018
  26. Aug 05, 2018
    • David Bolvansky's avatar
      Enrich inline messages · c0aa4b75
      David Bolvansky authored
      Summary:
      This patch improves Inliner to provide causes/reasons for negative inline decisions.
      1. It adds one new message field to InlineCost to report causes for Always and Never instances. All Never and Always instantiations must provide a simple message.
      2. Several functions that used to return the inlining results as boolean are changed to return InlineResult which carries the cause for negative decision.
      3. Changed remark priniting and debug output messages to provide the additional messages and related inline cost.
      4. Adjusted tests for changed printing.
      
      Patch by: yrouban (Yevgeny Rouban)
      
      
      Reviewers: craig.topper, sammccall, sgraenitz, NutshellySima, shchenz, chandlerc, apilipenko, javed.absar, tejohnson, dblaikie, sanjoy, eraman, xbolva00
      
      Reviewed By: tejohnson, xbolva00
      
      Subscribers: xbolva00, llvm-commits, arsenm, mehdi_amini, eraman, haicheng, steven_wu, dexonsmith
      
      Differential Revision: https://reviews.llvm.org/D49412
      
      llvm-svn: 338969
      c0aa4b75
  27. Aug 01, 2018
    • David Bolvansky's avatar
      Revert "Enrich inline messages", tests fail · fbbb83c7
      David Bolvansky authored
      llvm-svn: 338496
      fbbb83c7
    • David Bolvansky's avatar
      Enrich inline messages · 7f36cd9d
      David Bolvansky authored
      Summary:
      This patch improves Inliner to provide causes/reasons for negative inline decisions.
      1. It adds one new message field to InlineCost to report causes for Always and Never instances. All Never and Always instantiations must provide a simple message.
      2. Several functions that used to return the inlining results as boolean are changed to return InlineResult which carries the cause for negative decision.
      3. Changed remark priniting and debug output messages to provide the additional messages and related inline cost.
      4. Adjusted tests for changed printing.
      
      Patch by: yrouban (Yevgeny Rouban)
      
      
      Reviewers: craig.topper, sammccall, sgraenitz, NutshellySima, shchenz, chandlerc, apilipenko, javed.absar, tejohnson, dblaikie, sanjoy, eraman, xbolva00
      
      Reviewed By: tejohnson, xbolva00
      
      Subscribers: xbolva00, llvm-commits, arsenm, mehdi_amini, eraman, haicheng, steven_wu, dexonsmith
      
      Differential Revision: https://reviews.llvm.org/D49412
      
      llvm-svn: 338494
      7f36cd9d
  28. Jul 31, 2018
    • David Bolvansky's avatar
      Revert Enrich inline messages · ab79414f
      David Bolvansky authored
      llvm-svn: 338389
      ab79414f
    • David Bolvansky's avatar
      Enrich inline messages · b562dbab
      David Bolvansky authored
      Summary:
      This patch improves Inliner to provide causes/reasons for negative inline decisions.
      1. It adds one new message field to InlineCost to report causes for Always and Never instances. All Never and Always instantiations must provide a simple message.
      2. Several functions that used to return the inlining results as boolean are changed to return InlineResult which carries the cause for negative decision.
      3. Changed remark priniting and debug output messages to provide the additional messages and related inline cost.
      4. Adjusted tests for changed printing.
      
      Patch by: yrouban (Yevgeny Rouban)
      
      
      Reviewers: craig.topper, sammccall, sgraenitz, NutshellySima, shchenz, chandlerc, apilipenko, javed.absar, tejohnson, dblaikie, sanjoy, eraman, xbolva00
      
      Reviewed By: tejohnson, xbolva00
      
      Subscribers: xbolva00, llvm-commits, arsenm, mehdi_amini, eraman, haicheng, steven_wu, dexonsmith
      
      Differential Revision: https://reviews.llvm.org/D49412
      
      llvm-svn: 338387
      b562dbab
  29. Jun 28, 2018
  30. Jun 04, 2018
    • David Blaikie's avatar
      Move Analysis/Utils/Local.h back to Transforms · 31b98d2e
      David Blaikie authored
      Review feedback from r328165. Split out just the one function from the
      file that's used by Analysis. (As chandlerc pointed out, the original
      change only moved the header and not the implementation anyway - which
      was fine for the one function that was used (since it's a
      template/inlined in the header) but not in general)
      
      llvm-svn: 333954
      31b98d2e
  31. May 14, 2018
    • Nicola Zaghen's avatar
      Rename DEBUG macro to LLVM_DEBUG. · d34e60ca
      Nicola Zaghen authored
          
      The DEBUG() macro is very generic so it might clash with other projects.
      The renaming was done as follows:
      - git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g'
      - git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM
      - Manual change to APInt
      - Manually chage DOCS as regex doesn't match it.
      
      In the transition period the DEBUG() macro is still present and aliased
      to the LLVM_DEBUG() one.
      
      Differential Revision: https://reviews.llvm.org/D43624
      
      llvm-svn: 332240
      d34e60ca
  32. May 08, 2018
Loading