1. May 17, 2024
  2. May 16, 2024
    • Florian Hahn's avatar
      [VPlan] Address remaining comments for #85689. · 309a881d
      Florian Hahn authored
      Address comments missed when landing
      https://github.com/llvm/llvm-project/pull/85689.
      309a881d
    • Matt Arsenault's avatar
    • Renaud Kauffmann's avatar
      [flang] AliasAnalysis: More formally define and distinguish between data and non-data (#91020) · ee407e17
      Renaud Kauffmann authored
      This PR is an implementation for changes proposed in
      https://discourse.llvm.org/t/rfc-distinguish-between-data-and-non-data-in-fir-alias-analysis/78759
      
      Test updates were made when the query was on the wrong reference. So, it
      is my hope that this will clear ambiguity on the nature of the queries
      from here on.
      There are also some TODOs that were addressed. 
      
      It also partly implements what
      https://github.com/llvm/llvm-project/pull/87723 is attempting to
      accomplish. At least, on a point-to-point query between references, the
      distinction is made. To apply it to TBAA, would be another PR.
      
      Note that, the changes were minimal in the TBAA code to retain the
      current results.
      ee407e17
    • Dana Jansens's avatar
      Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (#91777) · 5ac34358
      Dana Jansens authored
      The -Wunsafe-buffer-usage warning should fire on any call to a function
      annotated with [[clang::unsafe_buffer_usage]], however it omitted calls
      to constructors, since the expression is a CXXConstructExpr which does
      not subclass CallExpr. Thus the matcher on callExpr() does not find
      these expressions.
      
      Add a new WarningGadget that matches cxxConstructExpr that are calling a
      CXXConstructDecl annotated by [[clang::unsafe_buffer_usage]] and fires
      the warning. The new UnsafeBufferUsageCtorAttrGadget gadget explicitly
      avoids matching against the std::span(ptr, size) constructor because
      that is handled by SpanTwoParamConstructorGadget and we never want two
      gadgets to match the same thing (and this is guarded by asserts).
      
      The gadgets themselves do not report the warnings, instead each gadget's
      Stmt is passed to the UnsafeBufferUsageHandler (implemented by
      UnsafeBufferUsageReporter). The Reporter is previously hardcoded that a
      CXXConstructExpr statement must be a match for std::span(ptr, size), but
      that is no longer the case. We want the Reporter to generate different
      warnings (in the -Wunsafe-buffer-usage-in-container subgroup) for the
      span contructor. And we will want it to report more warnings for other
      std-container-specific gadgets in the future. To handle this we allow
      the gadget to control if the warning is general (it calls
      handleUnsafeBufferUsage()) or is a std-container-specific warning (it
      calls handleUnsafeOperationInContainer()).
      
      Then the WarningGadget grows a virtual method to dispatch to the
      appropriate path in the UnsafeBufferUsageHandler. By doing so, we no
      longer need getBaseStmt in the Gadget interface. The only use of it for
      FixableGadgets was to get the SourceLocation, so we make an explicit
      virtual method for that on Gadget. Then the handleUnsafeOperation()
      dispatcher can be a virtual method that is only in WarningGadget.
      
      The SpanTwoParamConstructorGadget gadget dispatches to
      handleUnsafeOperationInContainer() while the other WarningGadgets all
      dispatch to the original handleUnsafeBufferUsage().
      
      Tests are added for annotated constructors, conversion operattors, call
      operators, fold expressions, and regular methods.
      
      Issue #80482
      5ac34358
    • Vlad Serebrennikov's avatar
      d1f96d4c
    • Dmitry Vasilyev's avatar
      [lldb] Fixed the DAP tests in case of a remote target (#92398) · d665d51c
      Dmitry Vasilyev authored
      These tests failed in case of Windows host and Linux target, because
      dap_server tried to run ELF file on Windows.
      d665d51c
    • Dmitry Vasilyev's avatar
      [lldb] Fixed an invalid error message in the DAP disconnect response (#92345) · f579dcf8
      Dmitry Vasilyev authored
      The `disconnect` response contains the `error` message with invalid
      characters (a junk data). To reproduce this issue it is enough to run
      the `TestDAP_commands` test on Windows host and Linux target. The test
      will fail to run ELF file on Windows and dap_server will be disconnected
      unexpectedly.
      
      Note dap_server hangs if read_packet() cannot decode JSON with invalid
      characters. read_packet() must return None in this case instead of an
      exception. But dap_server does not require any fix after this patch.
      f579dcf8
    • NimishMishra's avatar
      [flang][OpenMP] Add test for checking overloaded operator in atomic update (#88471) · d94582ee
      NimishMishra authored
      Atomic update expression does not allow overloaded user-defined
      operators. This PR adds a test case for the same; the semantic check is
      already existent.
      d94582ee
    • Tom Eccles's avatar
      [flang][MLIR][OpenMP] make reduction by-ref toggled per variable (#92244) · 74a87548
      Tom Eccles authored
      Fixes #88935
      
      Toggling reduction by-ref broke when multiple reduction clauses were
      used. Decisions made for the by-ref status for later clauses could then
      invalidate decisions for earlier clauses. For example,
      
      ```
      reduction(+:scalar,scalar2) reduction(+:array)
      ```
      
      The first clause would choose by value reduction and generate by-value
      reduction regions, but then after this the second clause would force
      by-ref to support the array argument. But by the time the second clause
      is processed, the first clause has already had the wrong kind of
      reduction regions generated.
      
      This is solved by toggling whether a variable should be reduced by
      reference per variable. In the above example, this allows only `array`
      to be reduced by ref.
      74a87548
    • Benjamin Maxwell's avatar
    • Michael Maitland's avatar
      [TableGen][SubtargetEmitter] Early exit from loop in FindWriteResources and... · c675a58e
      Michael Maitland authored
      [TableGen][SubtargetEmitter] Early exit from loop in FindWriteResources and FindReadAdvance (#92202)
      
      This gives us a 30% speed improvement in our downstream.
      c675a58e
    • Jacek Caban's avatar
    • Simon Pilgrim's avatar
      [X86] Reduce znver3/4 LoopMicroOpBufferSize to practical loop unrolling values (#91340) · 54e52aa5
      Simon Pilgrim authored
      The znver3/4 scheduler models have previously associated the LoopMicroOpBufferSize with the maximum size of their op caches, and when this led to quadratic complexity issues this were reduced to a value of 512 uops, based mainly on compilation time and not its effectiveness on runtime performance.
      
      From a runtime performance POV, a large LoopMicroOpBufferSize leads to a higher number of loop unrolls, meaning the cpu has to rely on the frontend decode rate (4 ins/cy max) for much longer to fill the op cache before looping begins and we make use of the faster op cache rate (8/9 ops/cy).
      
      This patch proposes we instead cap the size of the LoopMicroOpBufferSize based off the maximum rate from the op cache (znver3 = 8op/cy, znver4 = 9op/cy) and the branch misprediction penalty from the opcache (~12cy) as a estimate of the useful number of ops we can unroll a loop by before mispredictions are likely to cause stalls. This isn't a perfect metric, but does try to be closer to the spirit of how we use LoopMicroOpBufferSize in the compiler vs the size of a similar naming buffer in the cpu.
      54e52aa5
    • Jacek Caban's avatar
    • zibi2's avatar
      [libc++][z/OS] Correct a definition of __native_vector_size (#91995) · af57ad65
      zibi2 authored
      Fix `std/ranges/range.adaptors/range.lazy.split/general.pass.cpp` which
      started failing on z/OS after this
      [commit](https://github.com/llvm/llvm-project/commit/985c1a44f8d49e0af).
      
      This test case is passing on other platforms such as AIX. This is
      because the `__ALTIVEC__` macro is defined and `__mismatch` under
      `_LIBCPP_VECTORIZE_ALGORITHMS` guard is compiled out. However, on z/OS
      `_LIBCPP_VECTORIZE_ALGORITHMS` is defined. Analyzing the algorithm of
      `__mismatch` shows that the culprit is the definition of
      `__native_vector_size` which was defined wrongly as 1. This PR corrects
      the definition of `__native_vector_size` and fixes the affected test.
      af57ad65
    • Hassnaa Hamdi's avatar
      [AArch64] Add intrinsics for bfloat16 min/max/minnm/maxnm (#90105) · f7392f40
      Hassnaa Hamdi authored
      According to specifications in
      [ARM-software/acle/pull/309](https://github.com/ARM-software/acle/pull/309)
      Add following intrinsics:
      
      ```
      // svmax single,multi
      svbfloat16x2_t svmax_single_bf16_x2(svbfloat16x2_t zdn, svbfloat16_t zm)
      svbfloat16x4_t svmax_single_bf16_x4(svbfloat16x4_t zdn, svbfloat16_t zm)
      svbfloat16x2_t svmax_bf16_x2(svbfloat16x2_t zdn, svbfloat16x2_t zm)
      svbfloat16x4_t svmax_bf16_x4(svbfloat16x4_t zdn, svbfloat16x4_t zm)
      ```
      
      ```
      // svmin single,multi
      svbfloat16x2_t svmin_single_bf16_x2(svbfloat16x2_t zdn, svbfloat16_t zm)
      svbfloat16x4_t svmin_single_bf16_x4(svbfloat16x4_t zdn, svbfloat16_t zm)
      svbfloat16x2_t svmin_bf16_x2(svbfloat16x2_t zdn, svbfloat16x2_t zm)
      svbfloat16x4_t svmin_bf16_x4(svbfloat16x4_t zdn, svbfloat16x4_t zm)
      ```
      
      ```
      // svmaxnm single,multi
      svbfloat16x2_t svmaxnm_single_bf16_x2(svbfloat16x2_t zdn, svbfloat16_t zm)
      svbfloat16x4_t svmaxnm_single_bf16_x4(svbfloat16x4_t zdn, svbfloat16_t zm)
      svbfloat16x2_t svmaxnm_bf16_x2(svbfloat16x2_t zdn, svbfloat16x2_t zm)
      svbfloat16x4_t svmaxnm_bf16_x4(svbfloat16x4_t zdn, svbfloat16x4_t zm)
      ```
      
      ```
      // svminnm single,multi
      svbfloat16x2_t svminnm_single_bf16_x2(svbfloat16x2_t zdn, svbfloat16_t zm)
      svbfloat16x4_t svminnm_single_bf16_x4(svbfloat16x4_t zdn, svbfloat16_t zm)
      svbfloat16x2_t svminnm_bf16_x2(svbfloat16x2_t zdn, svbfloat16x2_t zm)
      svbfloat16x4_t svminnm_bf16_x4(svbfloat16x4_t zdn, svbfloat16x4_t zm)
      ```
      - Variations other than bfloat16 are already supported.
      f7392f40
    • Dmitry Vasilyev's avatar
      [lldb] Move TestBase.runCmd() to the Base class (#92252) · 44eded31
      Dmitry Vasilyev authored
      runCmd() is called from Base.getCPUInfo() but implemented only in
      TestBase(Base). Usually it works if TestBase is used. But call
      getCPUInfo() from a class based on Base will cause something like
      ```
      File "E:\projects\llvm-nino\lldb\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py", line 1256, in getCPUInfo
        self.runCmd('platform get-file "/proc/cpuinfo" ' + cpuinfo_path)
      AttributeError: 'TestGdbRemoteExpeditedRegisters' object has no attribute 'runCmd'
      ```
      BTW, TestBase.setUp() called runCmd() before applying
      LLDB_MAX_LAUNCH_COUNT and LLDB_TIME_WAIT_NEXT_LAUNCH.
      
      This patch fixes the test TestGdbRemoteExpeditedRegisters in case of
      Windows host and Linux target.
      44eded31
    • Simon Pilgrim's avatar
      [X86] rot32.ll - remove old shld check prefixes · 80fac30a
      Simon Pilgrim authored
      This was missed in 8dbd745b
      80fac30a
    • Jie Fu's avatar
      [Transforms] Fix -Wunused-variable in DemoteRegToStack.cpp (NFC) · e948da10
      Jie Fu authored
      llvm-project/llvm/lib/Transforms/Utils/DemoteRegToStack.cpp:58:21:
      error: unused variable 'BB' [-Werror,-Wunused-variable]
              BasicBlock *BB = SplitCriticalEdge(II, i);
                          ^
      1 error generated.
      e948da10
    • zibi2's avatar
    • Dmitry Vasilyev's avatar
      [lldb][Windows] Disable the TestGdbRemoteLibrariesSvr4Support test for Windows host (#92341) · 2bc9af96
      Dmitry Vasilyev authored
      Windows does not allow quotes in file names. So it is impossible to
      build `libsvr4lib_b".so` on Windows.
      2bc9af96
    • Krzysztof Parzyszek's avatar
      [flang][OpenMP] Remove unnecessary `Fortran::` qualification, NFC (#92298) · 7a66e420
      Krzysztof Parzyszek authored
      The `Fortran::` namespace is redundant for all parts of the code in this
      PR, except for names of functions in their definitions.
      7a66e420
    • David Truby's avatar
      [clang][flang][windows] Prefer user-provided library paths (-L) (#90758) · 7ce8d2e5
      David Truby authored
      Currently the paths to compiler-rt and the Flang runtimes from the LLVM
      build/install directory are preferred over any user-provided library
      paths. This means a user can't override compiler-rt or the Flang
      runtimes with custom versions.
      
      This patch changes the link order to prefer library paths specified with
      -L over the LLVM paths. This matches the behaviour of clang and flang on
      Linux.
      7ce8d2e5
    • Florian Hahn's avatar
      [VPlan] Document current status. (#85689) · 99de3a68
      Florian Hahn authored
      Update VectorizationPlan.rst to include a section about the current
      status of VPlan and its use in LoopVectorize, based on "VPlan: Status
      Update and Future Roadmap", LLVM Developers’ Meeting 2023,
      https://www.youtube.com/watch?v=SzGP4PgMuLE
      
      PR: https://github.com/llvm/llvm-project/pull/85689
      99de3a68
    • Jie Fu's avatar
      [Transforms] Fix -Wsign-compare in DemoteRegToStack.cpp (NFC) · 03d8e613
      Jie Fu authored
      llvm-project/llvm/lib/Transforms/Utils/DemoteRegToStack.cpp:54:23:
      error: comparison of integers of different signs: 'int' and 'unsigned int' [-Werror,-Wsign-compare]
          for (int i = 0; i < CBI->getNumSuccessors(); i++) {
                          ~ ^ ~~~~~~~~~~~~~~~~~~~~~~~
      1 error generated.
      03d8e613
    • Orlando Cazalet-Hyams's avatar
      [RemoveDIs][NFC] Fix rotten green C API test (#92362) · 91120733
      Orlando Cazalet-Hyams authored
      `llvm_test_dibuilder(/*NewDebugInfoMode=*/true)` isn't currently executed in 
      `return llvm_test_dibuilder(false) && llvm_test_dibuilder(true);`
      because `llvm_test_dibuilder` returns 0 for success.
      
      Split the llvm-c-test flag `--test-dibuilder` into two, one for the old and
      one for the new debug info format. Add another lit test for the new format.
      
      Now that the test actually runs, it crashes using the new format with
      `llvm/lib/IR/LLVMContextImpl.cpp:53:llvm::LLVMContextImpl::~LLVMContextImpl(): Assertion 'TrailingDbgRecords.empty() && "DbgRecords in blocks not cleaned"' failed. Aborted`.
      
      Insert terminators into the blocks so that we don't leave the debug records
      trailing, unattached to any instructions, which fixes that.
      91120733
    • XChy's avatar
      [Reg2Mem] Handle CallBr instructions (#90953) · fdaad738
      XChy authored
      Fixes #90900
      fdaad738
    • Simon Pilgrim's avatar
      [DAG] SimplifyDemandedBits - ISD::AND - only request DemandedElts when looking for a splat constant · 311339e2
      Simon Pilgrim authored
      Limit the isConstOrConstSplat call to the vector elements we care about
      
      Noticed while investigating regressions in #92096
      311339e2
    • LLVM GN Syncbot's avatar
      [gn build] Port 7d810623 · cf92e51f
      LLVM GN Syncbot authored
      cf92e51f
    • Pierre van Houtryve's avatar
      [GlobalISel] Refactor Combiner MatchData & Apply C++ Code Handling (#92239) · 7d810623
      Pierre van Houtryve authored
      Combiners that use C++ code in their "apply" pattern only use that. They
      never mix it with MIR patterns as that has little added value.
      
      This patch restricts C++ apply code so that if C++ is used, we cannot
      use MIR patterns or builtins with it. Adding this restriction allows us
      to merge calls to match and apply C++ code together, which in turns
      makes it so we can just have MatchData variables on the stack.
      
      So before, we would have
      ```
        GIM_CheckCxxInsnPredicate // match
        GIM_CheckCxxInsnPredicate // apply
        GIR_Done
      ```
      Alongside a massive C++ struct holding the MatchData of all rules
      possible (which was a big space/perf issue).
      
      Now we just have
      ```
      GIR_DoneWithCustomAction
      ```
      
      And the function being ran just does
      ```
      unsigned SomeMatchData;
      if (match(SomeMatchData))
        apply(SomeMatchData)
      ```
      
      This approach solves multiple issues in one:
      - MatchData handling is greatly simplified and more efficient, "don't
      pay for what you don't use"
        - We reduce the size of the match table
      - Calling C++ code has a certain overhead (we need a switch), and this
      overhead is only paid once now.
      
      Handling of C++ code inside PatFrags is unchanged though, that still
      emits a `GIM_CheckCxxInsnPredicate`. This is completely fine as they
      can't use MatchDatas.
      7d810623
    • Pierre van Houtryve's avatar
      [GlobalISel] Reduce KnownBits usage in matcher combines (#92381) · 0bc1ec5c
      Pierre van Houtryve authored
      Two icmp/and combines forced computation of KnownBits on all operands
      everytime. We can avoid computing KnownBits on the LHS by exploiting a
      couple of properties:
      - Constants are always on the RHS for those instructions. If we have no
      KnownBits on the RHS, we can bail out early and avoid computing LHS
      knownbits.
      - For icmp uge/ult 0, we don't need to know the KBs of the LHS to infer
      the result
      
      This allows to save some KnownBits calls, which are very expensive,
      without affecting codegen.
      0bc1ec5c
    • Yingwei Zheng's avatar
    • Haojian Wu's avatar
      [clang] CTAD: implement the missing IsDeducible constraint for alias templates (#89358) · a9605730
      Haojian Wu authored
      Fixes https://github.com/llvm/llvm-project/issues/85192
      Fixes https://github.com/llvm/llvm-project/issues/84492
      
      This patch implements the "IsDeducible" constraint where the template
      arguments of the alias template can be deduced from the returned type of
      the synthesized deduction guide, per C++ [over.match.class.deduct]p4. In
      the implementation, we perform the deduction directly, which is more
      efficient than the way specified in the standard.
      
      Also update relevant CTAD tests which were incorrectly compiled due to
      the missing constraint.
      a9605730
    • Haojian Wu's avatar
      [AST] RecursiveASTVisitor: Don't traverse the alias deduction guides in the default mode. (#91454) · 239f8b9e
      Haojian Wu authored
      By default (`shouldVisitImplicitCode()` returns `false`), RAV should not
      traverse AST nodes that are not spelled in the source code. Deduction
      guides for alias templates are always synthesized, so they should not be
      traversed.
      
      This is usually done by checking the implicit bit of the Decl. However,
      this doesn't work deduction guides that are synthesized from explicit
      user-defined deduction guides, as we must maintain the explicit bit to
      ensure correct overload resolution.
      239f8b9e