1. Jul 18, 2023
    • Nikita Popov's avatar
      [OpenMPIRBuilder] Check GV type instead of pointee type (NFC) · 8db30225
      Nikita Popov authored
      Change the assertion to check the value type instead of the pointee
      type. To facilitate this, store GlobalVariable* instead of Constant*
      in the map.
      8db30225
    • Kiran Chandramohan's avatar
      [Flang][HLFIR] Intrinsics: Propagate fast math flags · fe705c34
      Kiran Chandramohan authored
      Add a new FirOpBuilder constructor to propagate the fast math flag
      from an operation. Use this constructor in the LowerHLFIRIntrinsics
      pass.
      
      This fixes the performance issue with the hlfir intrinsics flow
      for polyhedron/test_fpu2.
      
      Reviewed By: tblah, vzakhari
      
      Differential Revision: https://reviews.llvm.org/D155438
      fe705c34
    • Kiran Chandramohan's avatar
      [Flang][HLFIR] Relax size check for dot_product intrinsic · 41f478f0
      Kiran Chandramohan authored
      If the size of one of the operand arrays is not known at compile
      time, do not issue a size mismatch error sinc they could match at
      runtime.
      
      Fixes the compilation error in polyhedron/induct2.
      
      Reviewed By: tblah, vzakhari
      
      Differential Revision: https://reviews.llvm.org/D155302
      41f478f0
    • Nikita Popov's avatar
    • ManuelJBrito's avatar
      [NewGVN] Abort PHIOfOps if singleton PHI is found · 29b5666f
      ManuelJBrito authored
      Currently we just bypass singleton phis, however we know that
      in order to create the phi of ops all phis must be in the same block.
      Therefore if one phi is a singleton then the rest are as well.
      
      Differential Revision: https://reviews.llvm.org/D155478
      29b5666f
    • Nikita Popov's avatar
      [LowerMatrixIntrinsics] Fix test expectations (NFC) · bc39a7a5
      Nikita Popov authored
      Some of the test expectation were incorrectly changed in
      23c21759. Regenerate the tests.
      bc39a7a5
    • Nikita Popov's avatar
    • dingfei's avatar
      [clang-extdef-mapping] register necessary targest for ms-style asm block · 2c651184
      dingfei authored
      Without targets registered gives: "error: MS-style inline assembly is not
      available: Unable to find target for this triple (no targets are registered)"
      
      Differential Revision: https://reviews.llvm.org/D154983
      2c651184
    • dingfei's avatar
      [ASTImporter] Fields are imported first and reordered for correct layout · e9536698
      dingfei authored
      Fields are imported first and reordered for correct layout.
      For partially imported record, layout computation is incorrect.
      
      Differential Revision: https://reviews.llvm.org/D154764
      e9536698
    • Nikita Popov's avatar
      3be16bd7
    • Nuno Lopes's avatar
      [LowerMatrixIntrinsics] Use poison instead of undef as placeholder [NFC] · 23c21759
      Nuno Lopes authored
      These values don't propagate to the output; they are always replaced with a subsequent shuffle
      or insertelement.
      Tested equivalence with Alive2, e.g., https://alive2.llvm.org/ce/z/fj4s78.
      23c21759
    • Weining Lu's avatar
      [LoongArch] Change 'using namespace llvm;' to 'namespace llvm {' in LoongArchTargetParser.cpp. NFC · 58632146
      Weining Lu authored
      And change 'using namespace llvm::LoongArch' to 'namespace LoongArch {'
      to simplify the code a little bit.
      58632146
    • Weining Lu's avatar
    • Cullen Rhodes's avatar
      [mlir][ArmSME] Implement tile allocation · fb54fec7
      Cullen Rhodes authored
      This patch adds a pass '-allocate-sme-tiles' to the ArmSME dialect that
      implements allocation of SME ZA tiles.
      
      It does this at the 'func.func' op level by replacing
      'arm_sme.get_tile_id' ops with 'arith.constant' ops that represent the
      tile number. The tiles in use in a given function are tracked by an
      integer function attribute 'arm_sme.tiles_in_use' that is a 16-bit tile
      mask with a bit for each 128-bit element tile (ZA0.Q-ZA15.Q), the
      smallest ZA tile granule. This is initialized on the first
      'arm_sme.get_tile_id' rewrite and updated on each subsequent rewrite.
      Mixing of different element tile types is supported.
      
      Section B2.3.2 of the SME spec [1] describes how the 128-bit element
      tiles overlap with other element tiles.
      
      Depends on D154941
      
      [1] https://developer.arm.com/documentation/ddi0616/aa
      
      Reviewed By: awarzynski
      
      Differential Revision: https://reviews.llvm.org/D154955
      fb54fec7
    • Nikita Popov's avatar
      Reapply [InstSimplify] Make simplifyWithOpReplaced() recursive (PR63104) · 0db5d8e1
      Nikita Popov authored
      A similar assumption as for the x^x case also existed for the absorber
      case, which lead to a stage2 miscompile. That assumption is not fixed.
      
      -----
      
      Support replacement of operands not only in the immediate
      instruction, but also instructions it uses.
      
      To the most part, this extension is straightforward, but there are
      two bits worth highlighting:
      
      First, we can now no longer assume that if the Op is a vector, the
      instruction also returns a vector. If Op is a vector and the
      instruction returns a scalar, we should consider it as a cross-lane
      operation.
      
      Second, for the x ^ x special case and the absorber special case, we
      can no longer assume that one of the operands is RepOp, as we might
      have a replacement higher up the instruction chain.
      
      There is one optimization regression, but it is in a fuzzer-generated
      test case.
      
      Fixes https://github.com/llvm/llvm-project/issues/63104.
      0db5d8e1
    • dingfei's avatar
      [ASTImporter] Fix 'isVirtual()' assert failure while import overridden methods · 5b99aa57
      dingfei authored
      CXXMethodDecl::isVirtual() count the number of overridden methods.
      This assertion is not true before overridden methods are fully loaded.
      The body of this CXXMethodDecl can introduce deps on a derived class
      which contains a method overriding this method, causing the assertion failure.
      
      ImportOverriddenMethods() is moved before body loading to fix this issue.
      
      Testcase is contributed by Balázs Kéri (balazske)
      
      Differential Revision: https://reviews.llvm.org/D154701
      5b99aa57
    • Jens Massberg's avatar
      [clangd][c++20] Add concept Hover tests. · e9ab43dd
      Jens Massberg authored
      Concepts aren't fully supporteb by hover yet. For the currently
      supported case we add a test here to prevent regressions in the future.
      
      Differential Revision: https://reviews.llvm.org/D155558
      e9ab43dd
    • Pavel Labath's avatar
      [lldb/test] Fix command-disassemble-mixed.c · b71ac7ee
      Pavel Labath authored
      Add it to lit.local.cfg so that it's actually run, and change it to
      (properly) use the %clang_host substitution.
      b71ac7ee
    • Nikita Popov's avatar
    • Andrzej Warzynski's avatar
      [mlir][ArmSME] Introduce new lowering layer (Vector -> ArmSME) · 447bb5be
      Andrzej Warzynski authored
      At the moment, the lowering from the Vector dialect to SME looks like
      this:
      
        * Vector --> SME LLVM IR intrinsics
      
      This patch introduces a new lowering layer between the Vector dialect
      and the Arm SME extension:
      
        * Vector --> ArmSME dialect (custom Ops) --> SME LLVM IR intrinsics.
      
      This is motivated by 2 considerations:
      1. Storing `ZA` to memory (e.g. `vector.transfer_write`) requires an
         `scf.for` loop over all rows of `ZA`. Similar logic will apply to
         "load to ZA from memory". This is a rather complex transformation and
         a custom Op seems justified.
      2. As discussed in [1], we need to prevent the LLVM type converter from
         having to convert types unsupported in LLVM, e.g.
         `vector<[16]x[16]xi8>`. A dedicated abstraction layer with custom Ops
         opens a path to some fine tuning (e.g. custom type converters) that
         will allow us to avoid this.
      
      To facilitate this change, two new custom SME Op are introduced:
      
        * `TileStoreOp`, an...
      447bb5be
    • WANG Xuerui's avatar
      [LoongArch][NFC] Consistently derive instruction mnemonics from TableGen record names · 294bee10
      WANG Xuerui authored
      The recent D154183 and D154195 have introduced a simpler way to specify
      instruction mnemonics: by leveraging TableGen's `NAME` and string
      processing features, the mnemonics can be automatically derived from the
      respective TableGen record names. LoongArch instructions don't have
      "strange" characters in their names, so this approach can be applied to
      all the other instructions.
      
      A `deriveInsnMnemonic` helper class, modeled after the LSX/LASX mnemonic
      derivation logic, has been added, and all non-pseudo instruction formats
      are converted to use it, losing their `opstr/opcstr` arguments in the
      process.
      
      There are minor differences that are worth mentioning though:
      
      * The atomic instructions with implicit data barriers have an underscore
        (`_`) in their mnemonics, that will get converted to a period (`.`) if
        not specially handled. Double-underscore (`__`) in record names are
        converted to a single underscore in the resulting mnemonic; the
        definitions are tweaked accordingly.
      * Various duplicated FP instructions need special handling, mainly
        because of the need to handle both FPR32 and FPR64 classes for a
        single hardware instruction. The substrings `_xS`, `_xD` and `_64` are
        additionally dropped before deriving FP instructions' mnemonics.
      
      All of these are pure refactoring, no functional change.
      
      Reviewed By: SixWeining
      
      Differential Revision: https://reviews.llvm.org/D154916
      294bee10
    • Cullen Rhodes's avatar
      [mlir][ArmSME] Add custom get_tile_id and cast ops · 6ff9761a
      Cullen Rhodes authored
      This patch adds three new custom ops to the ArmSME dialect:
      
        * arm_sme.get_tile_id - returns a scalar integer representing an SME
          "virtual tile" that is not in use.
        * arm_sme.cast_tile_to_vector - casts from a tile id to a 2-d scalable
          vector type, which represents an SME "virtual tile".
        * arm_sme.cast_vector_to_tile - casts from a 2-d scalable vector type,
          which represents an SME "virtual tile", to a tile id.
      
      The 'arm_sme.get_tile_id' op currently only supports tile 0, a follow-up
      patch will implement proper tile allocation. A further follow-up patch
      will demonstrate load/store to/from ZA using these ops.
      
      See the op descriptions for further details and examples.
      
      Thanks to @paulwalker-arm and @awarzynski for helping drive this.
      
      Reviewed By: awarzynski, dcaballe
      
      Differential Revision: https://reviews.llvm.org/D154941
      6ff9761a
    • Martin Erhart's avatar
      [mlir][bufferization] Add DeallocOp · d5825621
      Martin Erhart authored
      The dealloc operation deallocates each of the given memrefs if there is no alias
      to that memref in the list of retained memrefs and the corresponding
      condition value is set. This condition can be used to indicate and pass on
      ownership of memref values (or in other words, the responsibility of
      deallocating that memref). If two memrefs alias each other, only one will be
      deallocated to avoid double free situations.
      
      The memrefs to be deallocated must be the originally allocated memrefs,
      however, the memrefs to be retained may be arbitrary memrefs.
      
      Returns a list of conditions corresponding to the list of memrefs which
      indicates the new ownerships, i.e., if the memref was deallocated the
      ownership was dropped (set to 'false') and otherwise will be the same as the
      input condition.
      
      Differential Revision: https://reviews.llvm.org/D155467
      d5825621
    • Balázs Kéri's avatar
      [clang][analyzer] Add all success/failure messages to StdLibraryFunctionsChecker. · 6dccf5b8
      Balázs Kéri authored
      Success or failure messages are now shown at all checked functions, if the call
      (return value) is interesting.
      Additionally new functions are added: open, openat, socket, shutdown
      
      Reviewed By: donat.nagy
      
      Differential Revision: https://reviews.llvm.org/D154423
      6dccf5b8
    • Balázs Kéri's avatar
      [clang][analyzer] Display notes in StdLibraryFunctionsChecker only if interesting · f12808ab
      Balázs Kéri authored
      The note tag that was previously added in all cases when a standard function call
      is found is displayed now only if the function call (return value) is "interesting".
      This results in less unneeded notes but some of the previously good notes disappear
      too. This is because interestingness is not always set as it should be.
      
      Reviewed By: donat.nagy
      
      Differential Revision: https://reviews.llvm.org/D153776
      f12808ab
    • Balázs Kéri's avatar
      [clang][analyzer] Add and change NoteTags in StdLibraryFunctionsChecker. · 39670ae3
      Balázs Kéri authored
      Change 1: ErrnoChecker notes show only messages related to errno,
      not to assumption of success or failure of functions.
      Change 2: StdLibraryFunctionsChecker adds its own note about success
      or failure of functions, and the errno related note, independently.
      Change 3: Every modeled function in StdLibraryFunctionsChecker
      should have a note tag message in all "cases". This is not implemented yet,
      only for file (stream) related functions.
      
      Reviewed By: donat.nagy
      
      Differential Revision: https://reviews.llvm.org/D153612
      39670ae3
    • David Green's avatar
      [AArch64] Regenerate a couple of mir GlobalISel tests. NFC · 4214f156
      David Green authored
      See D155311
      4214f156
    • Fangrui Song's avatar
      [lld][test] Remove unused features · 6a00e709
      Fangrui Song authored
      "system-linker-elf" and "demangler" have been unused since
      lld/test/old-elf/ was removed in 2016.
      6a00e709
    • LiaoChunyu's avatar
      [RISCV] Lower VP_CTLZ_ZERO_UNDEF/VP_CTTZ_ZERO_UNDEF/VP_CTLZ by converting to... · 65ffcc09
      LiaoChunyu authored
      [RISCV] Lower VP_CTLZ_ZERO_UNDEF/VP_CTTZ_ZERO_UNDEF/VP_CTLZ by converting to FP and extracting the exponent.
      
      D111904, D141585 made RISC-V customized lower vector ISD::CTLZ_ZERO_UNDEF/CTTZ_ZERO_UNDEF/CTLZ
      by converting to float and using the float result.
      
      Perhaps VP_CTLZ_ZERO_UNDEF/VP_CTTZ_ZERO_UNDEF/VP_CTLZ could use the similar feature.
      
      Reviewed By: craig.topper
      
      Differential Revision: https://reviews.llvm.org/D155150
      65ffcc09
    • Mikhail Goncharov's avatar
      [bazel] fix build of ArithUtils · d18ce731
      Mikhail Goncharov authored
      d18ce731
    • Balazs Benics's avatar
      [ADT] Remove SFINAE constraint from llvm::iterator_range ctor for gcc-7 · 497953b4
      Balazs Benics authored
      It turns out the SFINAE constraint breaks building MLIR using GCC-7,
      which is an outdated, but supported compiler by llvm-project.
      
      I tried to find a solution for fixing it, but I decided to cut branches
      and just simply remove the SFINAE constraint until we drop GCC-7.
      It was originally introduced by D152891.
      
      Allegedly, GCC-8 and above builds just fine.
      I tested GCC 8.4.0, and GCC 7.5.0, and now builds fine on both.
      
      Differential Revision: https://reviews.llvm.org/D155441
      
      Fixes https://github.com/llvm/llvm-project/issues/63843
      497953b4
    • Amir Bishara's avatar
      [mlir][cmake] Comment out redundant static assert regarding VarInfo struct · 1ad009ad
      Amir Bishara authored
      Reviewed By: aartbik
      
      Differential Revision: https://reviews.llvm.org/D154940
      1ad009ad
    • Andrzej Warzynski's avatar
      [mlir][SparseTensor][ArmSVE] Conditionally disable SVE RUN line · aa9a10ac
      Andrzej Warzynski authored
      This patch updates one SparseTensor integration test so that the VLA
      vectorisation is run conditionally based on the value of the
      MLIR_RUN_ARM_SME_TESTS CMake variable.
      
      This change opens the path to reduce the duplication of RUN lines in
      "mlir/test/Integration/Dialect/SparseTensor/CPU/". ATM, there are
      usually 2 RUN lines to test vectorization in SparseTensor integration
      tests:
        * one for VLS vectorisation,
        * one for VLA vectorisation whenever that's available and which
          reduces to VLS vectorisation when VLA is not supported.
      When VLA is not available, VLS vectorisation is verified twice. This
      duplication should be avoided - integration test are relatively
      expansive to run.
      
      This patch makes sure that the 2nd vectorisation RUN line becomes:
      ```
        if (SVE integration tests are enabled)
          run VLA vectorisation
        else
          return
      ```
      This logic is implemented using LIT's (relatively new) conditional
      substitution [1]. It enables us to guarantee that all RUN lines are
      unique and that the VLA vectorisation is only enabled when supported.
      
      This patch updates only 1 test to set-up and to demonstrate the logic.
      Subsequent patches will update the remaining tests.
      
      [1] https://www.llvm.org/docs/TestingGuide.html
      
      Differential Revision: https://reviews.llvm.org/D155403
      aa9a10ac
    • Tomasz Kamiński's avatar
      [analyzer] Bind return value for assigment and copies of trivial empty classes · 61760bb9
      Tomasz Kamiński authored
      We now properly bind return value of the trivial copy constructor
      and assignments of the empty objects. Such operations do not
      perform any loads from the source, however they preserve identity
      of the assigned object:
      ```
      Empty e;
      auto& x = (e = Empty());
      clang_analyzer_dump(x); // &e, was Unknown
      ```
      
      Reviewed By: xazax.hun
      
      Differential Revision: https://reviews.llvm.org/D155442
      61760bb9
    • Sameer Sahasrabuddhe's avatar
      [llvm] minor cleanup in GenericSSAContext · ef7d5373
      Sameer Sahasrabuddhe authored
      - update comments to reflect actual state
      - use (implicitly inline) constexpr for a const static member
      ef7d5373
    • Itay Bookstein's avatar
      [CodeGen] Constify changeTypeToInteger · 0e326d04
      Itay Bookstein authored
      
      
      Surrounding methods are const, seems to be an oversight.
      
      Signed-off-by: default avatarItay Bookstein <itay.bookstein@nextsilicon.com>
      
      Reviewed By: bogner
      
      Differential Revision: https://reviews.llvm.org/D155505
      0e326d04
    • Johannes Doerfert's avatar
      [Attributor][FIX] Initialize variable. · dae52dd0
      Johannes Doerfert authored
      dae52dd0
    • tomasz-kaminski-sonarsource's avatar
      [analyzer] Rework support for CFGScopeBegin, CFGScopeEnd, CFGLifetime elements · d937836e
      tomasz-kaminski-sonarsource authored
      This patch reworks generation for the `CFGScopeBegin`, `CFGScopeEnd`,
      and `CFGLiftimeEnd`, in a way that they are now compatible with each
      other and `CFGAutomaticObjDtor`. All of the above elements are now
      generated by a single code path, that conditionally inserts elements if
      they are requested.
      
      In addition, the handling of `goto` statements is improved.
      The `goto` statement may leave multiple scopes (and trigger destruction
      and lifetime end for the affected variables) and enter multiple scopes,
      for example:
      ```lang=C++
      {
        int s1;
        {
          int s2;
          goto label; // leaves s1, s2, and enters t1 t1
        }
      }
      {
        int t1;
        {
          int t2;
      label:
        }
      }
      ```
      This is performed by first determining the shared parent scope of the
      source and destination. And then emitting elements for exiting each
      scope between the source and the parent, and entering each scope
      between the parent and destination. All such elements are appended
      to the source block, as one label may be reached from multiple scopes.
      
      Finally, the approach for handling backward jumps is changed. When
      connecting a source block to a destination block that requires the
      insertion of additional elements, we put this element into a new block,
      which is then linked between the source and the destination block.
      For example:
      ```lang=C++
      {
        int t;
      label:
        // Destination block referred to as 'DB'
      }
      {
        // Source block referred to as 'SB'
        Obj s;
        goto label;
      }
      ```
      
      The jump between `SB` with terminator `T: goto` and `DB` should be
      coupled with the following CFG elements:
      ```
      CFGAutomaticObjDtor(s)
      CFGLifetimeEnd(s)
      CFGScopeEnd(s)
      CFGScopeBegin(t)
      ```
      
      To handle such situations, we create a new link (`LB`) that is linked as
      the predecessor of `DB`, to which we transfer the terminator (`goto`
      statement) of `SB`. Then `LB` is handled in the same manner as the
      source block in the case of forward jumps.
      This produces CFG that looks like this:
      ```
      SB -> LB (T: goto) -> DB
      ```
      
      Finally, the resulting block is linked as the successor of `SB`. Such an
      approach uses existing handling of the `noreturn` destructors.
      As a reminder, for each destructor of an automatic object that is
      marked as `noreturn`, a new `noreturn` block (marked `NBn`) is
      created, at the destructor is inserted at the end of it.
      To illustrate, given two `noreturn` destructors, we will have:
      ```
      SB -> NB1 (noreturn)
      NB2 (noreturn)
      LB (T:goto) -> DB
      ```
      
      Reviewed By: ymandel, steakhal
      
      Differential Revision: https://reviews.llvm.org/D153273
      d937836e
    • Fangrui Song's avatar
      [lit] Remove unreachable @ expansion code · 2306f898
      Fangrui Song authored
      ArgumentParser expands @ (fromfile_prefix_chars) by default, so the
      expansion code path is unused.
      2306f898
    • Charlie Barto's avatar
      [sanitizer][asan][win] Intercept _strdup on Windows instead of strdup · 31263211
      Charlie Barto authored
      Intercept `_strdup` on windows, instead of the nonexistent `strdup`.
      31263211