1. May 06, 2024
    • Chen Zheng's avatar
      5714e4db
    • Michael Flanders's avatar
      [libc][math] fix loose except check in `{EXPECT,ASSERT}_FP_EXCEPTION` macros (#88816) · ecfb5d99
      Michael Flanders authored
      Adds more FP test macros for the upcoming test adds for #61092 and the
      issues opened from it: #88768, #88769, #88770, #88771, #88772.
      
      Fix bug in `{EXPECT,ASSERT}_FP_EXCEPTION`. `EXPECT_FP_EXCEPTION(0)`
      seems to be used to test that an exception did not happen, but it always
      does `EXPECT_GE(... & 0, 0)` which never fails.
      
      Update and refactor tests that break after the above bug fix. An
      interesting way things broke after the above change is that
      `ForceRoundingMode` and `quick_get_round()` were raising the inexact
      exception, breaking a lot of the `atan*` tests.
      
      The changes for all files other than `FPMatcher.h` and
      `libc/test/src/math/smoke/RoundToIntegerTest.h` should have the same
      semantics as before. For `RoundToIntegerTest.h`, lines 56-58 before the
      changes do not always hold since this test is used for functions with
      different exception and errno behavior like `lrint` and `lround`. I've
      deleted those lines for now, but tests for those cases should be added
      for the different nearest int functions to account for this.
      
      Adding @nickdesaulniers for review.
      ecfb5d99
    • Danny Mösch's avatar
      [NFC] Use `const&` avoiding copies (#90334) · d751e407
      Danny Mösch authored
      Fixes #90285.
      d751e407
    • martinboehme's avatar
      [clang][dataflow] Don't propagate result objects in unevaluated contexts (reland #90438) (#91172) · 4d839d8f
      martinboehme authored
      This relands #90348 with a fix for a [buildbot
      failure](https://lab.llvm.org/buildbot/#/builders/216/builds/38446)
      caused by the test being run with `-fno-rtti`.
      4d839d8f
    • Florian Hahn's avatar
      [LAA] Add tests showing extra unnecessary runtime checks. · 5f73d29c
      Florian Hahn authored
      Pre-commit tests for an upcoming patch.
      5f73d29c
    • Chris's avatar
      [MLIR][EmitC] Fix bug in EmitC form-expressions pass (#91084) · 09adb531
      Chris authored
      An `emitc.expression` can only yield a single result, but some
      operations which have the `CExpression` trait can have multiple results,
      which can result in a crash when applying the `fold-expressions` pass.
      This change adds a check for the single-result condition and a simple
      test.
      09adb531
    • Yuanqiang Liu's avatar
      10ec0d20
    • Florian Hahn's avatar
      148b7217
    • Michael Kruse's avatar
      [driver] Do not warn about unused plugin flags. (#88948) · 6e31a499
      Michael Kruse authored
      Plugins are not loaded without the -cc1 phase. Do not report them when
      running on an assembly file or when linking. Many build tools add these
      options to all driver invocations, including LLVM's build system.
      
      Fixes #88173
      6e31a499
    • Leandro Lupori's avatar
    • Leandro Lupori's avatar
      [flang][OpenMP] Support tasks' implicit firstprivate DSA (#85989) · 1e9625e5
      Leandro Lupori authored
      Handle implicit firstprivate DSAs on task generating constructs.
      
      Fixes https://github.com/llvm/llvm-project/issues/64480
      1e9625e5
    • Jie Fu's avatar
      [X86] Fix -Wunused-function in X86ISelLowering.cpp (NFC) · b2c2fef5
      Jie Fu authored
      llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:3582:13:
      error: unused function 'isBlendOrUndef' [-Werror,-Wunused-function]
      static bool isBlendOrUndef(ArrayRef<int> Mask) {
                  ^
      1 error generated.
      b2c2fef5
    • Jie Fu's avatar
      [X86] Fix -Wsign-compare in X86ISelLowering.cpp (NFC) · a9241998
      Jie Fu authored
      llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:40081:21:
      error: comparison of integers of different signs: 'int' and 'unsigned int' [-Werror,-Wsign-compare]
        for (int I = 0; I != NumElts; ++I) {
                        ~ ^  ~~~~~~~
      1 error generated.
      a9241998
    • Xing Xue's avatar
      [libc++abi][AIX] Use different function pointer types for destructors with 1 or 2 args (#89624) · 47214903
      Xing Xue authored
      The destructors generated by the legacy IBM `xlclang++` compiler can
      take 1 or 2 arguments and the differences were handled by type `cast`
      where it is needed. Clang now treats the `cast` here as an error after
      https://github.com/llvm/llvm-project/commit/999d4f840777bf8de26d45947192aa0728edc0fb
      landed with `-Xextra -Werror`. The issue had been worked around by using
      `#pragma GCC diagnostic push/pop`. This patch defines 2 separate
      destructor types for 1 argument and 2 arguments respectively so `cast`
      is not needed.
      47214903
    • Hans Wennborg's avatar
      Add requires clause to risc-v clang driver tests · 6217abce
      Hans Wennborg authored
      Followup to #89727
      6217abce
    • Simon Pilgrim's avatar
      [X86] Fold BLEND(PERMUTE(X),PERMUTE(Y)) -> PERMUTE(BLEND(X,Y)) (#90219) · 8e7618aa
      Simon Pilgrim authored
      If we don't demand the same element from both single source shuffles (permutes), then attempt to blend the sources together first and then perform a merged permute.
      
      For vXi16 blends we have to be careful as these are much more likely to involve byte/word vector shuffles that will result in the creation of additional shuffle instructions.
      
      This fold might be worth it for VSELECT with constant masks on AVX512 targets, but I haven't investigated this yet, but I've tried to write combineBlendOfPermutes so to be prepared for this.
      
      The PR34592 -O0 regression is an unfortunate failure to cleanup with a later pass that calls SimplifyDemandedElts like the -O3 does - I'm not sure how worried we should be tbh.
      8e7618aa
    • Ulrich Weigand's avatar
      [SystemZ] Simplify f128 atomic load/store (#90977) · 0a0cac6d
      Ulrich Weigand authored
      Change definition of expandBitCastI128ToF128 and expandBitCastF128ToI128
      to allow for simplified use in atomic load/store.
      
      Update logic to split 128-bit loads and stores in DAGCombine to also
      handle the f128 case where appropriate. This fixes the regressions
      introduced by recent atomic load/store patches.
      0a0cac6d
    • Simon Pilgrim's avatar
      [DAG] Fold bitreverse(shl/srl(bitreverse(x),y)) -> srl/shl(x,y) (#89897) · 522b4bfe
      Simon Pilgrim authored
      Noticed while investigating GFNI per-element vector shifts (we can form SHL but not SRL/SRA)
      
      Alive2: https://alive2.llvm.org/ce/z/fSH-rf
      522b4bfe
    • WANG Rui's avatar
      0933a7a1
    • Timm Bäder's avatar
    • WANG Rui's avatar
      d98a7859
    • hev's avatar
      [LoongArch] Optimize *W Instructions at MI level (#90463) · e9bcd2bf
      hev authored
      Referring to RISC-V, adding an MI level pass to optimize *W instructions
      for LoongArch.
      
      First it removes unneeded sext(addi.w rd, rs, 0) instructions. Either
      because the sign extended bits aren't consumed or because the input was
      already sign extended by an earlier instruction.
      
      Then:
      1. Unless explicit disabled or the target prefers instructions with W
      suffix, it removes the -w suffix from opw instructions whenever all
      users are dependent only on the lower word of the result of the
      instruction. The cases handled are:
      * addi.w because it helps reduce test differences between LA32 and LA64
      w/o being a pessimization.
      
      2. Or if explicit enabled or the target prefers instructions with W
      suffix, it adds the W suffix to the instruction whenever all users are
      dependent only on the lower word of the result of the instruction. The
      cases handled are:
         * add.d/addi.d/sub.d/mul.d.
         * slli.d with imm < 32.
         * ld.d/ld.wu.
      e9bcd2bf
    • Timm Bäder's avatar
      [clang][Interp] Fix primitive lambda capture defaults · 9a521e27
      Timm Bäder authored
      We need to use InitField here, not SetField.
      9a521e27
    • Sameer Sahasrabuddhe's avatar
      [AMDGPU] don't mark control-flow intrinsics as convergent (#90026) · 8a65ee8b
      Sameer Sahasrabuddhe authored
      This is really a workaround to allow control flow lowering in the
      presence of convergence control tokens. Control-flow intrinsics in LLVM
      IR are convergent because they indirectly represent the wave CFG, i.e.,
      sets of threads that are "converged" or "execute in lock-step". But they
      exist during a small window in the lowering process, inserted after the
      structurizer and then translated to equivalent MIR pseudos. So rather
      than create convergence tokens for these builtins, we simply mark them
      as not convergent.
      
      The corresponding MIR pseudos are marked as having side effects, which
      is sufficient to prevent optimizations without having to mark them as
      convergent.
      8a65ee8b
    • Yingwei Zheng's avatar
    • Pavel Labath's avatar
      [lldb] Add SBType::GetByteAlign (#90960) · 30367cb5
      Pavel Labath authored
      lldb already mostly(*) tracks this information. This just makes it
      available to the SB users.
      
      (*) It does not do that for typedefs right now see llvm.org/pr90958
      30367cb5
    • Matt Arsenault's avatar
      Reapply "SystemZ: Fold copy of vector immediate to gr128" (#91099) · eb75af22
      Matt Arsenault authored
      This reverts commit a415b4df.
      
      Modify the instruction in place to transform it into a REG_SEQUENCE,
      which is what other implementations of foldImmediate do. Also start
      erasing the def instruction if there are no other uses.
      
      Fixes #91110.
      eb75af22
    • Jay Foad's avatar
      [AMDGPU] Fix typo in function name · e2c89254
      Jay Foad authored
      e2c89254
    • Matt Arsenault's avatar
      4b61d046
    • Matt Arsenault's avatar
      181e8214
    • Mehdi Amini's avatar
      Revert "Remove redundant move in return statement" (#91169) · ef8d8148
      Mehdi Amini authored
      Reverts llvm/llvm-project#90546
      
      This broke some bots, seems like some toolchain don’t consider the
      implicit move here.
      ef8d8148
    • Serge Pavlov's avatar
      [clang] Enable FPContract with optnone (#91061) · 0140ba03
      Serge Pavlov authored
      Previously treatment of the attribute `optnone` was modified in
      https://github.com/llvm/llvm-project/pull/85605 ([clang] Set correct
      FPOptions if attribute 'optnone' presents). As a side effect FPContract
      was disabled for optnone. It created unneeded divergence with the
      behavior of -O0, which enables this optimization.
      
      In the discussion
      https://github.com/llvm/llvm-project/pull/85605#issuecomment-2089350379
      it was pointed out that FP contraction should be enabled even if all
      optimizations are turned off, otherwise results of calculations would be
      different. This change enables FPContract at optnone.
      0140ba03
    • Matt Arsenault's avatar
      Reapply "AMDGPU: Implement llvm.set.rounding (#88587)" series (#91113) · d654278b
      Matt Arsenault authored
      Revert "Revert 4 last AMDGPU commits to unbreak Windows bots"
      
      This reverts commit 0d493ed2.
      
      MSVC does not like constexpr on the definition after an extern
      declaration of a global.
      d654278b
    • xiaoleis-nv's avatar
      Remove redundant move in return statement (#90546) · db532ff9
      xiaoleis-nv authored
      
      
      This pull request removes unnecessary move in the return statement to
      suppress compilation warnings.
      
      Co-authored-by: default avatarXiaolei Shi <xiaoleis@nvidia.com>
      db532ff9
    • Luke Lau's avatar
      [RISCV] Use virtual registers for AVL instrs in coalesce-vsetvli.mir. NFC · 1500dc0a
      Luke Lau authored
      All GPR registers will still be virtual at this stage, so update the test
      to reflect that.
      1500dc0a
    • martinboehme's avatar
      [clang][dataflow] Fix crash when `operator=` result type is not destination type. (#90898) · 0348e718
      martinboehme authored
      The existing code was full of comments about how we assume this is
      always the
      case, but it's not mandated by the standard, and there is code out there
      that
      returns a different type. So check that the result type is in fact the
      same as
      the destination type before attempting to copy to the result.
      
      To make sure that we don't bail out in more cases than intended, I've
      extended
      existing tests to verify that in the common case, we do return the
      destination
      object (by reference or value, as the case may be).
      0348e718
    • Yeting Kuo's avatar
      [RISCV] Teach .option arch to support experimental extensions. (#89727) · d70267fb
      Yeting Kuo authored
      Previously `.option arch` denied extenions are not belongs to RISC-V
      features. But experimental features have experimental- prefix, so
      `.option arch` can not serve for experimental extension.
      This patch uses the features of extensions to identify extension
      existance.
      d70267fb
    • Chuanqi Xu's avatar
      Reland "[Modules] No transitive source location change (#86912)" · 947b0628
      Chuanqi Xu authored
      This relands 6c311046.
      
      The patch was reverted due to incorrectly introduced alignment. And the
      patch was re-commited after fixing the alignment issue.
      
      Following off are the original message:
      
      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.
      
      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.
      
      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.
      
      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.
      
      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.
      
      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.
      
      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.
      947b0628
    • Luke Lau's avatar
    • Owen Pan's avatar
      [clang-format] Don't remove parentheses of fold expressions (#91045) · db0ed553
      Owen Pan authored
      Fixes #90966.
      db0ed553