1. May 08, 2024
    • Matthias Springer's avatar
      [mlir][IR] Support op interfaces in `HasParent` trait · 7b1d6a75
      Matthias Springer authored
      This commit adds support for op interfaces to `HasParent`: an op interface can now be specified as a parent.
      
      To produce useful error messages, a new helper function `getInterfaceName` is generated for every op interface. This is similar to `getOperationName`, which is generated for operations.
      
      This commit addresses a TODO in `TensorOps.td`.
      7b1d6a75
    • Luke Lau's avatar
      [RISCV] Convert implicit_def tuples to noreg in post-isel peephole (#91173) · bbd6a2d8
      Luke Lau authored
      If a segmented load has an undefined passthru then it will be selected
      as a reg_sequence with implicit_def operands, which currently slips
      through the implicit_def -> noreg peephole.
      
      This patch fixes this so we're able to infer if the passthru is
      undefined without the need for looking through vreg definitions with
      MachineRegisterInfo, which will help with moving RISCVInsertVSETVLI to
      LiveIntervals in #70549
      bbd6a2d8
    • Freddy Ye's avatar
      e44600f3
    • martinboehme's avatar
      [clang][dataflow] Allow `DataflowAnalysisContext` to use a non-owned `Solver`. (#91316) · 23ae482b
      martinboehme authored
      For some callers (see change in DataflowAnalysis.h), this is more
      convenient.
      23ae482b
    • Mircea Trofin's avatar
      [compiler-rt][ctx_profile] Fix signed-ness warnings in test · 8755d24c
      Mircea Trofin authored
      Follow-up from PR ##89838. Some build bots warn-as-error
      about signed/unsigned comparison in CtxInstrProfilingTest.
      
      Example: https://lab.llvm.org/buildbot/#/builders/37/builds/34610
      8755d24c
    • jyu2-git's avatar
      Revert "Revert "[OpenMP][TR12] change property of map-type modifier."… (#91141) · a99ce615
      jyu2-git authored
      … (#90885)"
      
      This reverts commit eea81aa2.
      
      Also change isMapType as @vitalybuka suggested. Hope this fix sanitizer
      build problem.
      a99ce615
    • Christian Ulmann's avatar
      [MLIR][Interfaces] Change MemorySlotInterface to use OpBuilder (#91341) · 084e2b53
      Christian Ulmann authored
      This commit changes the `MemorySlotInterface` back to using `OpBuilder`
      instead of a rewriter. This was originally introduced in
      https://reviews.llvm.org/D150432 but it was shown that patterns are a
      bad idea for both Mem2Reg and SROA.
      Mem2Reg suffers from the usage of a rewriter due to being forced to
      create new basic blocks. This is an issue, as it leads to the
      invalidation of the dominance information, which can be expensive to
      recompute.
      084e2b53
    • Farzon Lotfi's avatar
      [SPIRV] Add tan intrinsic part 3 (#90278) · 3e82442f
      Farzon Lotfi authored
      This change is an implementation of #87367's investigation on supporting
      IEEE math operations as intrinsics.
      Which was discussed in this RFC:
      https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294
      
      If you want an overarching view of how this will all connect see:
      https://github.com/llvm/llvm-project/pull/90088
      Changes:
      - `llvm/docs/GlobalISel/GenericOpcode.rst` - Document the `G_FTAN`
      opcode
      -  `llvm/include/llvm/IR/Intrinsics.td` - Create the tan intrinsic
      - `llvm/include/llvm/Support/TargetOpcodes.def` - Create a `G_FTAN`
      Opcode handler
      - `llvm/include/llvm/Target/GenericOpcodes.td` - Define the `G_FTAN`
      Opcode
      - `llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp` Map the tan intrinsic
      to `G_FTAN` Opcode
      - `llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp` - Map the
      `G_FTAN` opcode to the GLSL 4.5 and openCL tan instructions.
      - `llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp` - Define `G_FTAN` as a
      legal spirv target opcode.
      3e82442f
    • Luke Lau's avatar
      [RISCV] Add invariants that registers always have definitions. NFC (#90587) · 8296f061
      Luke Lau authored
      For vector merge operands, we check if it's a NoRegister beforehand so
      any other register type should have a definition.
      
      For VL operands, they don't get replaced with NoRegisters since they're
      scalar and should also always have a definition, even if it's an
      implicit_def.
      
      All the definitions at this stage should also be unique, this will
      change in #70549
      8296f061
    • Craig Topper's avatar
      [RISCV] Don't crash if parseNormalizedArchString encounters a multi-letter... · 0d93b01c
      Craig Topper authored
      [RISCV] Don't crash if parseNormalizedArchString encounters a multi-letter extension with an unknown prefix. (#91398)
      
      The sorting code previously asserted if a prefix was multiple letters,
      but didn't start with s, x, or z.
      
      Replace the assert with an explicit check and sort the multi-letter
      extension after the known multi-letter prefixes.
      0d93b01c
    • Craig Topper's avatar
      [DAGCombiner] Be more careful about looking through extends and truncates in... · ef844525
      Craig Topper authored
      [DAGCombiner] Be more careful about looking through extends and truncates in mergeTruncStores. (#91375)
      
      Previously we recursively looked through extends and truncates on both
      SourceValue and WideVal.
      
      SourceValue is the largest source found for each of the stores we are
      combining. WideVal is the source for the current store.
      
      Previously we could incorrectly look through a (zext (trunc X)) pair and
      incorrectly believe X to be a good source.
      
      I think we could also look through a zext on one store and a sext on
      another store and arbitrarily pick one of the extends as the final
      source.
      
      With this patch we only look through one level of extend or truncate.
      And we don't look through extends/truncs on both SourceValue and WideVal
      at the same time.
      
      This may lose some optimization cases, but keeps everything we had tests
      for.
      
      Fixes #90936.
      ef844525
    • Farzon Lotfi's avatar
      [DXIL] Add tan intrinsic part 2 (#90277) · 85ef6b7c
      Farzon Lotfi authored
      This change is an implementation of #87367's investigation on supporting
      IEEE math operations as intrinsics.
      Which was discussed in this RFC:
      https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294
      
      If you want an overarching view of how this will all connect see:
      https://github.com/llvm/llvm-project/pull/90088
      
      Changes:
      -  `llvm/include/llvm/IR/Intrinsics.td` - Create the tan intrinsic
      - `llvm/lib/Target/DirectX/DXIL.td` - Map `int_tan` (the tan intrinsic)
      to the equivalent DXIL Op.
      85ef6b7c
    • Craig Topper's avatar
      [RISCV] Detect duplicate extensions in parseNormalizedArchString. (#91416) · 2c209957
      Craig Topper authored
      This detects the same extension name being added twice. Mostly I'm
      worried about the case that the same string appears with two different
      versions. We will only preserve one of the versions.
      
      We could allow the same version to be repeated, but that doesn't seem
      useful at the moment.
      
      I've updated addExtension to use map::emplace instead of
      map::operator[]. This means we only keep the first version if there are
      duplicates. Previously we kept the last version, but that shouldn't matter
      now that we don't allow duplicates. parseArchString already doesn't allow
      duplicates.
      2c209957
    • Thorsten Schütt's avatar
      [GlobalIsel][AArch64] legalize ptr add (#89218) · 812c3025
      Thorsten Schütt authored
      LLVM ERROR: unable to legalize instruction: %275:_(<4 x p0>) = G_PTR_ADD
      %268:_, %274:_(<4 x s64>) (in function: prepare_for_pass)
      812c3025
    • Luke Lau's avatar
      [RISCV] Rewrite spill-fpr-scalar.ll test to not use vsetvli. NFC (#91428) · 48b6f4a1
      Luke Lau authored
      It was relying on the fact that vsetvlis have side effects to prevent
      reordering, but #91319 proposes to remove the side effects. This reworks
      it to use volatile loads and stores instead.
      48b6f4a1
    • Liao Chunyu's avatar
      [RISCV] Codegen support for XCVbi extension (#89719) · f4d2f7a3
      Liao Chunyu authored
      spec:
      https://github.com/openhwgroup/cv32e40p/blob/master/docs/source/instruction_set_extensions.rst#immediate-branching-operations
      
      Contributors: @CharKeaney, @jeremybennett, @lewis-revill,
      @NandniJamnadas,
      @PaoloS02, @simonpcook, @xingmingjie, @realqhc, @PhilippvK,@melonedo
      f4d2f7a3
    • Jhonatan Cléto's avatar
      [Offload] Fix dataDelete op for TARGET_ALLOC_HOST memory type (#91134) · b438a817
      Jhonatan Cléto authored
      Summary:
      The `GenericDeviceTy::dataDelete` method doesn't verify the
      `TargetAllocTy` of the of the device pointer. Because of this, it can
      use the `MemoryManager` to free the ptr. However, the
      `TARGET_ALLOC_HOST` and `TARGET_ALLOC_SHARED` types are not allocated
      using the `MemoryManager` in the `GenericDeviceTy::dataAlloc` method.
      Since the `MemoryManager` uses the `DeviceAllocatorTy::free` operation
      without specifying the type of the ptr, some plugins may use incorrect
      operations to free ptrs of certain types. In particular, this bug causes
      the CUDA plugin to use the `cuMemFree` operation on ptrs of type
      `TARGET_ALLOC_HOST`, resulting in an unchecked error, as shown in the
      output snippet of the test
      `offload/test/api/omp_host_pinned_memory_alloc.c`:
      
      ```
      omptarget --> Notifying about an unmapping: HstPtr=0x00007c6114200000
      omptarget --> Call to llvm_omp_target_free_host for device 0 and address 0x00007c6114200000
      omptarget --> Call to omp_get_num_devices returning 1
      omptarget --> Call to omp_get_initial_device returning 1
      PluginInterface --> MemoryManagerTy::free: target memory 0x00007c6114200000.
      PluginInterface --> Cannot find its node. Delete it on device directly.
      TARGET CUDA RTL --> Failure to free memory: Error in cuMemFree[Host]: invalid argument
      omptarget --> omp_target_free deallocated device ptr
      ```
      
      This patch fixes this by adding the check of the device pointer type
      before calling the appropriate operation for each type.
      b438a817
    • Farzon Lotfi's avatar
      [clang][hlsl] Add tan intrinsic part 1 (#90276) · 31b45a9d
      Farzon Lotfi authored
      This change is an implementation of #87367's investigation on supporting
      IEEE math operations as intrinsics.
      Which was discussed in this RFC:
      https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294
      
      If you want an overarching view of how this will all connect see:
      https://github.com/llvm/llvm-project/pull/90088
      
      Changes:
      - `clang/docs/LanguageExtensions.rst` - Document the new elementwise tan
      builtin.
      -  `clang/include/clang/Basic/Builtins.td` - Implement the tan builtin.
      - `clang/lib/CodeGen/CGBuiltin.cpp` - invoke the tan intrinsic on uses
      of the builtin
      - `clang/lib/Headers/hlsl/hlsl_intrinsics.h` - Associate the tan builtin
      with the equivalent hlsl apis
      - `clang/lib/Sema/SemaChecking.cpp` - Add generic sema checks as well as
      HLSL specifc sema checks to the tan builtin
      -  `llvm/include/llvm/IR/Intrinsics.td` - Create the tan intrinsic
      -  `llvm/docs/LangRef.rst` - Document the tan intrinsic
      31b45a9d
    • Jie Fu's avatar
      [mlir] Fix -Wdeprecated-declarations in BufferResultsToOutParams.cpp (NFC) · 1c8c2fdd
      Jie Fu authored
      /llvm-project/mlir/lib/Dialect/Bufferization/Transforms/BufferResultsToOutParams.cpp:124:26:
      error: 'cast' is deprecated: Use mlir::cast<U>() instead [-Werror,-Wdeprecated-declarations]
        124 |           orig.getType().cast<MemRefType>().hasStaticShape()) {
            |
      1c8c2fdd
    • Menooker's avatar
      [MLIR][Bufferization] BufferResultsToOutParams: Add an option to eliminate... · 0af448b7
      Menooker authored
      [MLIR][Bufferization] BufferResultsToOutParams: Add an option to eliminate AllocOp and avoid Copy (#90011)
      
      Add an option hoist-static-allocs to remove the unnecessary memref.alloc
      and memref.copy after this pass, when the memref in ReturnOp is
      allocated by memref.alloc and is statically shaped. Instead, it replaces
      the uses of the allocated memref with the memref in the out argument.
      By default, BufferResultsToOutParams will result in a memcpy operation
      to copy the originally returned memref to the output argument memref.
      This is inefficient when the source of memcpy (the returned memref in
      the original ReturnOp) is from a local AllocOp. The pass can use the
      output argument memref to replace the locally allocated memref for
      better performance.hoist-static-allocs avoids dynamic allocation and
      memory movement.
      This option will be critical for performance-sensivtive applications,
      which require BufferResultsToOutParams pass for a caller-owned output
      buffer calling convension.
      0af448b7
    • Ryosuke Niwa's avatar
    • Yingwei Zheng's avatar
      [InstSimplify] Do not simplify freeze in `simplifyWithOpReplaced` (#91215) · d085b42c
      Yingwei Zheng authored
      See the LangRef:
      > All uses of a value returned by the same ‘freeze’ instruction are
      guaranteed to always observe the same value, while different ‘freeze’
      instructions may yield different values.
      
      It is incorrect to replace freezes with the simplified value.
      
      Proof:
      https://alive2.llvm.org/ce/z/3Dn9Cd
      https://alive2.llvm.org/ce/z/Qyh5h6
      
      Fixes https://github.com/llvm/llvm-project/issues/91178
      d085b42c
    • Nikita Popov's avatar
      [NFC] Add myself as code owner for llvm/IR/Core.cpp · 7098cd21
      Nikita Popov authored
      In practice I end up reviewing most changes to the C API.
      7098cd21
    • Jinsong Ji's avatar
      [Analysis] Attribute Range should not prevent tail call optimization (#91122) · 2dade004
      Jinsong Ji authored
      - Remove Range attr when comparing for tailcall
      - Add test for testcall with range
      2dade004
    • Aart Bik's avatar
    • Benji Smith's avatar
      [C API] Add getters and build function for CallBr (#91154) · 584253c4
      Benji Smith authored
      This adds LLVMBuildCallBr to create CallBr instructions, and getters for
      the CallBr-specific data. The remainder of its data, e.g.
      arguments/function, can be accessed using existing getters.
      584253c4
    • Krystian Stasiowski's avatar
      [Clang][Sema] Improve support for explicit specializations of constrained... · 34ae2265
      Krystian Stasiowski authored
      [Clang][Sema] Improve support for explicit specializations of constrained member functions & member function templates (#88963)
      
      Consider the following snippet from the discussion of CWG2847 on the core reflector:
      ```
      template<typename T>
      concept C = sizeof(T) <= sizeof(long);
      
      template<typename T>
      struct A 
      {
          template<typename U>
          void f(U) requires C<U>; // #1, declares a function template 
      
          void g() requires C<T>; // #2, declares a function
      
          template<>
          void f(char);  // #3, an explicit specialization of a function template that declares a function
      };
      
      template<>
      template<typename U>
      void A<short>::f(U) requires C<U>; // #4, an explicit specialization of a function template that declares a function template
      
      template<>
      template<>
      void A<int>::f(int); // #5, an explicit specialization of a function template that declares a function
      
      template<>
      void A<long>::g(); // #6, an explicit specialization of a function that declares a function
      ```
      
      A number of problems exist:
      - Clang rejects `#4` because the trailing _requires-clause_ has `U`
      substituted with the wrong template parameter depth when
      `Sema::AreConstraintExpressionsEqual` is called to determine whether it
      matches the trailing _requires-clause_ of the implicitly instantiated
      function template.
      - Clang rejects `#5` because the function template specialization
      instantiated from `A<int>::f` has a trailing _requires-clause_, but `#5`
      does not (nor can it have one as it isn't a templated function).
      - Clang rejects `#6` for the same reasons it rejects `#5`.
      
      This patch resolves these issues by making the following changes:
      - To fix `#4`, `Sema::AreConstraintExpressionsEqual` is passed
      `FunctionTemplateDecl`s when comparing the trailing _requires-clauses_
      of `#4` and the function template instantiated from `#1`.
      - To fix `#5` and `#6`, the trailing _requires-clauses_ are not compared
      for explicit specializations that declare functions.
      
      In addition to these changes, `CheckMemberSpecialization` now considers
      constraint satisfaction/constraint partial ordering when determining
      which member function is specialized by an explicit specialization of a
      member function for an implicit instantiation of a class template (we
      previously would select the first function that has the same type as the
      explicit specialization). With constraints taken under consideration, we
      match EDG's behavior for these declarations.
      34ae2265
    • Yinying Li's avatar
      [mlir][sparse] Add verification for explicit/implicit value (#90111) · 83f3b1cb
      Yinying Li authored
      1. Verify that the type of explicit/implicit values should be the same
      as the tensor element type.
      2. Verify that implicit value could only be zero.
      3. Verify that explicit/implicit values should be numeric.
      4. Fix the type change issue caused by SparseTensorType(enc).
      83f3b1cb
    • Krystian Stasiowski's avatar
      [Clang][Sema] Don't set instantiated from function when rewriting operator<=> (#91339) · d4cf20ca
      Krystian Stasiowski authored
      The following snippet causes a crash:
      ```
      template<typename T>
      struct A 
      {
          bool operator<=>(const A&) const requires true = default;
      };
      
      bool f(A<int> a) 
      {
          return a != A<int>();
      }
      ```
      This occurs because during the rewrite from `operator<=>` to
      `operator==`, the "pattern" `operator<=>` function is set as the
      instantiated from function for the newly created `operator==` function.
      This is obviously incorrect, and this patch fixes it.
      d4cf20ca
    • Krystian Stasiowski's avatar
      [Clang][Sema] Explicit template arguments are not substituted into the... · 77c5cea7
      Krystian Stasiowski authored
      [Clang][Sema] Explicit template arguments are not substituted into the exception specification of a function (#90760)
      
      [temp.deduct.general] p6 states:
      > At certain points in the template argument deduction process it is
      necessary to take a function type that makes use of template parameters
      and replace those template parameters with the corresponding template
      arguments.
      This is done at the beginning of template argument deduction when any
      explicitly specified template arguments are substituted into the
      function type, and again at the end of template argument deduction when
      any template arguments that were deduced or obtained from default
      arguments are substituted.
      
      [temp.deduct.general] p7 goes on to say:
      > The _deduction substitution loci_ are
      > - the function type outside of the _noexcept-specifier_,
      > - the explicit-specifier,
      > - the template parameter declarations, and
      > - the template argument list of a partial specialization
      >
      > The substitution occurs in all types and expressions that are used in
      the deduction substitution loci. [...]
      
      Consider the following:
      ```cpp
      struct A
      {
          static constexpr bool x = true;
      };
      
      template<typename T, typename U>
      void f(T, U) noexcept(T::x); // #1
      
      template<typename T, typename U>
      void f(T, U*) noexcept(T::y); // #2
      
      template<>
      void f<A>(A, int*) noexcept; // clang currently accepts, GCC and EDG reject
      ```
      
      Currently, `Sema::SubstituteExplicitTemplateArguments` will substitute
      into the _noexcept-specifier_ when deducing template arguments from a
      function declaration or when deducing template arguments for taking the
      address of a function template (and the substitution is treated as a
      SFINAE context). In the above example, `#1` is selected as the primary
      template because substitution of the explicit template arguments into
      the _noexcept-specifier_ of `#2` failed, which resulted in the candidate
      being ignored.
      
      This behavior is incorrect ([temp.deduct.general] note 4 says as much), and
      this patch corrects it by deferring all substitution into the
      _noexcept-specifier_ until it is instantiated.
      
      As part of the necessary changes to make this patch work, the
      instantiation of the exception specification of a function template
      specialization when taking the address of a function template is changed
      to only occur for the function selected by overload resolution per
      [except.spec] p13.1 (as opposed to being instantiated for every candidate).
      77c5cea7
    • Fangrui Song's avatar
    • Max Winkler's avatar
      [clang][CodeGen] Fix MSVC ABI for classes with a deleted copy assignment operator (#90547) · 3f37397c
      Max Winkler authored
      For global functions and static methods the MSVC ABI returns
      structs/classes with a deleted copy assignment operator indirectly.
      From local testing this ABI holds true for all currently supported
      architectures including ARM64EC.
      3f37397c
    • Youngsuk Kim's avatar
      c0d9efd3
    • Prathamesh Tagore's avatar
      [mlir][memref.expand_shape] Add verifier check to ensure correct output_shape... · 54401b43
      Prathamesh Tagore authored
      [mlir][memref.expand_shape] Add verifier check to ensure correct output_shape is provided by user (#91245)
      
      The verifier was not checking for the case when the user provided shape
      in output_shape is different than the one inferred from output type. Fix
      this.
      54401b43
    • Maksim Panchenko's avatar
      [BOLT] Add a test for BOLT-reserved space in a binary (#91399) · ff0c5ccb
      Maksim Panchenko authored
      Test case for #90300.
      ff0c5ccb
    • Ryosuke Niwa's avatar
      8fc68879
    • Mircea Trofin's avatar
      [compiler-rt][ctx_profile] Add the instrumented contextual profiling APIs (#89838) · ccf765cf
      Mircea Trofin authored
      APIs for contextual profiling. `ContextNode` is the call context-specific counter buffer. `ContextRoot` is associated to those functions that constitute roots into interesting call graphs, and is the object on which we hang off `Arena`s for allocating `ContextNode`s, as well as the `ContextNode` corresponding to such functions. Graphs of `ContextNode`s are accessible by one thread at a time.
      
      (Tracking Issue: #89287, more details in the RFC referenced there)
      ccf765cf
    • Schrodinger ZHU Yifan's avatar
      a5044e6d
    • Stanislav Mekhanoshin's avatar
      [AMDGPU] Prevent FMINIMUM and FMAXIMUM beeing fully scalarized (#91378) · 2a3903fa
      Stanislav Mekhanoshin authored
      This is the same logic as with FMINNUM_IEEE/FMAXNUM_IEEE.
      2a3903fa
    • Marian Buschsieweke's avatar
      [MSP430][Clang] Update list of MCUs (#91258) · bc8a4276
      Marian Buschsieweke authored
      This updates the list of MSP430 MCUs from TI's devices.csv obtained from [1] under the "Header and Support Files" link. A simple python script has been used to generate this list and is included as well.
      
      [1]: https://www.ti.com/tool/MSP430-GCC-OPENSOURCE#downloads
      bc8a4276