1. Apr 30, 2024
    • Jonathan Thackray's avatar
    • Maxim Moskalets's avatar
    • Tomas Matheson's avatar
      [AArch64][TargetParser] autogen ArchExtKind enum (#90314) · 61b2a0e3
      Tomas Matheson authored
      Thanks to ExtensionSet::toLLVMFeatureList, all values of ArchExtKind
      should correspond to a particular -target-feature. The valid values of
      -target-feature are in turn defined by SubtargetFeature defs.
      
      Therefore we can generate ArchExtKind from the tablegen data. This is
      done by adding an Extension class which derives from SubtargetFeature.
      
      Because the Has* FieldNames do not always correspond to the AEK_
      names ("extensions", as defined in TargetParser), and AEK_ names do
      not always correspond to -march strings, some additional enum entries
      have been added to remap the names. I have renamed these to make the
      naming consistent, but split them into a separate PR to keep the diff
      reasonable (#90320)
      61b2a0e3
    • Luke Lau's avatar
      [DAGCombiner] Fix mayAlias not accounting for scalable MMOs with offsets (#90573) · 5e03c0af
      Luke Lau authored
      In #70452 DAGCombiner::mayAlias was taught to handle scalable sizes, but
      when it checks via AA->isNoAlias it didn't take into account the case
      where the size is scalable but there was an offset too.
      
      For the fixed length case the offset was just accounted for by adding to
      the LocationSize, but for the scalable case there doesn't seem to be a
      way to represent both a scalable and fixed part in it. So this patch
      works around it by bailing if there is an offset.
      
      Fixes #90559
      5e03c0af
    • Florian Hahn's avatar
      [LAA] Pass maximum stride to isSafeDependenceDistance. (#90036) · 82219e54
      Florian Hahn authored
      As discussed in https://github.com/llvm/llvm-project/pull/88039, support
      different strides with isSafeDependenceDistance by passing the maximum
      of both strides.
      
      isSafeDependenceDistance tries to prove that
          |Dist| > BackedgeTakenCount * Step
      holds. Chosing the maximum stride computes the maximum range accesed by
      the loop for all strides.
      
      PR: https://github.com/llvm/llvm-project/pull/90036
      82219e54
    • Maya Amrami's avatar
    • Timm Bäder's avatar
      bb95f5df
    • Florian Hahn's avatar
      [LTO] Reset DiscardValueNames in optimize(). (#78705) · f3ac55fa
      Florian Hahn authored
      libLTO parses options late, so at the moment the option is ignored. To
      fix that, re-set it in optimize(), as at this point the options have been
      parsed. When LTOCodeGenerator's constructor executes, the options
      haven't been parsed by the linker to libLTO yet.
      
      Note that we keep the value name of `%add = add..` because when the
      module is imported, DiscardValueNames is still set to false (the default
      when building with assertions).
      
      I tried to improve this in libLTO, but I am not sure if there's a
      suitable callback when all options have been set.
      
      PR: https://github.com/llvm/llvm-project/pull/78705
      f3ac55fa
    • yronglin's avatar
      [NFC][Clang] Update P2718R0 implementation status to partial supported (#90577) · 6fab3f2a
      yronglin authored
      Once https://github.com/llvm/llvm-project/issues/85613
      
       fixed, we can
      mark this feature fully supported.
      
      Signed-off-by: default avataryronglin <yronglin777@gmail.com>
      6fab3f2a
    • Timm Bäder's avatar
    • Timm Bäder's avatar
    • Luke Lau's avatar
      [RISCV] Remove -riscv-insert-vsetvl-strict-asserts flag (#90171) · 7faf3430
      Luke Lau authored
      This flag has been enabled by default for almost two years now since
      1f06398e, and at this stage we probably
      shouldn't be falling back to the fixups.
      
      This removes the flag so we always perform the assertion, as well as
      making sure that CurInfo is always valid on exit: We shouldn't leave
      emitVSETVLIs with an uninitialized VSETVLIInfo.
      7faf3430
    • Paul Walker's avatar
      66e1d2c9
    • Monad's avatar
      [InstCombine] Fold `trunc nuw/nsw (x xor y) to i1` to `x != y` (#90408) · 34c89eff
      Monad authored
      Fold:
      ``` llvm
      define i1 @src(i8 %x, i8 %y) {
        %xor = xor i8 %x, %y
        %r = trunc nuw/nsw i8 %xor to i1
        ret i1 %r
      }
      
      define i1 @tgt(i8 %x, i8 %y) {
        %r = icmp ne i8 %x, %y
        ret i1 %r
      }
      ```
      
      Proof: https://alive2.llvm.org/ce/z/dcuHmn
      34c89eff
    • Simon Pilgrim's avatar
      [X86] Add TODO for getTargetConstantFromBasePtr to support non-zero offsets. · 2cb97c7e
      Simon Pilgrim authored
      As noted on #66991 - we sometimes share vector constant pool entries, referencing subvectors within them via pointer offsets
      2cb97c7e
    • Simon Pilgrim's avatar
    • Simon Pilgrim's avatar
      3fca9d71
    • Simon Pilgrim's avatar
    • Simon Pilgrim's avatar
    • Danial Klimkin's avatar
      Fix output in coro-elide-thinlto.cpp (#90579) · fb2d3056
      Danial Klimkin authored
      Current dir can be read-only. Use a temp path instead.
      fb2d3056
    • David Stuttard's avatar
      [AMDGPU] Fix gfx12 waitcnt type for image_msaa_load (#90201) · 62dea99a
      David Stuttard authored
      image_msaa_load is actually encoded as a VSAMPLE instruction and
      requires the appropriate waitcnt variant.
      62dea99a
    • Ulrich Weigand's avatar
      [Clang][Sema] Do not accept "vector _Complex" for AltiVec/ZVector (#90467) · f73e87f5
      Ulrich Weigand authored
      The AltiVec (POWER) and ZVector (IBM Z) language extensions do not
      support using the "vector" keyword when the element type is a complex
      type, but current code does not verify this.
      
      Add a Sema check and diagnostic for this case.
      
      Fixes: https://github.com/llvm/llvm-project/issues/88399
      f73e87f5
    • Chuanqi Xu's avatar
      [NFC] [tests] Don't try to remove and create the same directory · 10aab63c
      Chuanqi Xu authored
      In the test of
      clang/test/Modules/no-transitive-source-location-change.cppm, there were
      reports about invalid directory names in windows. The reason may be that
      we may remove and create the same directory. This patch tries to avoid
      such patterns for that.
      10aab63c
    • David Spickett's avatar
      [flang] Fix debug-fn-info.f90 test · 21f8cedc
      David Spickett authored
      91a8cb78 was originally written
      before 8d538666 landed. The latter
      changed how main is emitted which changed the numbering of the
      suprograms in the test output.
      
      To fix this I've added a check for the new _QQmain and renumbered
      the existing checks.
      21f8cedc
    • Chuanqi Xu's avatar
      [NFC] [C++20] [Modules] Use new class CXX20ModulesGenerator to genera… (#90570) · fce09169
      Chuanqi Xu authored
      …te module file for C++20 modules instead of PCHGenerator
      
      Previously we're re-using PCHGenerator to generate the module file for
      C++20 modules. But this is slighty more or less odd. This patch tries to
      use a new class 'CXX20ModulesGenerator' to generate the module file for
      C++20 modules.
      fce09169
    • Chuanqi Xu's avatar
      [C++20] [Modules] Add signature to the BMI recording export imported · b2b463bd
      Chuanqi Xu authored
      modules
      
      After https://github.com/llvm/llvm-project/pull/86912,
      for the following example,
      
      ```
      export module A;
      export import B;
      ```
      
      The generated BMI of `A` won't change if the source location in `A`
      changes. Further, we plan avoid more such changes.
      
      However, it is slightly problematic since `export import` should
      propagate all the changes.
      
      So this patch adds a signature to the BMI of C++20 modules so that we
      can propagate the changes correctly.
      b2b463bd
    • Christian Sigg's avatar
      [mlir] Mark `isa/dyn_cast/cast/...` member functions deprecated. (#90413) · 7ac1fb01
      Christian Sigg authored
      This also removes the member overload in TypeSwitch.
      
      All other users have been removed in
      fac349a1 and
      bd9fdce6.
      7ac1fb01
    • Orlando Cazalet-Hyams's avatar
    • Daniil Kovalev's avatar
      [PAC][lldb][Dwarf] Support `__ptrauth`-qualified types in user expressions (#84387) · 64248d7d
      Daniil Kovalev authored
      Depends on #84384 and #90329
      
      This adds support for `DW_TAG_LLVM_ptrauth_type` entries corresponding
      to explicitly signed types (e.g. free function pointers) in lldb user
      expressions. Applies PR https://github.com/apple/llvm-project/pull/8239
      
      
      from Apple's downstream and also adds tests and related code.
      
      ---------
      
      Co-authored-by: default avatarJonas Devlieghere <jonas@devlieghere.com>
      64248d7d
    • Qizhi Hu's avatar
      [Clang][Sema] Fix a bug on template partial specialization with issue on... · a413c563
      Qizhi Hu authored
      [Clang][Sema] Fix a bug on template partial specialization with issue on deduction of nontype template parameter (#90376)
      
      Fix https://github.com/llvm/llvm-project/issues/68885
      
      
      When build expression from a deduced argument whose kind is
      `Declaration` and `NTTPType`(which declared as `decltype(auto)`) is
      deduced as a reference type, `BuildExpressionFromDeclTemplateArgument`
      just create a `DeclRef`. This is incorrect while we get type from the
      expression since we can't get the original reference type from
      `DeclRef`. Creating a `SubstNonTypeTemplateParmExpr` expression and make
      the deduction correct. `Replacement` expression of
      `SubstNonTypeTemplateParmExpr` just helps the deduction and may not be
      same with the original expression.
      
      Co-authored-by: default avatarhuqizhi <836744285@qq.com>
      a413c563
    • Qizhi Hu's avatar
      [Clang][Sema] fix a bug on template partial specialization (#89862) · eaee8aa0
      Qizhi Hu authored
      attempt to fix
      https://github.com/llvm/llvm-project/issues/68885#issuecomment-1764201896
      
      
      Deduction of NTTP whose type is `decltype(auto)` would create an
      implicit cast expression to dependent type and makes the type of primary
      template definition (`InjectedClassNameSpecialization`) and its partial
      specialization different. Prevent emitting cast expression to make clang
      knows their types are identical by removing `CTAK == CTAK_Deduced` when
      the type is `decltype(auto)`.
      
      Co-authored-by: default avatarhuqizhi <836744285@qq.com>
      eaee8aa0
    • Danial Klimkin's avatar
      Fix lock guads in PipePosix.cpp (#90572) · 29dda26c
      Danial Klimkin authored
      Guard object destroyed immediately after creation without naming.
      29dda26c
    • Timm Bäder's avatar
      [clang][Interp] Handle Shifts in OpenCL correctly · 74e65eec
      Timm Bäder authored
      We need to adjust the RHS to account for the LHS bitwidth.
      74e65eec
    • Andrzej Warzyński's avatar
      [mlir][test] Add TD example for peel+vectorize (depthwise conv) (#90200) · c9d92d21
      Andrzej Warzyński authored
      Adds an example that combines loop peeling and scalable vectorisation of
      `linalg.depthwise_conv_2d_nhwc_hwc`. This is similar to
      transform-op-peel-and-vectorize.mlir and is meant to demonstrate how to
      avoid masking when vectorising using scalable vectors.
      c9d92d21
    • Johannes de Fine Licht's avatar
      [MLIR][LLVM] Have LLVM::AddressOfOp implement ConstantLike (#90481) · 92ca6fcb
      Johannes de Fine Licht authored
      For all means and purposes llvm.mlir.addressof acts like a constant, and
      should be treated as such by passes. In particular, the operation should
      be propagated rather than passed whenever possible.
      92ca6fcb
    • Johannes de Fine Licht's avatar
      [MLIR] Sprinkle extra asserts in OperationSupport.h (#90465) · 2464c1c1
      Johannes de Fine Licht authored
      Should hopefully help shave some minutes off developer debugging time in
      the future.
      2464c1c1
    • Chuanqi Xu's avatar
      [Modules] No transitive source location change (#86912) · 6c311046
      Chuanqi Xu authored
      This is part of "no transitive change" patch series, "no transitive
      source location change". I talked this with @Bigcheese in the tokyo's
      WG21 meeting.
      
      The idea comes from @jyknight posted on LLVM discourse. That for:
      
      ```
      // A.cppm
      export module A;
      ...
      
      // B.cppm
      export module B;
      import A;
      ...
      
      //--- C.cppm
      export module C;
      import C;
      ```
      
      Almost every time A.cppm changes, we need to recompile `B`. Due to we
      think the source location is significant to the semantics. But it may be
      good if we can avoid recompiling `C` if the change from `A` wouldn't
      change the BMI of B.
      
      # Motivation Example
      
      This patch only cares source locations. So let's focus on source
      location's example. We can see the full example from the attached test.
      
      ```
      //--- A.cppm
      export module A;
      export template <class T>
      struct C {
          T func() {
              return T(43);
          }
      };
      export int funcA() {
          return 43;
      }
      
      //--- A.v1.cppm
      export module A;
      
      export template <class T>
      struct C {
          T func() {
              return T(43);
          }
      };
      export int funcA() {
          return 43;
      }
      
      //--- B.cppm
      export module B;
      import A;
      
      export int funcB() {
          return funcA();
      }
      
      //--- C.cppm
      export module C;
      import A;
      export void testD() {
          C<int> c;
          c.func();
      }
      ```
      
      Here the only difference between `A.cppm` and `A.v1.cppm` is that
      `A.v1.cppm` has an additional blank line. Then the test shows that two
      BMI of `B.cppm`, one specified `-fmodule-file=A=A.pcm` and the other
      specified `-fmodule-file=A=A.v1.pcm`, should have the bit-wise same
      contents.
      
      However, it is a different story for C, since C instantiates templates
      from A, and the instantiation records the source information from module
      A, which is different from `A` and `A.v1`, so it is expected that the
      BMI `C.pcm` and `C.v1.pcm` can and should differ.
      
      # Internal perspective of status quo
      
      To fully understand the patch, we need to understand how we encodes
      source locations and how we serialize and deserialize them.
      
      For source locations, we encoded them as:
      
      ```
      |
      |
      | _____ base offset of an imported module
      |
      |
      |
      |_____ base offset of another imported module
      |
      |
      |
      |
      | ___ 0
      ```
      
      As the diagram shows, we encode the local (unloaded) source location
      from 0 to higher bits. And we allocate the space for source locations
      from the loaded modules from high bits to 0. Then the source locations
      from the loaded modules will be mapped to our source location space
      according to the allocated offset.
      
      For example, for,
      
      ```
      // a.cppm
      export module a;
      ...
      
      // b.cppm
      export module b;
      import a;
      ...
      ```
      
      Assuming the offset of a source location (let's name the location as
      `S`) in a.cppm is 45 and we will record the value `45` into the BMI
      `a.pcm`. Then in b.cppm, when we import a, the source manager will
      allocate a space for module 'a' (according to the recorded number of
      source locations) as the base offset of module 'a' in the current source
      location spaces. Let's assume the allocated base offset as 90 in this
      example. Then when we want to get the location in the current source
      location space for `S`, we can get it simply by adding `45` to `90` to
      `135`. Finally we can get the source location for `S` in module B as
      `135`.
      
      And when we want to write module `b`, we would also write the source
      location of `S` as `135` directly in the BMI. And to clarify the
      location `S` comes from module `a`, we also need to record the base
      offset of module `a`, 90 in the BMI of `b`.
      
      Then the problem comes. Since the base offset of module 'a' is computed
      by the number source locations in module 'a'. In module 'b', the
      recorded base offset of module 'a' will change every time the number of
      source locations in module 'a' increase or decrease. In other words, the
      contents of BMI of B will change every time the number of locations in
      module 'a' changes. This is pretty sensitive. Almost every change will
      change the number of locations. So this is the problem this patch want
      to solve.
      
      Let's continue with the existing design to understand what's going on.
      Another interesting case is:
      
      ```
      // c.cppm
      export module c;
      import whatever;
      import a;
      import b;
      ...
      ```
      
      In `c.cppm`, when we import `a`, we still need to allocate a base
      location offset for it, let's say the value becomes to `200` somehow.
      Then when we reach the location `S` recorded in module `b`, we need to
      translate it into the current source location space. The solution is
      quite simple, we can get it by `135 + (200 - 90) = 245`. In another
      word, the offset of a source location in current module can be computed
      as `Recorded Offset + Base Offset of the its module file - Recorded Base
      Offset`.
      
      Then we're almost done about how we handle the offset of source
      locations in serializers.
      
      # The high level design of current patch
      
      From the abstract level, what we want to do is to remove the hardcoded
      base offset of imported modules and remain the ability to calculate the
      source location in a new module unit. To achieve this, we need to be
      able to find the module file owning a source location from the encoding
      of the source location.
      
      So in this patch, for each source location, we will store the local
      offset of the location and the module file index. For the above example,
      in `b.pcm`, the source location of `S` will be recorded as `135`
      directly. And in the new design, the source location of `S` will be
      recorded as `<1, 45>`. Here `1` stands for the module file index of `a`
      in module `b`. And `45` means the offset of `S` to the base offset of
      module `a`.
      
      So the trade-off here is that, to make the BMI more independent, we need
      to record more abstract information. And I feel it is worthy. The
      recompilation problem of modules is really annoying and there are still
      people complaining this. But if we can make this (including stopping
      other changes transitively), I think this may be a killer feature for
      modules. And from @Bigcheese , this should be helpful for clang explicit
      modules too.
      
      And the benchmarking side, I tested this patch against
      https://github.com/alibaba/async_simple/tree/CXX20Modules. No
      significant change on compilation time. The size of .pcm files becomes
      to 204M from 200M. I think the trade-off is pretty fair.
      
      # Some low level details
      
      I didn't use another slot to record the module file index. I tried to
      use the higher 32 bits of the existing source location encodings to
      store that information. This design may be safe. Since we use `unsigned`
      to store source locations but we use uint64_t in serialization. And
      generally `unsigned` is 32 bit width in most platforms. So it might not
      be a safe problem. Since all the bits we used to store the module file
      index is not used before. So the new encodings may be:
      
      ```
         |-----------------------|-----------------------|
         |           A           |         B         | C |
      
        * A: 32 bit. The index of the module file in the module manager + 1. The +1
                here is necessary since we wish 0 stands for the current module file.
        * B: 31 bit. The offset of the source location to the module file containing it.
        * C: The macro bit. We rotate it to the lowest bit so that we can save some 
                space in case the index of the module file is 0.
      ```
      
      (The B and C is the existing raw encoding for source locations)
      
      Another reason to reuse the same slot of the source location is to
      reduce the impact of the patch. Since there are a lot of places assuming
      we can store and get a source location from a slot. And if I tried to
      add another slot, a lot of codes breaks. I don't feel it is worhty.
      
      Another impact of this decision is that, the existing small
      optimizations for encoding source location may be invalided. The key of
      the optimization is that we can turn large values into small values then
      we can use VBR6 format to reduce the size. But if we decided to put the
      module file index into the higher bits, then maybe it simply doesn't
      work. An example may be the `SourceLocationSequence` optimization.
      
      This will only affect the size of on-disk .pcm files. I don't expect
      this impact the speed and memory use of compilations. And seeing my
      small experiments above, I feel this trade off is worthy.
      
      # Correctness
      
      The mental model for handling source location offsets is not so complex
      and I believe we can solve it by adding module file index to each stored
      source location.
      
      For the practical side, since the source location is pretty sensitive,
      and the patch can pass all the in-tree tests and a small scale projects,
      I feel it should be correct.
      
      # Future Plans
      
      I'll continue to work on no transitive decl change and no transitive
      identifier change (if matters) to achieve the goal to stop the
      propagation of unnecessary changes. But all of this depends on this
      patch. Since, clearly, the source locations are the most sensitive
      thing.
      
      ---
      
      The release nots and documentation will be added seperately.
      6c311046
    • Kristof Beyls's avatar
      [docs] Document which online sync-ups are no longer happening (#89361) · 853344d3
      Kristof Beyls authored
      Some of the online sync-ups on our Getting Involved page seem to no
      longer be happening. Document them as no longer happening, so that
      people don't get confused when dialing in to one of these.
      853344d3
    • Orlando Cazalet-Hyams's avatar
      [RemoveDIs] Fix findDbgValues to return dbg_assign records too (#90471) · 09e7d86b
      Orlando Cazalet-Hyams authored
      In the debug intrinsic class heirachy, a dbg.assign is a (inherits from)
      dbg.value, so `findDbgValues` returns dbg.values and dbg.assigns (by
      design). That hierarchy doesn't exist for DbgRecords - fix findDbgValues
      to return dbg_assign records as well as dbg_values and add unittest.
      09e7d86b
    • Abid Qadeer's avatar
      Reapply "[flang] Improve debug info for functions." with regression fixed. (#90484) · 91a8cb78
      Abid Qadeer authored
      The original PR #90083 had to be reverted in PR #90444 as it caused one
      of the gfortran tests to fail. The issue was using `isIntOrIndex` for
      checking for integer type. It allowed index type which later caused
      assertion when calling `getIntOrFloatBitWidth`. I have now replaced it
      with `isInteger` which should fix this regression.
      91a8cb78