1. May 07, 2024
    • Michael Kruse's avatar
      Make unique instances · 855a8481
      Michael Kruse authored
      855a8481
    • Quentin Colombet's avatar
      [SDISel] Teach the type legalizer about ADDRSPACECAST (#90969) · 6ce04747
      Quentin Colombet authored
      Vectorized ADDRSPACECASTs were not supported by the type legalizer.
      
      This patch adds the support for:
      - splitting the vector result: <2 x ptr> => 2 x <1 x ptr>
      - scalarization: <1 x ptr> => ptr
      - widening: <3 x ptr> => <4 x ptr>
      
      This is all exercised by the added NVPTX tests.
      6ce04747
    • Simon Pilgrim's avatar
      [X86] Add FastImm16 tuning flag to Intel Atom + AMD Bobcat/Ryzen Families (#90635) · d838e5b3
      Simon Pilgrim authored
      This patch limits the icmp_i16(x,c) -> icmp_i32(ext(x),ext(c)) fold to CPUs that aren't known to have fast handling for length-changing prefixes for imm16 operands.
      
      We are always assuming that 66/67h length-changing prefixes cause severe stalls and we should always extend imm16 operands and use a i32 icmp instead, the only exception being Intel Bonnell CPUs.
      
      Agner makes this clear (see microarchitecture.pdf) that there are no stalls for any of the Intel Atom family (at least as far as Tremont - not sure about Gracemont or later). This is also true for AMD Bobcat/Jaguar and Ryzen families.
      
      Recent performance Intel CPUs are trickier - Core2/Nehalem and earlier could have a 6-11cy stall, while SandyBridge onwards this is reduced to 3cy or less. I'm not sure if we should accept this as fast or not, we only use this flag for the icmp_i16 case, so that might be acceptable? If so, we should add this to x86-64-v3/v4 tuning as well.
      
      Part of #90355 + #62952
      d838e5b3
    • Anthony Ha's avatar
      [lldb] Have lldb-server assign ports to children in platform mode (#88845) · 6aed0ab6
      Anthony Ha authored
      Fixes #47549
      
      `lldb-server`'s platform mode seems to have an issue with its
      `--min-gdbserver-port` `--max-gdbserver-port` flags (and probably the
      `--gdbserver-port` flag, but I didn't test it).
      
      How the platform code seems to work is that it listens on a port, and
      whenever there's an incoming connection, it forks the process to handle
      the connection. To handle the port flags, the main process uses an
      instance of the helper class
      `GDBRemoteCommunicationServerPlatform::PortMap`, that can be configured
      and track usages of ports. The child process handling the platform
      connection, can then use the port map to allocate a port for the
      gdb-server connection it will make (this is another process it spawns).
      
      However, in the current code, this works only once. After the first
      connection is handled by forking a child process, the main platform
      listener code loops around, and then 'forgets' about the port map. This
      is because this code:
      ```cpp
      GDBRemoteCommunicationServerPlatform platform(
          acceptor_up->GetSocketProtocol(), acceptor_up->GetSocketScheme());
      if (!gdbserver_portmap.empty()) {
        platform.SetPortMap(std::move(gdbserver_portmap));
      }
      ```
      is within the connection listening loop. This results in the
      `gdbserver_portmap` being moved into the platform object at the
      beginning of the first iteration of the loop, but on the second
      iteration, after the first fork, the next instance of the platform
      object will not have its platform port mapped.
      The result of this bug is that subsequent connections to the platform,
      when spawning the gdb-remote connection, will be supplied a random port
      - which isn't bounded by the `--min-gdbserver-port` and
      `--max-gdbserver--port` parameters passed in by the user.
      
      This PR fixes this issue by having the port map be maintained by the
      parent platform listener process. On connection, the listener allocates
      a single available port from the port map, associates the child process
      pid with the port, and lets the connection handling child use that
      single port number.
      
      Additionally, when cleaning up child processes, the main listener
      process tracks the child that exited to deallocate the previously
      associated port, so it can be reused for a new connection.
      6aed0ab6
    • Ben Shi's avatar
      50da7680
    • ostannard's avatar
      [AArch64] Diagnose more functions when FP not enabled (#90832) · 1fd196c8
      ostannard authored
      When using a hard-float ABI for a target without FP registers, it's not
      possible to correctly generate code for functions with arguments which
      must be passed in floating-point registers. This is diagnosed in CodeGen
      instead of Sema, to more closely match GCC's behaviour around inline
      functions, which is relied on by the Linux kernel.
      
      Previously, this only checked function signatures as they were
      code-generated, but this missed some cases:
      * Calls to functions not defined in this translation unit.
      * Calls through function pointers.
      * Calls to variadic functions, where the variadic arguments have a
      floating-point type.
      
      This adds checks to function calls, as well as definitions, so that
      these cases are correctly diagnosed.
      1fd196c8
    • Orlando Cazalet-Hyams's avatar
      [RemoveDIs] Update some unittests to the new format (#90476) · 1530f319
      Orlando Cazalet-Hyams authored
      This patch updates the unittests that can be changed to the new format
      after #89799 (which changes the default format everywhere) to avoid a
      loss in coverage for the (new) default debug info format.
      1530f319
    • Peter Waller's avatar
      [llvm-mca] Abort on parse error without -skip-unsupported-instructions (#90474) · 1de0535e
      Peter Waller authored
      [llvm-mca] Abort on parse error without -skip-unsupported-instructions
      
      Prior to this patch, llvm-mca would continue executing after parse
      errors. These errors can lead to some confusion since some analysis
      results are printed on the standard output, and they're printed after
      the errors, which could otherwise be easy to miss.
      
      However it is still useful to be able to continue analysis after errors;
      so extend the recently added -skip-unsupported-instructions to support
      this.
      
      Two tests which have parse errors for some of the 'RUN' branches are
      updated to use -skip-unsupported-instructions so they can remain as-is.
      
      Add a description of -skip-unsupported-instructions to the llvm-mca
      command guide, and add it to the llvm-mca --help output:
      
      ```
        --skip-unsupported-instructions=<value> - Force analysis to continue in the presence of unsupported instructions
          =none                                 -   Exit with an error when an instruction is unsupported for any reason (default)
          =lack-sched                           -   Skip instructions on input which lack scheduling information
          =parse-failure                        -   Skip lines on the input which fail to parse for any reason
          =any                                  -   Skip instructions or lines on input which are unsupported for any reason
      ```
      
      Tests within this patch are intended to cover each of the cases.
      
      Reason        | Flag | Comment
      --------------|------|-------
      none          | none | Usual case, existing test suite
      lack-sched    | none | Advises user to use -skip-unsupported-instructions=lack-sched, tested in llvm/test/tools/llvm-mca/X86/BtVer2/unsupported-instruction.s
      parse-failure | none | Advises user to use -skip-unsupported-instructions=parse-failure, tested in llvm/test/tools/llvm-mca/bad-input.s
      any           | none | (N/A, covered above)
      lack-sched    | any  | Continues, prints warnings, tested in llvm/test/tools/llvm-mca/X86/BtVer2/unsupported-instruction.s
      parse-failure | any  | Continues, prints errors, tested in llvm/test/tools/llvm-mca/bad-input.s
      lack-sched    | parse-failure | Advises user to use -skip-unsupported-instructions=lack-sched, tested in llvm/test/tools/llvm-mca/X86/BtVer2/unsupported-instruction.s
      parse-failure | lack-sched    | Advises user to use -skip-unsupported-instructions=parse-failure, tested in llvm/test/tools/llvm-mca/bad-input.s
      none          | * | This would be any test case with skip-unsupported-instructions, coverage added in llvm/test/tools/llvm-mca/X86/BtVer2/simple-test.s
      any           | * | (Logically covered by the other cases)
      1de0535e
    • martinboehme's avatar
      [clang][dataflow] Strengthen pointer comparison. (#75170) · f3fbd21f
      martinboehme authored
      -  Instead of comparing the identity of the `PointerValue`s, compare the
         underlying `StorageLocation`s.
      
      - If the `StorageLocation`s are the same, return a definite "true" as
      the
      result of the comparison. Before, if the `PointerValue`s were different,
      we
      would return an atom, even if the storage locations themselves were the
      same.
      
      - If the `StorageLocation`s are different, return an atom (as before).
      Pointers
      that have different storage locations may still alias, so we can't
      return a
         definite "false" in this case.
      
      The application-level gains from this are relatively modest. For the
      Crubit
      nullability check running on an internal codebase, this change reduces
      the
      number of functions on which the SAT solver times out from 223 to 221;
      the
      number of "pointer expression not modeled" errors reduces from 3815 to
      3778.
      
      Still, it seems that the gain in precision is generally worthwhile.
      
      @Xazax-hun inspired me to think about this with his
      
      [comments](https://github.com/llvm/llvm-project/pull/73860#pullrequestreview-1761484615)
      on a different PR.
      f3fbd21f
    • Luke Lau's avatar
    • hev's avatar
      ad599673
    • Luke Lau's avatar
      [RISCV] Use IMPLICIT_DEF for undef GPR reg in vsetvli test. NFC · ebde770c
      Luke Lau authored
      Only VRs should use $noreg, this GPR was accidentally changed in d392520c
      ebde770c
    • jinchen's avatar
    • Kiran Chandramohan's avatar
      [Flang][OpenMP] NFC: Trivial changes in OmpCycleChecker (#91024) · 6ad37a41
      Kiran Chandramohan authored
      Cycle is associated with construct-names and not labels. Change name of
      a few variables to reflect this. Also add appropriate comment to
      describe the else case of error checking.
      6ad37a41
    • Haojian Wu's avatar
      [clang] Don't preserve the typo expr in the recovery expr for invalid VarDecls (#90948) · fc866fd2
      Haojian Wu authored
      With the commit d5308949, we now
      preserve the initializer for invalid decls with the recovery-expr.
      
      However there is a chance that the original init expr is a typo-expr, we
      should not preserve it in the final AST, as typo-expr is an internal AST
      node. We should use the one after the typo correction.
      
      This is spotted by a clangd hover crash on the testcase.
      fc866fd2
    • Abhishek Varma's avatar
      [MLIR][SCF] Add canonicalization pattern to fold away iter args of scf.forall (#90189) · 2b9210d1
      Abhishek Varma authored
      
      
      -- This commit adds a canonicalization pattern to fold away iter args of
      scf.forall if :-
         a. The corresponding tied result has no use.
         b. It is not being modified within the loop.
      
      Signed-off-by: default avatarAbhishek Varma <avarma094@gmail.com>
      2b9210d1
    • Timm Bäder's avatar
      [clang][Interp][NFC] Allow Pointer assignment if both are zero · 5f2f3900
      Timm Bäder authored
      ... even if the storage types are different.
      5f2f3900
    • Timm Bäder's avatar
      [clang][Interp][NFC] Add eval-order test · 05f4448d
      Timm Bäder authored
      Demonstrate that this isn't yet working right.
      05f4448d
    • Chuanqi Xu's avatar
      [NFC] Fix Modules/no-transitive-source-location-change.cppm after dfa7ff97 · ad9f38d0
      Chuanqi Xu authored
      The test fails after dfa7ff97. I didn't find this locally due to
      cache.
      ad9f38d0
    • Thorsten Schütt's avatar
      [GlobalIsel] Combine extract vector element (#90339) · b42f553a
      Thorsten Schütt authored
      look through shuffle vectors
      b42f553a
    • Mingming Liu's avatar
      [NFC]Extract the heuristic to find vtable for an indirect call into a helper function (#81024) · 879245e2
      Mingming Liu authored
      * This way the helper function could be re-used by
      indirect-call-promotion pass to find out the vtable for an indirect call
      and extract the value profiles if any.
      * The parent patch is https://github.com/llvm/llvm-project/pull/80762
      879245e2
    • Shilei Tian's avatar
      02ce8227
    • Chuanqi Xu's avatar
      [C++20] [Modules] [Reduced BMI] Combine the signature of used modules · dfa7ff97
      Chuanqi Xu authored
      into the current module
      
      Following of https://github.com/llvm/llvm-project/pull/86912. After
      https://github.com/llvm/llvm-project/pull/86912, with reduced BMI, the
      BMI can keep unchange if the dependent modules only changes the
      implementation (without introduing new decls). However, this is not
      strictly correct.
      
      For example:
      
      ```
      // a.cppm
      export module a;
      export inline int a() { ... }
      
      // b.cppm
      export module b;
      import a;
      export inline int b() { return a(); }
      ```
      
      Since both `a()` and `b()` are inline, we need to make sure the BMI of
      `b.pcm` will change after the implementation of `a()` changes.
      
      We can't get that naturally since we won't record the body of `a()`
      during the writing process. We can't reuse ODRHash here since ODRHash
      won't calculate the called function recursively. So ODRHash will be
      problematic if `a()` calls other inline functions.
      
      Probably we can solve this by a new hash mechanism. But the safety and
      efficiency may a problem too. Here we just combine the hash value of the
      used modules conservatively.
      dfa7ff97
    • Eli Friedman's avatar
      4cce9fbb
    • Chuanqi Xu's avatar
      [ASTContext] Profile Dependently-sized array types that do not have a specified number · f9d76197
      Chuanqi Xu authored
      of elements
      
      Close https://github.com/llvm/llvm-project/issues/91105
      
      The root reason for the issue is that we always generate the
      dependently-sized array types which don't specify a number of elements.
      
      The original comment says:
      
      > We do no canonicalization here at all, which is okay
      > because they can't be used in most locations.
      
      But now we find the locations.
      f9d76197
    • Owen Pan's avatar
      [clang-format] Handle Java switch expressions (#91112) · 236b3e1a
      Owen Pan authored
      Also adds AllowShortCaseExpressionOnASingleLine option and
      AlignCaseArrows suboption of AlignConsecutiveShortCaseStatements.
      
      Fixes #55903.
      236b3e1a
    • SahilPatidar's avatar
    • Jianjian Guan's avatar
      [RISCV] Add codegen support for Zvfbfmin (#87911) · 37fcb323
      Jianjian Guan authored
      This patch adds basic codegen support for Zvfbfmin extension.
      37fcb323
    • Joseph Huber's avatar
      [Offload] Detect target triple from preprocessor instead of CMake (#91283) · 3e54768d
      Joseph Huber authored
      Summary:
      This patch removes the special-case handling for the target triple
      inside of the CMake. I moved it into the implementation so it's easier
      to see and modify.
      3e54768d
    • S. Bharadwaj Yadavalli's avatar
      Revert "[DirectX][DXIL] Set DXIL Version in DXIL target triple based on shader... · 178ff395
      S. Bharadwaj Yadavalli authored
      Revert "[DirectX][DXIL] Set DXIL Version in DXIL target triple based on shader model version" (#91290)
      
      Reverts llvm/llvm-project#90809
      
      Need to investigate ASAN failures.
      178ff395
    • Monad's avatar
      [InstCombine] Fold `cttz(lshr(-1, x) + 1)` to `width - x` (#91244) · 0ab4458d
      Monad authored
      Fold
      ``` llvm
      define i64 @src(i64 %50) {
        %52 = lshr i64 -1, %50
        %53 = add i64 %52, 1
        %54 = call i64 @llvm.cttz.i64(i64 %53, i1 false)
        ret i64 %54
      }
      ```
      to
      ``` llvm
      define i64 @tgt(i64 %50) {
        %52 = sub i64 64, %50
        ret i64 %52
      }
      ```
      
      as
      https://github.com/llvm/llvm-project/pull/91171#pullrequestreview-2040663002
      pointed out.
      
      Alive2 proof: https://alive2.llvm.org/ce/z/2aHfYa
      
      Note: the `ctlz` version of this pattern seems not exist in dtcxzyw's
      benchmark, so put it aside for now.
      0ab4458d
    • Monad's avatar
      [ValueTracking] Recognize `LShr(UINT_MAX, Y) + 1` as a power-of-two (#91171) · fd0ffb74
      Monad authored
      There is a missed optimization in
      ``` llvm
      define i8 @known_power_of_two_rust_next_power_of_two(i8 %x, i8 %y) {
        %2 = add i8 %x, -1
        %3 = tail call i8 @llvm.ctlz.i8(i8 %2, i1 true)
        %4 = lshr i8 -1, %3
        %5 = add i8 %4, 1
        %6 = icmp ugt i8 %x, 1
        %p = select i1 %6, i8 %5, i8 1
      
        %r = urem i8 %y, %p
        ret i8 %r
      }
      ```
      which is extracted from the Rust code
      ``` rust
      fn func(x: usize, y: usize) -> usize {
          let z = x.next_power_of_two();
          y % z
      }
      ```
      Here `%p` (a.k.a `z`) is semantically a power-of-two, so `y urem p` can
      be optimized to `y & (p - 1)`. (Alive2 proof:
      https://alive2.llvm.org/ce/z/H3zooY)
      
      ---
      
      It could be generalized to recognizing `LShr(UINT_MAX, Y) + 1` as a
      power-of-two, which is what this PR does.
      Alive2 proof: https://alive2.llvm.org/ce/z/zUPTbc
      fd0ffb74
    • Nikita Popov's avatar
      [FunctionAttrs] Fix incorrect nonnull inference for non-inbounds GEP (#91180) · f34d30cd
      Nikita Popov authored
      For inbounds GEPs, if the source pointer is non-null, the result must
      also be non-null. However, this does not hold for non-inbounds GEPs.
          
      Fixes https://github.com/llvm/llvm-project/issues/91177.
      f34d30cd
    • Nikita Popov's avatar
      [LangRef] callbr result can be used in all successors (#91167) · de8cf69a
      Nikita Popov authored
      Originally, the callbr result could only be used on the fallthrough
      destination. This limitation has been lifted, and the result is now also
      available on the indirect destinations. However, LangRef was not updated
      to reflect this.
      de8cf69a
    • Nikita Popov's avatar
      Revert "[coro][CoroSplit] Use `llvm.lifetime.end` to compute putting objects... · 92438416
      Nikita Popov authored
      Revert "[coro][CoroSplit] Use `llvm.lifetime.end` to compute putting objects on the frame vs the stack (#90265)"
      
      This reverts commit fcf341d3.
      
      Causes major compile-time regressions when not using coroutines.
      92438416
    • alx32's avatar
      [lld-macho] Fix category merging category map non-determinism (#91159) · 6e5ed351
      alx32 authored
      Currently in `ObjcCategoryMerger::doMerge` and
      `generateCatListForNonErasedCategories` we use maps of pointers which
      leads to non-determinism. Switch instead to using `MapVector` which
      preserves determinism.
      6e5ed351
    • antangelo's avatar
      [NFC][X86] Fix check directive typo in preserve_none dynamic regmask test (#91048) · 2287f8d2
      antangelo authored
      Fixes an inactive check line and updates the check to match output and
      other cases.
      2287f8d2
    • Ryosuke Niwa's avatar
      [webkit.RefCntblBaseVirtualDtor] Ignore WTF::RefCounted<T> and its variants... · 6d6693e9
      Ryosuke Niwa authored
      [webkit.RefCntblBaseVirtualDtor] Ignore WTF::RefCounted<T> and its variants missing virtual destructor (#91009)
      
      6d6693e9
    • Ryosuke Niwa's avatar
    • Ian Anderson's avatar
      [clang][modules] stdarg.h and stddef.h shouldn't directly declare anything (#90676) · 29d447a6
      Ian Anderson authored
      stdarg.h and especially stddef.h are textual and so everything they
      declare gets precompiled into all of their clients' pcm files. They
      shouldn't directly declare anything though, their purpose is to select
      what submodules get imported, and not to add duplicate declarations to
      all of their clients. Make it so that they always ignore their header
      guards, even without modules, and declare them in separate header files
      so that they only go into the stdarg/stddef pcms. Still declare them in
      case clients rely on them.
      29d447a6