1. Feb 17, 2023
    • Erich Keane's avatar
      GH60642: Fix ICE when checking a lambda defined in a concept definition · 4bf6cc63
      Erich Keane authored
      As reported in GH60642, we asserted when there was a lambda defined in a
      template arguments inside of a concept, which caused us to not properly
      set up the list of instantiation args.  This patch ensures that the
      'lambda context decl' correctly falls-through the template argument
      instantiation, so that it is available when instantiating the lambda,
      and thus, when setting up the lambda instantiation args list.
      4bf6cc63
    • Nikita Popov's avatar
      06621ecd
    • Nikita Popov's avatar
      f098fb69
    • Aaron Ballman's avatar
      Fix Clang sphinx build · 49012454
      Aaron Ballman authored
      This addresses issues found in:
      https://lab.llvm.org/buildbot/#/builders/92/builds/40269
      49012454
    • Dmitry Bushev's avatar
      [RISCV][NFC] Add missing immediate operand types. · 6f3a7569
      Dmitry Bushev authored
      Some immediate types in RISCV target description lack operand type field.
      This leads them being listed as OPERAND_UNKNOWN in MCOperandInfo. This patch adds this fields.
      This is NFC because it does not affect flow of any current tools implementation.
      
      Reviewed By: craig.topper
      
      Differential Revision: https://reviews.llvm.org/D144105
      6f3a7569
    • Christian Ulmann's avatar
      [mlir][llvm] Add DINamespace attribute · e133cb9c
      Christian Ulmann authored
      This commit introduces the DINamespaceAttr to model LLVM's DINamespace metadata.
      
      Reviewed By: gysit
      
      Differential Revision: https://reviews.llvm.org/D144243
      e133cb9c
    • Christian Ulmann's avatar
      [mlir][llvm] Make DI param optional to match LLVM · 276358fd
      Christian Ulmann authored
      This commit makes DIDerivedTypeAttr's baseType parameter optional to ensure imported IR
      doesn't break the printer.
      
      Reviewed By: gysit
      
      Differential Revision: https://reviews.llvm.org/D144247
      276358fd
    • LLVM GN Syncbot's avatar
      [gn build] Port 46db8d82 · 76c638d1
      LLVM GN Syncbot authored
      76c638d1
    • Nikolas Klauser's avatar
      [libc++] Granularize <atomic> · 46db8d82
      Nikolas Klauser authored
      Reviewed By: Mordante, #libc
      
      Spies: arichardson, libcxx-commits, krytarowski
      
      Differential Revision: https://reviews.llvm.org/D142972
      46db8d82
    • Jay Foad's avatar
    • Nikita Popov's avatar
      f3fa1086
    • Balazs Benics's avatar
      [analyzer] Remove unjustified assert from EquivalenceClass::simplify · afcf70aa
      Balazs Benics authored
      One might think that by merging the equivalence classes (eqclasses) of
      `Sym1` and `Sym2` symbols we would end up with a `State` in which the
      eqclass of `Sym1` and `Sym2` should now be the same. Surprisingly, it's
      not //always// true.
      
      Such an example triggered the assertion enforcing this _unjustified_
      invariant in https://github.com/llvm/llvm-project/issues/58677.
      ```lang=C++
      unsigned a, b;
      #define assert(cond) if (!(cond)) return
      
      void f(unsigned c) {
          /*(1)*/ assert(c == b);
          /*(2)*/ assert((c | a) != a);
          /*(3)*/ assert(a);
          // a = 0  =>  c | 0 != 0  =>  c != 0  =>  b != 0
      }
      ```
      
      I believe, that this assertion hold for reasonable cases - where both
      `MemberSym` and `SimplifiedMemberSym` refer to live symbols.
      It can only fail if `SimplifiedMemberSym` refers to an already dead
      symbol. See the reasoning at the very end.
      In this context, I don't know any way of determining if a symbol is
      alive/dead, so I cannot refine the assertion in that way.
      So, I'm proposing to drop this unjustified assertion.
      
      ---
      
      Let me elaborate on why I think the assertion is wrong in its current
      shape.
      
      Here is a quick reminder about equivalence classes in CSA.
      We have 4 mappings:
      1) `ClassMap`: map, associating `Symbols` with an `EquivalenceClass`.
      2) `ClassMembers`: map, associating `EquivalenceClasses` with its
         members - basically an enumeration of the `Symbols` which are known
         to be equal.
      3) `ConstraintRange`: map, associating `EquivalenceClasses` with the
         range constraint which should hold for all the members of the
         eqclass.
      4) `DisequalityMap`: I'm omitting this, as it's irrelevant for our
         purposes now.
      
      Whenever we encounter/assume that two `SymbolRefs` are equal, we update
      the `ClassMap` so that now both `SymbolRefs` are referring to the same
      eqclass. This operation is known as `merge` or `union`.
      Each eqclass is uniquely identified by the `representative` symbol, but
      it could have been just a unique number or anything else - the point
      is that an eqclass is identified by something unique.
      Initially, all Symbols form - by itself - a trivial eqclass, as there
      are no other Symbols to which it is assumed to be equal. A trivial
      eqclass has //notionally// exactly one member, the representative symbol.
      I'm emphasizing that //notionally// because for such cases we don't store
      an entry in the `ClassMap` nor in the `ClassMembers` map, because it
      could be deduced.
      
      By `merging` two eqclasses, we essentially do what you would think it
      does. An important thing to highlight is that the representative symbol
      of the resulting eqclass will be the same as one of the two eqclasses.
      This operation should be commutative, so that `merge(eq1,eq2)` and
      `merge(eq2,eq1)` should result in the same eqclass - except for the
      representative symbol, which is just a unique identifier of the class,
      a name if you will. Using the representative symbol of `eq1` or `eq2`
      should have no visible effect on the analysis overall.
      
      When merging `eq1` into `eq2`, we take each of the `ClassMembers` of
      `eq1` and add them to the `ClassMembers` of `eq2` while we also redirect
      all the `Symbol` members of `eq1` to map to the `eq2` eqclass in the
      `ClassMap`. This way all members of `eq1` will refer to the correct
      eqclass. After these, `eq1` key is unreachable in the `ClassMembers`,
      hence we can drop it.
      
      ---
      
      Let's get back to the example.
      Note that when I refer to symbols `a`, `b`, `c`, I'm referring to the
      `SymbolRegionValue{VarRegion{.}}` - the value of that variable.
      
      After `(1)`, we will have a constraint `c == b : [1,1]` and an eqclass
      `c,b` with the `c` representative symbol.
      After `(2)`, we will have an additional constraint `c|b != a : [1,1]`
      with the same eqclass. We will also have disequality info about that
      `c|a` is disequal to `a` - and the other way around.
      However, after the full-expression, `c` will become dead. This kicks in
      the garbage collection, which transforms the state into this:
       - We no longer have any constraints, because only `a` is alive, for
         which we don't have any constraints.
       - We have a single (non-trivial) eqclass with a single element `b` and
         representative symbol `c`. (Dead symbols can be representative
         symbols.)
       - We have the same disequality info as before.
      
      At `(3)` within the false branch, `a` get perfectly constrained to zero.
      This kicks in the simplification, so we try to substitute (simplify) the
      variable in each SymExpr-tree. In our case, it means that the
      `c|a != a : [1,1]` constraint gets re-evaluated as `c|0 != 0 : [1,1]`,
      which is `c != 0 : [1,1]`.
      Under the hood, it means that we will call `merge(c|a, c)`. where `c` is
      the result of `simplifyToSVal(State, MemberSym).getAsSymbol()` inside
      `EquivalenceClass::simplify()`.
      Note that the result of `simplifyToSVal()` was a dead symbol. We
      shouldn't have acquired an already dead symbol. AFAIK, this is the only
      way we can get one at this point.
      Since `c` is dead, we no longer have a mapping in `ClassMap` for it;
      hence when we try to `find()` the eqclass of `c`, it will report that
      it's a trivial eqclass with the representative symbol `c`.
      
      After `merge(c|a, c)`, we will have a single (non-trivial) eqclass of
      `b, c|a` with the representative symbol `c|a` - because we merged the
      eqclass of `c` into the eqclass of `c|a`.
      
      This means that `find(c|a)` will result in the eqclass with the
      representative symbol `c|a`. So, we ended up having different eqclasses
      for `find(c|a)` and `find(c)` after `merge(c|a, c)`, firing the
      assertion.
      
      I believe, that this assertion hold for reasonable cases - where both
      `MemberSym` and `SimplifiedMemberSym` refer to live symbols.
      `MemberSym` should be live in all cases here, because it is from
      `ClassMembers` which is pruned in `removeDeadBindings()` so these must
      be alive. In this context, I don't know any way of determining if a
      symbol is alive/dead, so I cannot refine the assertion in that way.
      So, I'm proposing to drop this unjustified assertion.
      
      I'd like to thank @martong for helping me to conclude the investigation.
      It was really difficult to track down.
      
      PS: I mentioned that `merge(eq1, eq2)` should be commutative. We
      actually exploit this for merging the smaller eqclass into the bigger
      one within `EquivalenceClass::merge()`.
      Yea, for some reason, if you swap the operands, 3 tests break (only
      failures, no crashes) aside from the test which checks the state dumps.
      But I believe, that is a different bug and orthogonal to this one. I
      just wanted to mention that.
      - `Analysis/solver-sym-simplification-adjustment.c`
      - `Analysis/symbol-simplification-fixpoint-iteration-unreachable-code.cpp`
      - `Analysis/symbol-simplification-reassume.cpp`
      
      Fixes #58677
      
      Reviewed By: vabridgers
      
      Differential Revision: https://reviews.llvm.org/D138037
      afcf70aa
    • Nikolas Klauser's avatar
      [libc++] Granularize <bit> includes · 40a20ae6
      Nikolas Klauser authored
      Reviewed By: ldionne, #libc
      
      Spies: libcxx-commits
      
      Differential Revision: https://reviews.llvm.org/D141228
      40a20ae6
    • Anton Sidorenko's avatar
      [MachineCombiner] Support local strategy for traces · 2693efa8
      Anton Sidorenko authored
      For in-order cores MachineCombiner makes better decisions when the critical path
      is calculated only for the current basic block and does not take into account
      other blocks from the trace.
      
      This patch adds a virtual method to TargetInstrInfo to allow each target decide
      which strategy to use.
      
      Depends on D140541
      
      Reviewed By: spatel
      
      Differential Revision: https://reviews.llvm.org/D140542
      2693efa8
    • Nikita Popov's avatar
      e6e0ba8d
    • Alexander Belyaev's avatar
      cdf8f064
    • Martin Storsjö's avatar
      Revert "[LLD] [COFF] Don't try to detect MSVC installations in mingw mode" · eb141867
      Martin Storsjö authored
      This reverts commit 389bfbd6.
      
      This commit broke the compiler-rt/test/profile/Windows/coverage-weak-lld.cpp
      testcase. This testcase builds and links in an MSVC environment,
      but explicitly passes -lldmingw to the linker, to opt in to
      certain mingw-style behaviours regarding weak symbols, since
      effb87df. This patch broke that
      test, which now errored out with these errors:
      
          lld-link: error: could not open 'libuuid.a': no such file or directory
          lld-link: error: could not open 'libLIBCMT.a': no such file or directory
          lld-link: error: could not open 'libOLDNAMES.a': no such file or directory
      eb141867
    • Christian Ulmann's avatar
      [mlir][llvm] Verify LLVM module before import · bf91cd6e
      Christian Ulmann authored
      This commit ensures that the importing of LLVM modules first verifies
      that the module is even valid. As many tests did not work with valid
      LLVM IR, they were fixed as part of this commit.
      
      Some error messages were only reachable with invalid input IR, thus they
      were replaced with a failures.
      
      Reviewed By: gysit
      
      Differential Revision: https://reviews.llvm.org/D144186
      bf91cd6e
    • Benjamin Kramer's avatar
      [JT] Always create BPI/BFI when running in legacy PM · da3623de
      Benjamin Kramer authored
      This is wasteful, but only affects the legacy pass manager. Otherwise
      a1b78fb9 would crash JT when running
      with that PM. There are still a few users of the legacy PM out there
      that are reluctant to migrate, numba in this case.
      
      No test as we don't test legacy PM anymore.
      da3623de
    • Vassil Vassilev's avatar
      [clang-repl] Support compound statement as a top-level statement. · 159073bc
      Vassil Vassilev authored
      This patch teaches our incremental compilation infrastructure to push and pop a
      fake function scope making the Parser happy when parsing compound statements as
      part of a top-leve statement declaration.
      
      Differential revision: https://reviews.llvm.org/D139798
      159073bc
    • Alexander Belyaev's avatar
    • Antonio Frighetto's avatar
      [ConstantRange] Handle `Intrinsic::ctlz` · 65898e52
      Antonio Frighetto authored
      Introduce ConstantRange support for ctlz intrinsic, including
      exhaustive testing. Among other things, LVI may now be able to
      propagate information about cltz constant ranges lattice values.
      
      Differential Revision: https://reviews.llvm.org/D142234
      65898e52
    • R. Voggenauer's avatar
      [Support] [Windows] Don't check file access time in equivalent(file_status, file_status) · a1e80c69
      R. Voggenauer authored
      The sys::fs::equivalent(file_status, file_status) function is meant to
      judge whether two file_status structs denote the same individual file.
      On Unix, this is implemented by only comparing the st_dev and st_ino
      numbers (from stat), ignoring all other fields.
      
      On Windows, lacking reliable fields corresponding to st_dev and st_ino,
      equivalent(file_status, file_status) compares essentially all fields.
      However, since 1e39ef33
      (https://reviews.llvm.org/D18456), file_status also contains the file
      access time.
      
      Including the file access time in equivalent(file_status, file_status)
      makes it possible to spuriously break. In particular, when invoking
      equivalent(Twine, Twine), with two paths, there's a race condition - the
      function calls status() on both input paths. Even if the two paths
      are the same, the comparison can fail, if the file was accessed
      between the two status() calls.
      
      Thus, it seems like the inclusion of the access time in
      equivalent(file_status, file_status) was a mistake.
      
      This race condition can cause spurious failures when linking with
      LLD/ELF, where LLD uses equivalent() to check whether a file
      exists within a specific sysroot, and that sysroot is accessed by other
      processes concurrently.
      
      This fixes downstream issue
      https://github.com/msys2/MINGW-packages/issues/15695.
      
      Differential Revision: https://reviews.llvm.org/D144172
      a1e80c69
    • Martin Storsjö's avatar
      [LLD] [COFF] Don't try to detect MSVC installations in mingw mode · 389bfbd6
      Martin Storsjö authored
      In mingw mode, all linker paths are passed explicitly to the linker
      by the compiler driver. Don't try to implicitly add linker paths
      from the LIB environment variable or by detecting an MSVC
      installation directory.
      
      If the /winsysroot command line parameter is explicitly passed to
      lld-link while /lldmingw is specified, it could be considered reasonable
      to actually include those paths. However, modifying the code to
      handle only the /winsysroot case but not the other ones, when the
      mingw mode has been enabled, seems like much more code complexity
      for a mostly hypothetical case.
      
      Add a test for this when case when using LIB. (The code paths for
      trying to detect an MSVC installation aren't really regression tested.)
      
      Also fix an issue in the existing test for "Check that when /winsysroot
      is specified, %LIB% is ignored.", where the LIB variable pointed
      to a nonexistent directory, so the test would pass even if /winsysroot
      wouldn't be specified.
      
      Differential Revision: https://reviews.llvm.org/D144084
      389bfbd6
    • Nikita Popov's avatar
      3d84f426
    • Tobias Gysi's avatar
      [mlir][llvm] Add atomic support to the LoadOp. · 6f4af64b
      Tobias Gysi authored
      This revision adds atomic support to the LoadOp. It chooses
      to print the atomic keywords together with the syncscope and
      ordering arguments, which simplifies parsing and printing compared
      to the LLVM IR printer that puts the atomic keyword at the beginning.
      It uses the ordering attribute to check if the load is atomic.
      
      The revision also implements verifiers to ensure the constraints
      that apply to atomic load operations are checked.
      
      Reviewed By: Dinistro
      
      Differential Revision: https://reviews.llvm.org/D144112
      6f4af64b
    • Nikita Popov's avatar
      55a18bfe
    • Diana Picus's avatar
      [AMDGPU] Add cross-project-tests for WMMA builtins · 58dada5f
      Diana Picus authored
      Add a few tests to make sure we get the expected instruction for the
      WMMA builtins (and generally that our builtins and intrinsics are on the
      same page and won't blow up).
      
      Differential Revision: https://reviews.llvm.org/D144176
      58dada5f
    • Johannes de Fine Licht's avatar
      [MLIR][LLVM] Only disallow inlining for selected function attributes. · a048d739
      Johannes de Fine Licht authored
      This loosens the requirement of no passthrough function attribute being
      present to checking for specific attributes that prevent inlining. Since
      these attributes are no longer strictly passthrough, they should
      eventually be upgraded to some form of addressable attributes.
      
      Drops the expensive StringSwitches over call and function attributes in
      favor of selectively disallowing attributes that prevent inlining
      (similiar to the LLVM inliner), thereby moving to a less conservative
      approach.
      
      Reviewed By: gysit
      
      Differential Revision: https://reviews.llvm.org/D144104
      a048d739
    • Nikita Popov's avatar
    • Yeting Kuo's avatar
      [DAGCombiner] Teach MatchContextClass classes to use TargetLowering::isOperationLegalOrCustom(). · a96cbeb4
      Yeting Kuo authored
      Some of TargetLowering functions needed opcodes are often used in DAGCombiner.
      The patch make those MatchContextClass classes have TargetLowering members and
      pass specific opcodes for those TargetLowering functions.
      
      Reviewed By: RKSimon
      
      Differential Revision: https://reviews.llvm.org/D144075
      a96cbeb4
    • Alexander Belyaev's avatar
    • Chuanqi Xu's avatar
      Revert "[Coroutines] Stop supportting std::experimental::coroutine_traits" · 6d5ea6b1
      Chuanqi Xu authored
      This reverts commit c4e6e771.
      
      Since clang-tools-extra contains the use for
      std::experimental::coroutine_traits, the previsou commit breaks the
      build bot. Revert this one to make the bot green.
      6d5ea6b1
    • Chuanqi Xu's avatar
      [Coroutines] Stop supportting std::experimental::coroutine_traits · c4e6e771
      Chuanqi Xu authored
      As we discussed before, we should stop supporting
      std::experimental::coroutine_traits in clang17. Now the clang16 is
      branched so we can clean them now.
      
      All the removed tests have been duplicated before.
      c4e6e771
    • Ryan Guo's avatar
      [NDF] Revert earlier nfc commit to test commit access · f2404a58
      Ryan Guo authored
      This patch reverts 511d5506 by removing the empty newline.
      f2404a58
    • Ryan Guo's avatar
      511d5506
    • Dave Lee's avatar
    • Dave Lee's avatar
      [lldb] Limit TestPoPersistentResult to darwin · 5552c4dd
      Dave Lee authored
      5552c4dd
    • Dave Lee's avatar
      [lldb] Suppress persistent result when running po · 3328ee55
      Dave Lee authored
      Remove the persistent result variable after executing `po`.
      
      Without this change, the following behavior happens:
      
      ```
      (lldb) p thing
      (NSObject *) $0 = 0x600000008000
      (lldb) po thing
      <NSObject: 0x600000008000>
      (lldb) p thing
      (NSObject *) $2 = 0x600000008000
      (lldb) p $1
      (NSObject *) $1 = 0x600000008000
      ```
      
      Even though `po` hides the persistent result variable, it's still created - as $1 in
      this example. It can be accessed even though its existence is not evident.
      
      With this change, the persistent result is removed after the object description has
      printed. Instead, this is the behavior:
      
      ```
      (lldb) p thing
      (NSObject *) $0 = 0x600000008000
      (lldb) po thing
      <NSObject: 0x600000008000>
      (lldb) p thing
      (NSObject *) $1 = 0x600000008000
      ```
      
      The difference here is that the `po` doens't silently create a persistent result.
      
      Differential Revision: https://reviews.llvm.org/D144044
      3328ee55
    • Dave Lee's avatar
      [lldb] Rename SetResultIsInternal to SetSuppressPersistentResult (NFC) · b3215c81
      Dave Lee authored
      Rename `SetResultIsInternal` and `GetResultIsInternal` to `SetSuppressPersistentResult`
      and `GetSuppressPersistentResult` respectively.  Also rename `m_result_is_internal`.
      
      This matches the naming in the SB API.
      
      A separate change calls `SetSuppressPersistentResult`, where the name
      `SetResultIsInternal` doesn't quite fit.
      
      Differential Revision: https://reviews.llvm.org/D144042
      b3215c81