1. Feb 17, 2023
    • LLVM GN Syncbot's avatar
      [gn build] Port bf0f94a5 · 783cbf70
      LLVM GN Syncbot authored
      783cbf70
    • Thomas Raoux's avatar
      [mlir] add option to multi-buffering · ddeb55ab
      Thomas Raoux authored
      Allow user to apply multi-buffering transformation for cases where proving
      that there is no loop carried dependency is not trivial. In this case user needs
      to ensure that the data are written and read in the same iteration otherwise the
      result is incorrect.
      
      Differential Revision: https://reviews.llvm.org/D144227
      ddeb55ab
    • Sanjay Patel's avatar
      [InstCombine] create a pass options container and add "use-loop-info" argument · 4ecc6af8
      Sanjay Patel authored
      This is a cleanup/modernization patch requested in D144045 to make loop
      analysis a proper optional parameter to the pass rather than a
      semi-arbitrary value inherited via the pass pipeline.
      
      It's a bit more complicated than the recent patch I started copying from
      (D143980) because InstCombine already has an option for MaxIterations
      (added with D71145).
      
      I debated just deleting that option, but it was used by a pair of existing
      tests, so I put it into a struct (code largely copied from SimplifyCFG's
      implementation) to make the code more flexible for future options
      enhancements.
      
      I didn't alter the pass manager invocations of InstCombine in this patch
      because the patch was already getting big, but that will be a small
      follow-up as noted with the TODO comment.
      
      Differential Revision: https://reviews.llvm.org/D144199
      4ecc6af8
    • Alexey Bataev's avatar
      [SLP]Do not reduce repeated values, use scalar red ops instead. · e03d254b
      Alexey Bataev authored
      Metric: size..text
      
                                                           size..text                 results     results0    diff
      SingleSource/Regression/C/gcc-c-torture/execute/GCC-C-execute-980605-1.test      445.00      461.00  3.6%
      SingleSource/Benchmarks/Adobe-C++/loop_unroll.test                               428477.00   428445.00 -0.0%
      External/SPEC/CFP2006/447.dealII/447.dealII.test                                 618849.00   618785.00 -0.0%
      
      For all tests some extra code was optimized, GCC-C-execute has some more
      inlining after
      
      Differential Revision: https://reviews.llvm.org/D132261
      e03d254b
    • Teresa Johnson's avatar
      New SetOperations and unittesting for all SetOperations · bf0f94a5
      Teresa Johnson authored
      New set operations split out of D140908 as suggested, and I have added
      unit testing for all set operations.
      
      This adds a set_intersection, which returns the intersection instead of
      updating the first set like set_intersect (using a different name
      analogous to set_difference vs set_subtract).
      
      Also adds a variant of set_subtract that updates two additional set
      arguments to note which members of the subtrahend were removed from
      the minuend and which were not.
      
      Differential Revision: https://reviews.llvm.org/D144220
      bf0f94a5
    • Paul Robinson's avatar
      Tighten up a modules test · 17a90f11
      Paul Robinson authored
      Differential Revision: https://reviews.llvm.org/D144188
      17a90f11
    • Christian Ulmann's avatar
      [mlir][llvm] Fuse access_group & loop export (NFC) · 87a04795
      Christian Ulmann authored
      This commit moves the access group translation into the
      LoopAnnotationTranslation class as these two metadata kinds only appear
      together.
      
      Drops the access group cleanup from `ModuleTranslation::forgetMapping`
      as this is only used on function regions. Access groups only appear in the
      region of a global metadata operation and will thus not be cleaned here.
      
      Analogous to https://reviews.llvm.org/D143577
      
      Reviewed By: gysit
      
      Differential Revision: https://reviews.llvm.org/D144253
      87a04795
    • Paul Walker's avatar
      [SVE] Add intrinsics for floating-point operations that explicitly undefine... · cf4df616
      Paul Walker authored
      [SVE] Add intrinsics for floating-point operations that explicitly undefine the result for inactive lanes.
      
      This patch is the floating-point equivalent of D141937.
      
      Depends on D143764.
      
      Differential Revision: https://reviews.llvm.org/D143765
      cf4df616
    • Marius Brehler's avatar
      [mlir][standalone] Extend sample with custom type · 83e9ef7e
      Marius Brehler authored
      This extends the standalone example to illustrate how to structure the
      files needed to create own types.
      
      Reviewed By: jpienaar
      
      Differential Revision: https://reviews.llvm.org/D143715
      83e9ef7e
    • Vladislav Dzhidzhoev's avatar
      [clang][CodeGen] Use base subobject type layout for potentially-overlapping fields · af6c0b6d
      Vladislav Dzhidzhoev authored
      RecordLayoutBuilder assumes the size of a potentially-overlapping
      class/struct field with non-zero size as the size of the base subobject
      type corresponding to the field type.
      Make CGRecordLayoutBuilder to acknowledge that in order to avoid incorrect
      padding insertion.
      
      Differential Revision: https://reviews.llvm.org/D139741
      af6c0b6d
    • 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