1. May 16, 2024
    • 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
    • Arseniy Zaostrovnykh's avatar
      [clang] Fix CXXNewExpr end source location for 'new struct S' (#92266) · ba2e4fe4
      Arseniy Zaostrovnykh authored
      Currently, `new struct S` fails to set any valid end source location
      because the token corresponding to `S` is consumed in
      `ParseClassSpecifier` and is not accessible in the
      `ParseDeclarationSpecifiers` that normally sets the end source location.
      
      Fixes #35300
      ba2e4fe4
    • Dmitri Gribenko's avatar
      Revert "[LoopUnroll] Clamp PartialThreshold for large LoopMicroOpBufferSize (#67657)" · 83974a4b
      Dmitri Gribenko authored
      This reverts commit f0b36547.
      
      This commit triggers UB by reading an uninitialized variable.
      
      `UP.PartialThreshold` is used uninitialized in `getUnrollingPreferences()` when
      it is called from `LoopVectorizationPlanner::executePlan()`. In this case the
      `UP` variable is created on the stack and its fields are not initialized.
      
      ```
      ==8802==WARNING: MemorySanitizer: use-of-uninitialized-value
          #0 0x557c0b081b99 in llvm::BasicTTIImplBase<llvm::X86TTIImpl>::getUnrollingPreferences(llvm::Loop*, llvm::ScalarEvolution&, llvm::TargetTransformInfo::UnrollingPreferences&, llvm::OptimizationRemarkEmitter*) llvm-project/llvm/include/llvm/CodeGen/BasicTTIImpl.h
          #1 0x557c0b07a40c in llvm::TargetTransformInfo::Model<llvm::X86TTIImpl>::getUnrollingPreferences(llvm::Loop*, llvm::ScalarEvolution&, llvm::TargetTransformInfo::UnrollingPreferences&, llvm::OptimizationRemarkEmitter*) llvm-project/llvm/include/llvm/Analysis/TargetTransformInfo.h:2277:17
          #2 0x557c0f5d69ee in llvm::TargetTransformInfo::getUnrollingPreferences(llvm::Loop*, llvm::ScalarEvolution&, llvm::TargetTransformInfo::UnrollingPreferences&, llvm::OptimizationRemarkEmitter*) const llvm-project/llvm/lib/Analysis/TargetTransformInfo.cpp:387:19
          #3 0x557c0e6b96a0 in llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool, llvm::DenseMap<llvm::SCEV const*, llvm::Value*, llvm::DenseMapInfo<llvm::SCEV const*, void>, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::Value*>> const*) llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7624:7
          #4 0x557c0e6e4b63 in llvm::LoopVectorizePass::processLoop(llvm::Loop*) llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10253:13
          #5 0x557c0e6f2429 in llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10344:30
          #6 0x557c0e6f2f97 in llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10383:9
      
      [...]
      
        Uninitialized value was created by an allocation of 'UP' in the stack frame
          #0 0x557c0e6b961e in llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool, llvm::DenseMap<llvm::SCEV const*, llvm::Value*, llvm::DenseMapInfo<llvm::SCEV const*, void>, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::Value*>> const*) llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7623:3
      ```
      83974a4b
    • Donát Nagy's avatar
      [analyzer] Clean up list of taint propagation functions (#91635) · 5ffd154c
      Donát Nagy authored
      This commit refactors GenericTaintChecker and performs various
      improvements in the list of taint propagation functions:
      
      1. The matching mode (usually `CDM::CLibrary` or
      `CDM::CLibraryMaybeHardened`) was specified to avoid matching e.g. C++
      methods or functions from a user-defined namespace that happen to share
      the name of a well-known library function.
      2. With these matching modes, a `CallDescription` can automatically
      match builtin variants of the functions, so entries that explicitly
      specified a builtin function were removed. This eliminated
      inconsistencies where the "normal" and the builtin variant of the same
      function was handled differently (e.g. `__builtin_strlcat` was covered,
      while plain `strlcat` wasn't; while `__builtin_memcpy` and `memcpy` were
      both on the list with different propagation rules).
      3. The modeling of the functions `strlcat` and `strncat` was updated to
      propagate taint from the first argument (index 0), because a tainted
      string should remain tainted even if we append something else to it.
      Note that this was already applied to `strcat` and `wcsncat` by commit
      6ceb1c0e.
      4. Some functions were updated to propagate taint from a size/length
      argument to the result: e.g. `memcmp(p, q, get_tainted_int())` will now
      return a tainted value (because the attacker can manipulate it). This
      principle was already present in some propagation rules (e.g.
      `__builtin_memcpy` was handled this way), and even after this commit
      there are still some functions where it isn't applied. (I only aimed for
      consistency within the same function family.)
      5. Functions that have hardened `__FOO_chk()` variants are matched in
      `CDM:CLibraryMaybeHardened` to ensure consistent handling of the
      "normal" and the hardened variant. I added special handling for the
      hardened variants of "sprintf" and "snprintf" because there the extra
      parameters are inserted into the middle of the parameter list.
      6. Modeling of `sscanf_s` was added, to complete the group of `fscanf`,
      `fscanf_s` and `sscanf`.
      7. The `Source()` specifications for `gets`, `gets_s` and `wgetch` were
      ill-formed: they were specifying variadic arguments starting at argument
      index `ReturnValueIndex`. (That is, in addition to the return value they
      were propagating taint to all arguments.)
      8. Functions that were related to each other were grouped together. (I
      know that this makes the diff harder to read, but I felt that the full
      list is unreadable without some reorganization.)
      9. I spotted and removed some redundant curly braces. Perhaps would be
      good to switch to a cleaner layout with less nested braces...
      10. I updated some obsolete comments and added two TODOs for issues that
      should be fixed in followup commits.
      5ffd154c
    • Sirraide's avatar
      [NFC] Update example in comment · 1795fa58
      Sirraide authored
      1795fa58
    • Benjamin Maxwell's avatar
      [mlir][vector] Teach `TransferOptimization` to look through trivial aliases (#87805) · 90d2f8c6
      Benjamin Maxwell authored
      This allows `TransferOptimization` to eliminate and forward stores that
      are to trivial aliases (rather than just to identical memref values).
      
      A trivial aliases is (currently) defined as:
      
        1. A `memref.cast`
        2. A `memref.subview` with a zero offset and unit strides
        3. A chain of 1 and 2
      90d2f8c6
    • wanglei's avatar
    • Oleg Shyshkov's avatar
      [mlir][bazel] Fix bazel build. · 53bdcee9
      Oleg Shyshkov authored
      53bdcee9
    • wanglei's avatar
      [LoongArch] Refactor LoongArchABI::computeTargetABI · 70608c24
      wanglei authored
      The previous logic did not consider whether the architectural features
      meet the requirements of the ABI, resulting in the generation of
      incorrect object files in some cases. For example:
      
      ```
      llc -mtriple=loongarch64 -filetype=obj test/CodeGen/LoongArch/ir-instruction/fadd.ll -o t.o
      llvm-readelf -h t.o
      ```
      The object file indicates the ABI as lp64d, however, the generated code
      is lp64s.
      
      The new logic introduces the `feature-implied` ABI. When both target-abi
      and triple-implied ABI are invalid, the feature-implied ABI is used.
      
      Reviewed By: SixWeining, xen0n
      
      Pull Request: https://github.com/llvm/llvm-project/pull/92223
      70608c24
    • wanglei's avatar
      [LoongArch] Enable all -target-abi options · 30410018
      wanglei authored
      This is a pre-commit for modifying `computeTargetABI` logic.
      
      This patch will provide warning prompts when using those ABIs that have
      not yet been standardized.
      
      Reviewed By: xen0n, SixWeining
      
      Pull Request: https://github.com/llvm/llvm-project/pull/92222
      30410018
    • Benjamin Maxwell's avatar
      [mlir][vector] Teach `TransferOptimization` to forward masked stores (#87794) · ca02f36b
      Benjamin Maxwell authored
      This only handles one case (that's fairly common in practice*), storing
      a masked constant splat, then reloading again with the same mask and a
      padding value that matches the splat.
      
      * For SVE/SME (without peeling) this occurs when you have a
      `linalg.fill` preceding a `linalg.matmul`.
      ca02f36b
    • Tomas Matheson's avatar
      [AArch64][TargetParser] move ArchInfo into tablegen [NFC] (#92037) · 72a89533
      Tomas Matheson authored
      This moves the architecture version, profile and extension information
      into tablegen, and generates the TargetParser ArchInfo objects from
      this data.
      
      There are two lists of "dependencies" defined for each architecture: the
      SubtargetFeature::Implies which controls which features are
      automatically enabled in the backend when the corresponding architecture
      SubtargetFeature is enabled; and the list of Extensions which are
      enabled by default for this architecture. As far as I can tell, the idea
      here is that the SubtargetFeature models the mandatory dependencies (although
      they can still be disabled if desired) while the default extensions models
      the typical use case for that architecture.
      72a89533
    • Alex Zinenko's avatar
      [mlir] fix orphaned IRDLExtensionOps documentation · 51403ada
      Alex Zinenko authored
      .md files should be included into other .md files so they don't show up in the
      top-level menu.
      51403ada
    • Alex Zinenko's avatar
      [mlir] add missing include to MemRefTransformOps.h · 710f4bd0
      Alex Zinenko authored
      The ODS-generated code has the following:
      
      ```
      ::mlir::TypedValue<::mlir::transform::OperationType> getAlloca() {
        return ::llvm::cast<::mlir::TypedValue<::mlir::transform::OperationType>>(
            *getODSOperands(0).begin());
      }
      ```
      
      that may require the compiler seing the definition of `OperationType` so
      include the corresponding header.
      710f4bd0
    • Matt Arsenault's avatar
    • Abid Qadeer's avatar
      [reland][flang] Initial debug info support for local variables (#92304) · cd5ee271
      Abid Qadeer authored
      This is same as #90905 with an added fix. The issue was that we
      generated variable info even when user asked for line-tables-only. This
      caused llvm dwarf generation code to fail an assertion as it expected an
      empty variable list.
      
      Fixed by not generating debug info for variables when user wants only
      line table. I also updated a test check for this case.
      cd5ee271
    • Adam Siemieniuk's avatar
      [mlir][tensor] Fold pack-unpack with unbalanced outer_dims_perm attr (#92234) · dcd32bd6
      Adam Siemieniuk authored
      Extends pack/unpack perm attribute checker to account for cases when the
      optional outer_dims_perm attribute might be missing in one operation and
      the other one has explicit identity permutation. This enables
      canonicalizer to fold more unpack(pack(x)) variants.
      dcd32bd6
    • Mital Ashok's avatar
    • Kazu Hirata's avatar
      [ADT] Deprecate StringRef::equals (#92351) · de483ad5
      Kazu Hirata authored
      This patch deprecates StringRef::equals.  Note that I've migrated all
      known users to operator==(StringRef, StringRef).
      de483ad5
    • Matt Arsenault's avatar
    • Cullen Rhodes's avatar
      [mlir][ArmSME] Verify ops on tile types post LLVM conversion (#92076) · b5107bdd
      Cullen Rhodes authored
      Unsupported ops on tile types can become dead after
      `-convert-arm-sme-to-llvm` resulting in incorrect results. Verify such
      operations don't exist post-conversion and fail if they do.
      
      Based on discussion from
      https://discourse.llvm.org/t/on-improving-arm-sme-lowering-resilience-in-mlir/78543
      b5107bdd
    • Matt Arsenault's avatar
      InstCombine: Try to use exp10 intrinsic instead of libcall (#92287) · ce1ce5d3
      Matt Arsenault authored
      Addresses old TODO about the exp10 intrinsic not existing.
      ce1ce5d3
    • Daniil Kovalev's avatar
    • Kiran Chandramohan's avatar
      [Flang][OpenMP] Fix update operation not found issue (#92165) · 89ee3ae2
      Kiran Chandramohan authored
      If there is only one non-terminator operation in the update region then
      the update operation can be found and we can try to generate an
      atomicrmw instruction. Otherwise use the cmpxchg loop.
      
      Fixes #91929
      89ee3ae2