1. Aug 25, 2022
    • Jeff Niu's avatar
      [mlir] Remove the element type enum from DenseArrayAttr · 444683a9
      Jeff Niu authored
      The element type enum is not needed to differentiate dense array kinds
      because the element type of the shaped type can be used instead.
      
      Reviewed By: mehdi_amini, rriddle
      
      Differential Revision: https://reviews.llvm.org/D132535
      444683a9
    • Fabian Parzefall's avatar
      [BOLT] Towards FunctionLayout const-correctness · d5c03def
      Fabian Parzefall authored
      A const-qualified reference to function layout allows accessing
      non-const qualified basic blocks on a const-qualified function. This
      patch adds or removes const-qualifiers where necessary to indicate where
      basic blocks are used in a non-const manner.
      
      Reviewed By: rafauler
      
      Differential Revision: https://reviews.llvm.org/D132049
      d5c03def
    • Usman Nadeem's avatar
      [AArch64][DAGCombine] Fix a bug in performBuildVectorCombine where it could... · 46768052
      Usman Nadeem authored
      [AArch64][DAGCombine] Fix a bug in performBuildVectorCombine where it could produce an invalid EXTRACT_SUBVECTOR
      
      EXTRACT_SUBVECTOR requires that Idx be a constant multiple of ResultType's
      known minimum vector length.
      
      Something like this will produce an invalid extract_subvector:
      
      t1: v4i16 = .....
      t2: i32 = extract_vector_elt t1, Constant:i64<1>
      t3: i32 = extract_vector_elt t1, Constant:i64<2>
      t4: v2i32 = BUILD_VECTOR t2, t3
      // produces
      t5: v2i32 = extract_subvector t...., Constant:i64<1>
      
      Differential Revision: https://reviews.llvm.org/D132517
      
      Change-Id: I7a5acf054edee3e89c0f85a28d8869256403ce08
      46768052
    • Mircea Trofin's avatar
      [mlgo] Use TFLite for 'development' mode. · 5ce4c9aa
      Mircea Trofin authored
      TLite is a lightweight, statically linkable[1], model evaluator, supporting a
      subset of what the full tensorflow library does, sufficient for the
      types of scenarios we envision having. It is also faster.
      
      We still use saved models as "source of truth" - 'release' mode's AOT
      starts from a saved model; and the ML training side operates in terms of
      saved models.
      
      Using TFLite solves the following problems compared to using the full TF
      C API:
      
      - a compiler-friendly implementation for runtime-loadable (as opposed
        to AOT-embedded) models: it's statically linked; it can be built via
        cmake;
      - solves an issue we had when building the compiler with both AOT and
        full TF C API support, whereby, due to a packaging issue on the TF
        side, we needed to have the pip package and the TF C API library at
        the same version. We have no such constraints now.
      
      The main liability is it supporting a subset of what the full TF
      framework does. We do not expect that to cause an issue, but should that
      be the case, we can always revert back to using the full framework
      (after also figuring out a way to address the problems that motivated
      the move to TFLite).
      
      Details:
      
      This change switches the development mode to TFLite. Models are still
      expected to be placed in a directory - i.e. the parameters to clang
      don't change; what changes is the directory content: we still need
      an `output_spec.json` file; but instead of the saved_model protobuf and
      the `variables` directory, we now just have one file, `model.tflite`.
      
      The change includes a utility showing how to take a saved model and
      convert it to TFLite, which it uses for testing.
      
      The full TF implementation can still be built (not side-by-side). We
      intend to remove it shortly, after patching downstream dependencies. The
      build behavior, however, prioritizes TFLite - i.e. trying to enable both
      full TF C API and TFLite will just pick TFLite.
      
      [1] thanks to @petrhosek's changes to TFLite's cmake support and its deps!
      5ce4c9aa
    • Zequan Wu's avatar
      [LLDB] Clean up after command fails · b6d56dda
      Zequan Wu authored
      `CommandObject::CheckRequirements()` requires m_exe_ctx being cleaned up.
      
      Differential Revision: https://reviews.llvm.org/D132397
      b6d56dda
    • Philip Reames's avatar
      [RISCV] Remove cttz/ctlz cost model coverage for the moment · 0473ac88
      Philip Reames authored
      I'd used the wrong signatures for these as I had not remembered we'd added the second boolean argument.  We appear to still parse the old form just fine, but we should use the two argument form in test since that's what the LangRef actually describes.
      0473ac88
    • Akira Hatanaka's avatar
      [compiler-rt][builtins] Add compiler flags to catch potential errors · e1dcd4ba
      Akira Hatanaka authored
      that can lead to security vulnerabilities
      
      Also, fix a few places that were causing -Wshadow and
      -Wformat-nonliteral warnings to be emitted.
      
      This reapplies the patch that was reverted in 0d66dc57 because it
      broke a few bots.
      
      I made changes so that cmake checks whether some of the flags are
      supported by the compiler that is used before adding them to the list.
      Also, I moved function add_security_warnings to CompilerRTUtils.cmake so
      that it is defined before it's used.
      
      Differential Revision: https://reviews.llvm.org/D131714
      e1dcd4ba
    • Sami Tolvanen's avatar
      KCFI sanitizer · cff5bef9
      Sami Tolvanen authored
      The KCFI sanitizer, enabled with `-fsanitize=kcfi`, implements a
      forward-edge control flow integrity scheme for indirect calls. It
      uses a !kcfi_type metadata node to attach a type identifier for each
      function and injects verification code before indirect calls.
      
      Unlike the current CFI schemes implemented in LLVM, KCFI does not
      require LTO, does not alter function references to point to a jump
      table, and never breaks function address equality. KCFI is intended
      to be used in low-level code, such as operating system kernels,
      where the existing schemes can cause undue complications because
      of the aforementioned properties. However, unlike the existing
      schemes, KCFI is limited to validating only function pointers and is
      not compatible with executable-only memory.
      
      KCFI does not provide runtime support, but always traps when a
      type mismatch is encountered. Users of the scheme are expected
      to handle the trap. With `-fsanitize=kcfi`, Clang emits a `kcfi`
      operand bundle to indirect calls, and LLVM lowers this to a
      known architecture-specific sequence of instructions for each
      callsite to make runtime patching easier for users who require this
      functionality.
      
      A KCFI type identifier is a 32-bit constant produced by taking the
      lower half of xxHash64 from a C++ mangled typename. If a program
      contains indirect calls to assembly functions, they must be
      manually annotated with the expected type identifiers to prevent
      errors. To make this easier, Clang generates a weak SHN_ABS
      `__kcfi_typeid_<function>` symbol for each address-taken function
      declaration, which can be used to annotate functions in assembly
      as long as at least one C translation unit linked into the program
      takes the function address. For example on AArch64, we might have
      the following code:
      
      ```
      .c:
        int f(void);
        int (*p)(void) = f;
        p();
      
      .s:
        .4byte __kcfi_typeid_f
        .global f
        f:
          ...
      ```
      
      Note that X86 uses a different preamble format for compatibility
      with Linux kernel tooling. See the comments in
      `X86AsmPrinter::emitKCFITypeId` for details.
      
      As users of KCFI may need to locate trap locations for binary
      validation and error handling, LLVM can additionally emit the
      locations of traps to a `.kcfi_traps` section.
      
      Similarly to other sanitizers, KCFI checking can be disabled for a
      function with a `no_sanitize("kcfi")` function attribute.
      
      Relands 67504c95 with a fix for
      32-bit builds.
      
      Reviewed By: nickdesaulniers, kees, joaomoreira, MaskRay
      
      Differential Revision: https://reviews.llvm.org/D119296
      cff5bef9
    • Philip Reames's avatar
      {RISCV] Backout cttz/ctlz instruction costs · 03798f26
      Philip Reames authored
      Craig points out correctly in post-commit review that these depend on the availability of floating point extensions.
      03798f26
    • Rob Suderman's avatar
      [mlir][tosa] Add constant folding for tosa.slice · 89d55513
      Rob Suderman authored
      If the input to a tosa.slice operation is a splat we can just replace with
      another splat. If the result is a single element, replacing with a splat
      is universally useful.
      
      Reviewed By: NatashaKnk
      
      Differential Revision: https://reviews.llvm.org/D132499
      89d55513
    • Craig Topper's avatar
      [RISCV] Pre-commit tests for D132614. NFC · ecde3036
      Craig Topper authored
      ecde3036
    • Jonathon Penix's avatar
      [Flang] Enable lowering of CONVERT specifier in OPEN statements · 15dc516e
      Jonathon Penix authored
      The runtime function was implemented and tested and the
      specifier was handled, but it seems lowering was never
      specifically added.
      
      Differential Revision: https://reviews.llvm.org/D131814
      15dc516e
    • Rob Suderman's avatar
      [mlir][tosa] Added folders for tosa.add · f5c8c9d5
      Rob Suderman authored
      Added folders for tosa.add that handles bypassing add-zero,
      fold additions of two splat tensors, and additions between
      two tensors with small values.
      
      Reviewed By: jpienaar
      
      Differential Revision: https://reviews.llvm.org/D132272
      f5c8c9d5
    • Philip Reames's avatar
      [RISCV] Add empirical costs for bswap/bitreverse/ctpop/ctlz/cttz · d4d6e71e
      Philip Reames authored
      If anyone is looking for a source of ideas on vector codegen improvements, the lowerings for several of these seem to include pretty obvious fixits.
      d4d6e71e
    • Philip Reames's avatar
    • Benjamin Kramer's avatar
      bbf19a67
    • Sanjay Patel's avatar
    • Daniel Bertalan's avatar
      [lld-macho][test] Check addresses in flat-namespace-interposable.s · 1b2d84a5
      Daniel Bertalan authored
      This test helped me catch an issue in my implementation of chained
      fixups (D132560). This commit makes the test more robust by checking if
      the bind opcodes are emitted for the correct address.
      
      Differential Revision: https://reviews.llvm.org/D132367
      1b2d84a5
    • Michael Kruse's avatar
      [flang] Fix msvc 17.3 build. · 71d80cd6
      Michael Kruse authored
      Compile fix for Microsoft Visual Studio 17.3 (msvc 14.33.31629) which regressed from 17.1.
      
      The compile error is:
      ```
      llvm-project\flang\lib\Evaluate\fold-integer.cpp(802,41): error C2672: 'invoke': no matching overloaded function found
      C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\type_traits(1552,19): message : could be 'unknown-type std::invoke(_Callable &&,_Ty1 &&,_Types2 &&...) noexcept(<expr>)'
      llvm-project\flang\lib\Evaluate\fold-integer.cpp(802,41): message : Failed to specialize function template 'unknown-type std::invoke(_Callable &&,_Ty1 &&,_Types2 &&...) noexcept(<expr>)'
      C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\type_traits(1552): message : see declaration of 'std::invoke'
      llvm-project\flang\lib\Evaluate\fold-integer.cpp(490,1): message : With the following template arguments:
      llvm-project\flang\lib\Evaluate\fold-integer.cpp(490,1): message : '_Callable=int (__cdecl Fortran::evaluate::value::Integer<16,true,16,unsigned short,unsigned int>::* &)(void) const'
      llvm-project\flang\lib\Evaluate\fold-integer.cpp(490,1): message : '_Ty1=const Fortran::evaluate::value::Integer<8,true,8,unsigned char,unsigned short> &'
      llvm-project\flang\lib\Evaluate\fold-integer.cpp(490,1): message : '_Types2={}'
      C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\type_traits(1546,19): message : or       'unknown-type std::invoke(_Callable &&) noexcept(<expr>)'
      C:\Users\meinersbur\src\llvm-project\flang\lib\Evaluate\fold-integer.cpp(802,41): message : 'unknown-type std::invoke(_Callable &&) noexcept(<expr>)': expects 1 arguments - 2 provided
      ```
      
      For some reason, msvc thinks that the lambda argument is `Scalar<T>` instead of `Scalar<TI>` as declared. This only happens in nested closures, using a lambda without `[]` arguments makes the problem disappear. Using `auto` instead to automatically derive the type fixes the problem.
      
      I recently updated the version of Visual Studio on [[ https://lab.llvm.org/buildbot/#/builders/172 | flang-x86_64-windows buildbot  ]] which since then fails because of this problem. It occasionally failed with 'fatal error C1001: Internal compiler error." internal error which I hoped to fix with an update.
      
      Reviewed By: klausler
      
      Differential Revision: https://reviews.llvm.org/D132594
      71d80cd6
    • Pirama Arumuga Nainar's avatar
      [lldb] Remove obsolete Android-specific definitions · ee9d52a2
      Pirama Arumuga Nainar authored
      Bionic's <sys/procfs.h> defines the necessary symbols.  Remove the
      specialization for Android and the now-unnecessary include of
      <sys/ptrace.h>.  This also helps resolve issues when building the
      x86/x86_64 lldb-server for Android.
      
      Curiously, the default branch to include <sys/procfs.h> doesn't seem
      necessary on Linux.  I'll remove it and add it back if it breaks other
      builders.
      
      Differential Revision: https://reviews.llvm.org/D132514
      ee9d52a2
    • LLVM GN Syncbot's avatar
      [gn build] Port 91389000 · fafc6f99
      LLVM GN Syncbot authored
      fafc6f99
    • Adrian Vogelsgesang's avatar
      [LLDB] Add data formatter for std::coroutine_handle · 91389000
      Adrian Vogelsgesang authored
      This patch adds a formatter for `std::coroutine_handle`, both for libc++
      and libstdc++. For the type-erased `coroutine_handle<>`, it shows the
      `resume` and `destroy` function pointers. For a non-type-erased
      `coroutine_handle<promise_type>` it also shows the `promise` value.
      
      With this change, executing the `v t` command on the example from
      https://clang.llvm.org/docs/DebuggingCoroutines.html now outputs
      
      ```
      (task) t = {
        handle = coro frame = 0x55555555b2a0 {
          resume = 0x0000555555555a10 (a.out`coro_task(int, int) at llvm-example.cpp:36)
          destroy = 0x0000555555556090 (a.out`coro_task(int, int) at llvm-example.cpp:36)
        }
      }
      ```
      
      instead of just
      
      ```
      (task) t = {
        handle = {
          __handle_ = 0x55555555b2a0
        }
      }
      ```
      
      Note, how the symbols for the `resume` and `destroy` function pointer
      reveal which coroutine is stored inside the `std::coroutine_handle`.
      A follow-up commit will use this fact to infer the coroutine's promise
      type and the representation of its internal coroutine state based on
      the `resume` and `destroy` pointers.
      
      The same formatter is used for both libc++ and libstdc++. It would
      also work for MSVC's standard library, however it is not registered
      for MSVC, given that lldb does not provide pretty printers for other
      MSVC types, either.
      
      The formatter is in a newly added  `Coroutines.{h,cpp}` file because there
      does not seem to be an already existing place where we could share
      formatters across libc++ and libstdc++. Also, I expect this code to grow
      as we improve debugging experience for coroutines further.
      
      **Testing**
      
      * Added API test
      
      Differential Revision: https://reviews.llvm.org/D132415
      91389000
    • Jan Svoboda's avatar
      [clang][modules] Consider M affecting after mapping M.Private to M_Private · 94e64df5
      Jan Svoboda authored
      When Clang encounters `@import M.Private` during implicit build, it precompiles module `M` and looks through its submodules. If the `Private` submodule is not found, Clang assumes `@import M_Private`. In the dependency scanner, we don't capture the dependency on `M`, since it's not imported. It's an affecting module, though: compilation of the import statement will fail when implicit modules are disabled and `M` is not precompiled and explicitly provided. This patch fixes that.
      
      Depends on D132430.
      
      Reviewed By: benlangmuir
      
      Differential Revision: https://reviews.llvm.org/D132502
      94e64df5
    • Philip Reames's avatar
    • Philip Reames's avatar
    • Uday Bondhugula's avatar
      [MLIR] Generalize/complete getEnclosingAffineForIfOps utility · 26fedf92
      Uday Bondhugula authored
      Rename/generalize getEnclosingAffineForIfOps -> getEnclosingAffineOps.
      The utility was originally written only for affine.for ops and then
      extended for affine.if as well. It wasn't however updated when
      affine.parallel was introduced -- in most cases, analysis has been used
      in the presence of affine.for/if but not post parallelization. Extend
      utility to also support affine.parallel ops; this allows future changes
      to enable affine analysis and opts in the presence of affine.parallel
      ops. Fix related stale comments.
      
      This is NFC for all use cases in tree.
      
      Change an associated assert to a utility failure.
      
      Reviewed By: ftynse
      
      Differential Revision: https://reviews.llvm.org/D132326
      26fedf92
    • Jonas Devlieghere's avatar
    • Philip Reames's avatar
      [RISCV] Add vector fabs intrinsic costs · 4d313486
      Philip Reames authored
      We have a fabs vector instruction, and are using it for current lowering.
      4d313486
    • V Donaldson's avatar
      [flang] Noncontiguous formats · 27d666b9
      V Donaldson authored
      Add the remaining pieces to support IO for noncontigous formats.
      This is done by passing an array descriptor to IO calls.  Scalar
      formats continue to pass string and length arguments.  IO calls
      with formats are modified to place the new format descriptor
      argument directly after the original string and length arguments.
      27d666b9
    • Ilia Diachkov's avatar
      [SPIRV] support builtin functions · f61eb416
      Ilia Diachkov authored
      The patch adds support for OpenCL and SPIR-V built-in functions.
      Their detection and properties are implemented using TableGen.
      Five tests are added to demonstrate the improvement.
      
      Differential Revision: https://reviews.llvm.org/D132024
      
      
      
      Co-authored-by: default avatarAleksandr Bezzubikov <zuban32s@gmail.com>
      Co-authored-by: default avatarMichal Paszkowski <michal.paszkowski@outlook.com>
      Co-authored-by: default avatarAndrey Tretyakov <andrey1.tretyakov@intel.com>
      Co-authored-by: default avatarKonrad Trifunovic <konrad.trifunovic@intel.com>
      f61eb416
    • Peter Cooper's avatar
    • Saleem Abdulrasool's avatar
      RISCV: permit unaligned nop-slide padding emission · 8f45b5a7
      Saleem Abdulrasool authored
      We may be requested to emit an unaligned nop sequence (e.g. 7-bytes or
      3-bytes).  These should be 0-filled even though that is not a valid
      instruction.  This matches the behaviour on other architectures like
      ARM, X86, and MIPS.  When a custom section is emitted, it may be
      classified as text even though it may be a data section or we may be
      emitting data into a text segment (e.g. a literal pool).  In such cases,
      we should be resilient to the emission request.
      
      This was originally identified by the Linux kernel build and reported on
      D131270 by Nathan Chancellor.
      
      Differential Revision: https://reviews.llvm.org/D132482
      Reviewed By: luismarques
      Tested By: Nathan Chancellor
      8f45b5a7
    • Cameron McInally's avatar
      [GlobalOpt] Bail out of GlobalOpt SROA if a Scalable Vector is seen · 38d58c1b
      Cameron McInally authored
      The SROA algorithm won't work for Scalable Vectors, since we don't
      know how many bytes are loaded/stored. Bail out if a Scalable
      Vector is seen.
      
      Differential Revision: https://reviews.llvm.org/D132417
      38d58c1b
    • Sanjay Patel's avatar
      [InstCombine] reduce disguised mul+add factorization · f7ab70cf
      Sanjay Patel authored
      ~(A * C1) + A --> (A * (1 - C1)) - 1
      
      This is a non-obvious mix of bitwise logic and math:
      https://alive2.llvm.org/ce/z/U7ACVT
      
      The pattern may be produced by Negator from the more typical
      code seen in issue #57255.
      f7ab70cf
    • Sanjay Patel's avatar
      [InstCombine] add tests for add with not-of-mul common operand; NFC · 24d52181
      Sanjay Patel authored
      Negator can create non-obvious math while trying hard to avoid subtraction.
      issue #57255
      24d52181
    • Eli Friedman's avatar
      Exclude check-polly-unittests and check-polly-isl from check-all · 2c29268b
      Eli Friedman authored
      The unittests are already included in check-polly, so check-all was
      running them twice.  Running them twice causes a race on the output
      files, which led to intermittent failures on the reverse-iteration
      buildbot.
      2c29268b
    • Chris Bieneman's avatar
      [HLSL] Entry functions require param annotation · bdf1327f
      Chris Bieneman authored
      HLSL entry function parameters must have parameter annotations. This
      allows appropriate intrinsic values to be populated into parameters
      during code generation.
      
      This does not handle entry function return values, which will be
      handled in a subsequent commit because we don't currently support any
      annotations that are valid for function returns.
      
      Reviewed By: aaron.ballman
      
      Differential Revision: https://reviews.llvm.org/D131625
      bdf1327f
    • Ye Luo's avatar
      [libomptarget][amdgpu] enable tests whenever possible. · 322ea531
      Ye Luo authored
      if(TARGET amdgpu-arch) doesn't work when ENABLE_LLVM_PROJECTS=openmp because openmp subdirectory is processed before clang subdirectory. Adopt the same logic of enabling tests like the CUDA plugin.
      
      Differential Revision: https://reviews.llvm.org/D132579
      322ea531
    • Sami Tolvanen's avatar
      Revert "KCFI sanitizer" · a79060e2
      Sami Tolvanen authored
      This reverts commit 67504c95 as using
      PointerEmbeddedInt to store 32 bits breaks 32-bit arm builds.
      a79060e2
    • Michael Liao's avatar
      [LoongArch] Fix build due to TLI interface changes. NFC. · dda38786
      Michael Liao authored
      - isCheapToSpeculateCttz/isCheapToSpeculateCtlz have one type operand
        after https://reviews.llvm.org/D132520
      dda38786