1. Mar 27, 2024
    • Craig Topper's avatar
      [RISCV] Remove unneeded VAESKF_MV_I tablegen class. NFC · 8cb4eb99
      Craig Topper authored
      It is identical to PALUVINoVm so we can use that instead.
      8cb4eb99
    • Kazu Hirata's avatar
      [TosaToTensor] Fix a warning (#86703) · 1eaef445
      Kazu Hirata authored
      This patch fixes:
      
        mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp:76:46: error:
        'multiplies' may not intend to support class template argument
        deduction [-Werror,-Wctad-maybe-unsupported]
      1eaef445
    • Alexey Bataev's avatar
      [SLP]Do not propagate nuw/nsw flags for alt nodes, affected by · 26dd1287
      Alexey Bataev authored
      minbitwidth analysis.
      
      Need to drop nuw/nsw flags, if the alternate node is resized after the
      minbitwidth analysis, to avoid producing poison values in corner cases.
      26dd1287
    • Piotr Zegar's avatar
      [clang-tidy] Fix fix-it overlaps in readability-static-definition-in-anonymous-namespace (#86599) · 31373479
      Piotr Zegar authored
      Because check emitted multiple warnings for every template instance
      fix-it couldn't be applied due to overlaps.
      
      Using TK_IgnoreUnlessSpelledInSource and restricting check to C++ only.
      31373479
    • Peter Klausler's avatar
      [flang] Catch impossible but necessary TBP override (#86558) · f4fc959c
      Peter Klausler authored
      An apparent attempt to override a type-bound procedure is not allowed to
      be interpreted as on override when the procedure is PRIVATE and the
      override attempt appears in another module. However, if the TBP that
      would have been overridden is a DEFERRED procedure in an abstract base
      type, the override must take place. PRIVATE DEFERRED procedures must
      therefore have all of their overrides appear in the same module as the
      abstract base type.
      f4fc959c
    • Ivan Butygin's avatar
      [mlir][spirv] Remove `enableFastMathMode` flag from SPIR-V conversion (#86578) · f050a098
      Ivan Butygin authored
      Most of arith/math ops support fastmath attribute, use it instead of
      global flag.
      f050a098
    • smanna12's avatar
      [NFC][CLANG] Fix static analyzer bugs about unnecessary object copies with auto keyword (#85962) · 4c4ea249
      smanna12 authored
      Reported by Static Analyzer Tool:
      In clang::dataflow::Environment::initialize(): Using the auto keyword
      without an & causes the copy of an object of type LambdaCapture
      4c4ea249
    • Jonas Hahnfeld's avatar
      [unittests] Fix `TableGenTests` with `LLVM_LINK_LLVM_DYLIB` (#86664) · 81fc43a3
      Jonas Hahnfeld authored
      Since the restructuring in commit fa3d789d, the option
      DISABLE_LLVM_LINK_LLVM_DYLIB is counter-productive and leads to
      CommandLine Error: Option 'debug-counter' registered more than once!
      81fc43a3
    • Peter Klausler's avatar
      [flang][NFC] Address reported "possible missing return" (#86523) · f92f7752
      Peter Klausler authored
      A function uses "if constexpr" to consider all possible types in a
      variant, but looks as if it can fall out without returning an
      expression. Add a final "else" with a crash to make things more clear
      and to protect against unlikely future extensions of the type.
      
      Fixes https://github.com/llvm/llvm-project/issues/86391.
      f92f7752
    • Andrzej Warzyński's avatar
      [mlir][vector] Refactor linearize.mlir (#86648) · bf4fc00b
      Andrzej Warzyński authored
      This patch refactors the `linearize.mlir` test - currently it contains
      some duplication and can be tricky to follow.
      
      Summary of changes:
        * reduce duplication by introducing a shared check prefix (`ALL`) and
          by introducing `-check-prefixes`,
        * make sure that every "check" line is directly above the
          corresponding line of input MLIR,
        * group check lines corresponding to a particular prefix together (so
          that it's easier to see the expected output for a particular
          prefix),
        * remove `CHECK` from prefix names (with multiple prefixes that's just
          noise that can be avoided) and use a bit more descriptive prefixes
          instead (`CHECK0` -> `BW-0`, where `BW` stands for bitwidth),
        * unify indentation,
        * `nonvec_result` -> `test_tensor_no_linearize` (for consistency with
          `test_index_no_linearize`).
      
      NOTE: This change only updates the format of the "CHECK" lines and
      doesn't affect what's being tested.
      
      This change is intended as preparation for adding support for scalable
      vectors to `LinearizeConstant` and `LinearizeVectorizable` - i.e.
      patterns that `linearlize.mlir` is meant to test.
      bf4fc00b
    • Craig Topper's avatar
    • Peter Klausler's avatar
      [flang] Special-case handling of INTRINSIC in type-decl-stmt (#86518) · 8f01ecae
      Peter Klausler authored
      Fortran allows the INTRINSIC attribute to be specified with a distinct
      attribute statement, and also as part of the attribute list of a
      type-declaration-stmt. This is an odd case (especially as the declared
      type is mandated to be ignored if it doesn't match the type of the
      intrinsic function) that can lead to odd error messages and crashes,
      since the rest of name resolution expects that intrinsics with explicit
      declarations will have been declared with INTRINSIC attribute
      statements. Resolve by handling an "inline" INTRINSIC attribute as a
      special case while processing a type-declaration-stmt, so that
      
        real, intrinsic :: acos, asin, atan
      
      is processed exactly as if it had been
      
        intrinsic acos, asin, atan; real acos, asin, atan
      
      Fixes https://github.com/llvm/llvm-project/issues/86382.
      8f01ecae
    • smanna12's avatar
      [NFC][Clang] Fix potential dereferencing of nullptr (#85944) · e75989e9
      smanna12 authored
      This patch replaces getAs<> with castAs<> to resolve potential static
      analyzer bugs for
      
      1. Dereferencing a pointer issue with nullptr FPT when calling
      ResolveExceptionSpec() in
          checkEscapingByref(clang::VarDecl *, clang::Sema &).
      
      3. Dereferencing a pointer issue with nullptr ElementTy->getAs() when
      calling getElementType() in
      clang::Sema::SemaBuiltinFPClassification(clang::CallExpr *, unsigned
      int).
      
      4. Dereferencing a pointer issue with nullptr ConvType->getAs() when
      calling getKeyword() in
      clang::Sema::ActOnConversionDeclarator(clang::CXXConversionDecl *).
      e75989e9
    • Slava Zakharin's avatar
      [flang][runtime] Use cuda::std::variant in the CUDA build. (#86615) · 7860f970
      Slava Zakharin authored
      Added `FLANG_LIBCUDACXX_PATH` CMake variable to specify
      installation of header-only libcudacxx library.
      If it is specified, the `<cuda/std/variant>` is used to provide
      implementation of `std::variant`.
      7860f970
    • Farzon Lotfi's avatar
      [DXIL] Implement log intrinsic Lowering (#86569) · 5cf1e2e2
      Farzon Lotfi authored
      Completes #86192
      `DXIL.td` - add log2 to dxilop lowering
      `DXILIntrinsicExpansion.cpp` - add log and log10 to log2 expansions
      5cf1e2e2
    • Zahira Ammarguellat's avatar
    • Peter Klausler's avatar
      [flang] Catch non-constant targets for procedure pointer initialization (#86338) · 5a0382ce
      Peter Klausler authored
      Detect attempts to use non-constant targets, including internal
      procedures, as initializers for procedure pointers, including components
      of structure components being used as initializers.
      5a0382ce
    • Peter Klausler's avatar
      [flang][runtime] Runtime support for REDUCE() (#86214) · 3ada883f
      Peter Klausler authored
      Supports the REDUCE() transformational intrinsic function of Fortran
      (see F'2023 16.9.173) in a manner similar to the existing support for
      SUM(), PRODUCT(), &c. There are APIs for total reductions to scalar
      results, and APIs for partial reductions that reduce the rank of the
      argument by one.
      
      This implementation requires more functions than other reductions
      because the various possible types of the user-supplied OPERATION=
      function need to be elaborated.
      
      Once the basic API in reduce.h has been approved, later patches will
      implement lowering.
      
      REDUCE() is primarily for completeness, not portability; only one other
      Fortran compiler implements this F'2018 feature today, and only some
      types work correctly with it.
      3ada883f
    • Simon Pilgrim's avatar
      c8b85add
    • Simon Pilgrim's avatar
      [X86] extractelement-load.ll - use X86 instead of X32 check prefix. NFC · 3140d138
      Simon Pilgrim authored
      X32 should be used for gnux32 triples
      3140d138
    • Jonas Devlieghere's avatar
      [lldb] Fix warning: comparison of unsigned expression in >= 0 is always true · 348f9e73
      Jonas Devlieghere authored
      lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp:1195:15: warning:
      comparison of unsigned expression in ‘>= 0’ is always true
       1195 |   if (weekday >= 0 && weekday < 7)
            |       ~~~~~~~~^~~~
      348f9e73
    • Alfie Richards's avatar
      [ARM][MC] Add GNU Alias for ldrexd, ldaexd, stlexd, and strexd instructions (#86507) · 375ddd67
      Alfie Richards authored
      These aliases were supported previously there was a regression at some point.
      
      This adds back the alternate forms and tidies up this section of code a little.
      
      See https://github.com/llvm/llvm-project/pull/83436#issuecomment-2010213714 for the initial report regarding this change.
      375ddd67
    • Abhin P Jose's avatar
      Change type of DiagnosticHandlerTy (#86504) · 44d037cc
      Abhin P Jose authored
      Changing type of DiagnosticHandlerTy due to adding
      -Wcast-function-type-mismatch to -Wextra
      group(https://github.com/llvm/llvm-project/pull/86131#issuecomment-2018014179).
      Changed the reference argument DiagnosticInfo to a pointer and edited
      the test cases failing due to this change. Added another small change
      where Gtest api was throwing an warning due varargs argument not being
      passed.
      44d037cc
    • Jason Molenda's avatar
      [lldb] Don't clear a Module's UnwindTable when adding a SymbolFile (#86603) · 2f63718f
      Jason Molenda authored
      Fixing a crash in lldb when `symbols.auto-download` setting is enabled.
      When doing a backtrace, this feature has lldb search for a SymbolFile
      for stack frames when we are backtracing, and add them either
      synchoronously or asynchronously, depending on the specific setting
      used.
      
      Module::SetSymbolFileFileSpec clears the Module's UnwindTable, once we
      find a new SymbolFile. We may be adding a source of unwind information
      that we did not have when lldb was working only with the executable
      binary.
      
      What happens in practice is that we're using a reference to the Module's
      UnwindTable, and then the other thread getting the SymbolFile clears it
      and now the first thread is referring to freed memory and we can crash.
      When built with address sanitizer, it crashes much more reliably.
      
      Given that unwind information used for exception handling -- eh_frame,
      compact unwind -- is present in executable binaries, the only thing
      we're likely to *add* would be DWARF's `debug_frame` if that was also
      available. The actual value of re-creating the UnwindTable when we have
      added a SymbolFile is not large.
      
      I also tried fixing this by changing the Module to have a shared_ptr to
      the UnwindTable, so we could have two different UnwindTable's in use
      simultaneously for a brief period. This would be fine TODAY, but it
      introduces a very subtle bug that someone will have a heck of a time
      figuring out in the future.
      
      In the end, I believe the safest approach is to sacrifice the possible
      marginal gain of reconstructing the UnwindTable once a SymbolFile has
      been added, to sidestep this whole problem area.
      
      Also, in `Module::GetUnwindTable()`, call `DownloadSymbolFileAsync`
      before we create the UnwindTable for the first time, in case the symbol
      file is fetched synchronously, we will have it for that possible
      marginal gain.
      2f63718f
  2. Mar 26, 2024
    • Peter Klausler's avatar
      [flang] Fix crash in name resolution (#85835) · f50f0caf
      Peter Klausler authored
      ConvertToObjectEntity() returns true for use- and host-associated object
      symbols, too. Ensure in this case that the symbol really is a
      non-associated object.
      
      Fixes https://github.com/llvm/llvm-project/issues/85776.
      f50f0caf
    • Cyndy Ishida's avatar
      6d579cd1
    • Peter Klausler's avatar
      [flang] Accept more unrecognized !DIR$ compiler directives (#85829) · 6e261d9c
      Peter Klausler authored
      When encountering an unparsable !DIR$ compiler directive line, accept it
      as a whole source line and emit a warning that it is unrecognizable.
      
      Fixes https://github.com/llvm/llvm-project/issues/59107,
      https://github.com/llvm/llvm-project/issues/82212, and
      https://github.com/llvm/llvm-project/issues/82654.
      6e261d9c
    • Daniel Chen's avatar
      [Flang] Support for passing procedure pointer, reference to a function that... · 4998587e
      Daniel Chen authored
      [Flang] Support for passing procedure pointer, reference to a function that returns a procedure pointer to structure constructor. (#86533)
      
      This PR fixes `not yet implemented: procedure pointer component in
      structure constructor` as shown in the following test case.
      
      ```
        MODULE M
          TYPE :: DT
            PROCEDURE(Fun), POINTER, NOPASS :: pp1
          END TYPE
      
          CONTAINS
      
          INTEGER FUNCTION Fun(Arg)
          INTEGER :: Arg
            Fun = Arg
          END FUNCTION
      
        END MODULE
      
        PROGRAM MAIN
        USE M
        IMPLICIT NONE
        TYPE (DT) :: v2
        PROCEDURE(FUN), POINTER :: pp2
        v2 = DT(pp2)
        v2 = DT(bar())
        CONTAINS
          FUNCTION BAR() RESULT(res)
            PROCEDURE(FUN), POINTER :: res
          END
        END
        ```
      4998587e
    • Luke Lau's avatar
      [RISCV] Combine (mul (zext, zext)) -> (zext (mul (zext, zext))) (#86465) · 87519a28
      Luke Lau authored
      Building on #86248, we can also narrow the width of a mul of zexts.
      
      This is specifically legal because on RVV we always extend to the next
      power of 2 width, and multiplying two N bit integers produces a maximum
      value of 2\*N bits.
      So as long as we keep an inner zext of 2\*N, we will have enough space
      for the multiply and won't overflow.
      
      Alive2 proof: https://alive2.llvm.org/ce/z/XteYyb
      87519a28
    • Nick Desaulniers's avatar
      [libc][OSUtil] refactor quick_exit to be an object library everywhere (#85955) · ecfffbfd
      Nick Desaulniers authored
      The usage of __builtin_unreachable after calls to quick_exit were distressing.
      If a function is properly marked [[noreturn]] then __builtin_unreachable is not
      necessary.
      
      Looking into this further, we seem to have header only implementations for CPU
      targets. The inline nature of these functions is curious; we're going to exit,
      it doesn't matter if we need to pay the call of a function or not. If we just
      make these functions have distinct TUs rather than be header only, we can clean
      up the cmake rules for quick_exit which were different between CPU and GPU.
      
      Remove darwin support for quick_exit. This isn't being tested, and we can bring
      it back when necessary.
      ecfffbfd
    • Simon Pilgrim's avatar
      [X86] combineConcatVectorOps - concatenate FADD/FSUB/FMUL ops if we don't... · d18bee23
      Simon Pilgrim authored
      [X86] combineConcatVectorOps - concatenate FADD/FSUB/FMUL ops if we don't increase the number of INSERT_SUBVECTOR nodes.
      
      FADD/FSUB/FMUL are usually less port-bound than INSERT_SUBVECTOR, so only concatenate if it reduces the instruction count and doesn't introduce extra INSERT_SUBVECTOR nodes.
      d18bee23
    • Simon Pilgrim's avatar
      [X86] Add fadd/fsub/fmul tests showing failure to concat operands together and... · e933c05c
      Simon Pilgrim authored
      [X86] Add fadd/fsub/fmul tests showing failure to concat operands together and perform as a wider vector
      
      We don't want to concat fadd/fsub/fmul if both operands would need concatenating (as the fp op is usually cheaper than the concat), but if at least one operand is free to concat (i.e. constant or extracted from a wider vector), then we should try to concat the fp op.
      e933c05c
    • Florian Hahn's avatar
      [VPlan] Explicitly handle scalar pointer inductions. (#83068) · 06bb8c9f
      Florian Hahn authored
      Add a new PtrAdd opcode to VPInstruction that corresponds to
      IRBuilder::CreatePtrAdd, which creates a GEP with source element type
      i8.
      
      This is then used to model scalarizing VPWidenPointerInductionRecipe by
      introducing scalar-steps to model the index increment followed by a
      PtrAdd.
      
      Note that PtrAdd needs to be able to generate code for only the first
      lane or for all lanes. This may warrant introducing a separate recipe
      for scalarizing that can be created without relying on the underlying
      IR.
      
      Depends on https://github.com/llvm/llvm-project/pull/80271
      
      PR: https://github.com/llvm/llvm-project/pull/83068
      06bb8c9f
    • Rafael Ubal's avatar
      Fixes in 'tosa.reshape' lowering and folder (#85798) · 26d896f3
      Rafael Ubal authored
      - Revamped lowering conversion pattern for `tosa.reshape` to handle previously unsupported combinations of dynamic dimensions in input and output tensors. The lowering strategy continues to rely on pairs `tensor.collapse_shape` + `tensor.expand_shape`, which allow for downstream fusion with surrounding `linalg.generic` ops.
      
      - Fixed bug in canonicalization pattern `ReshapeOp::fold()` in `TosaCanonicalizations.cpp`. The input and result types being equal is not a sufficient condition for folding. If there is more than 1 dynamic dimension in the input and result types, a productive reshape could still occur.
      
      - This work exposed the fact that bufferization does not properly handle a `tensor.collapse_shape` op producing a 0D tensor from a dynamically shaped one due to a limitation in `memref.collapse_shape`. While the proper way to address this would involve releasing the `memref.collapse_shape` restriction and verifying correct bufferization, this is left as possible future work. For now, this scenario is avoided by casting the `tosa.reshape` input tensor to a static shape if necessary (see `inferReshapeInputType()`.
      
      - An extended set of tests are intended to cover relevant conversion paths. Tests are named using pattern `test_reshape_<rank>_{up|down|same}_{s2s|s2d|d2s|d2d}_{explicit|auto}[_empty][_identity]`, where:
      	
        - `<rank>` is the input rank (e.g., 3d, 6d)
        - `{up|down|same}` indicates whether the reshape increases, decreases, or retains the input rank.
        - `{s2s|s2d|d2s|d2d}` indicates whether reshape converts a statically shaped input to a statically shaped result (`s2s`), a statically shaped input to a dynamically shaped result (`s2d`), etc.
        - `{explicit|auto}` is used to indicate that all values in the `new_shape` attribute are >=0 (`explicit`) or that a -1 placeholder value is used (`auto`).
        - `empty` is used to indicate that `new_shape` includes a component set to 0.
        - `identity` is used when the input and result shapes are the same.
      26d896f3
    • Julian Nagele's avatar
      [TBAA] Tests for invalid tbaa.struct metadata (#86167) · 507e59aa
      Julian Nagele authored
      These tests show invalid tbaa.struct metadata that is currently accepted
      in preparation for a change to the IR Verifier that will then reject it.
      
      PR: https://github.com/llvm/llvm-project/pull/86167
      507e59aa
    • Akira Hatanaka's avatar
      Revert "[CodeGen][arm64e] Add methods and data members to Address, which are... · b3117564
      Akira Hatanaka authored
      Revert "[CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (#67454)" (#86674)
      
      This reverts commit 8bd1f911.
      
      It appears that the commit broke msan bots.
      b3117564
    • Stefan Gränitz's avatar
      [clang-repl] Fix remove invalidates iterators in CleanUpPTU() (#85378) · 2e38c50e
      Stefan Gränitz authored
      Using remove() on DeclContext::lookup_result list invalidates iterators.
      
      This assertion failure was one (fortunate) symptom:
      ```
      clang/include/clang/AST/DeclBase.h:1337: reference clang::DeclListNode::iterator::operator*() const: Assertion `Ptr && "dereferencing end() iterator"' failed.
      ```
      2e38c50e
    • Christian Sigg's avatar
      [mlir][bazel] Create a separate target for BytecodeOpInterface. (#86655) · 89ef3130
      Christian Sigg authored
      This matches the CMake targets and reduces the number of headers that
      need to be included in multiple targets.
      89ef3130
    • Tim Creech's avatar
      Update documentation and release notes for llvm-profgen COFF support (#84864) · ca594fed
      Tim Creech authored
      This change:
      - Updates the existing Clang User's Manual section on SPGO so that it
      describes how to use llvm-profgen to perform SPGO on Windows. This is
      new functionality implemented in #83972.
      - Fixes a minor typo in the existing llvm-profgen invocation example.
      - Adds an LLVM release note on this new functionality in llvm-profgen.
      ca594fed
    • Carlos Seo's avatar
      [Flang] Add new CHECK_MSG() function (#86576) · a51d13f5
      Carlos Seo authored
      Added a new variant of the CHECK() function that takes a custom message
      as a parameter. This is useful for more meaninful error messages when
      the compiler is expected to crash.
      
      Fixes #78931
      a51d13f5