1. Jan 06, 2021
  2. Jan 05, 2021
    • Atmn Patel's avatar
      [LoopDeletion] Allows deletion of possibly infinite side-effect free loops · f88a7975
      Atmn Patel authored
      From C11 and C++11 onwards, a forward-progress requirement has been
      introduced for both languages. In the case of C, loops with non-constant
      conditionals that do not have any observable side-effects (as defined by
      6.8.5p6) can be assumed by the implementation to terminate, and in the
      case of C++, this assumption extends to all functions. The clang
      frontend will emit the `mustprogress` function attribute for C++
      functions (D86233, D85393, D86841) and emit the loop metadata
      `llvm.loop.mustprogress` for every loop in C11 or later that has a
      non-constant conditional.
      
      This patch modifies LoopDeletion so that only loops with
      the `llvm.loop.mustprogress` metadata or loops contained in functions
      that are required to make progress (`mustprogress` or `willreturn`) are
      checked for observable side-effects. If these loops do not have an
      observable side-effect, then we delete them.
      
      Loops without observable side-effects that do not satisfy the above
      conditions will not be deleted.
      
      Reviewed By: jdoerfert
      
      Differential Revision: https://reviews.llvm.org/D86844
      f88a7975
  3. Jan 06, 2021
    • Craig Topper's avatar
      [RISCV] Move shift ComplexPatterns and custom isel to PatFrags with predicates · 7b5a0e2f
      Craig Topper authored
      ComplexPatterns are kind of weird, they don't call any of the predicates on their operands. And their "complexity" used for tablegen ordering purposes in the matcher table is hand specified.
      
      This started as an attempt to just use sext_inreg + SLOIPat to implement SLOIW just to have one less Select function. The matching for the or+shl is the same as long as you know the immediate is less than 32 for SLOIW. But that didn't work out because using uimm5 with SLOIPat didn't do anything if it was a ComplexPattern.
      
      I realized I could just use a PatFrag with the opcodes I wanted to match and an immediate predicate would then evaluate correctly. This also computes the complexity just like any other pattern does. Then I just needed to check the constraints on the immediates in the predicate. Conveniently the predicate is evaluated after the fragment has been matched. So the structure has already been checked, we just need to find the constants.
      
      I'll note that this is unusual, I didn't find any other targets looking through operands in PatFrag predicate. There is a PredicateCodeUsesOperands feature that can be used to collect the operands into an array that is used by AMDGPU/VOP3Instructions.td. I believe that feature exists to handle commuted matching, but since the nodes here use constants, they aren't ever commuted
      
      Differential Revision: https://reviews.llvm.org/D91901
      7b5a0e2f
    • Alan Phipps's avatar
      [Coverage] Fix test failures from commit rG9f2967bc · 16f3401e
      Alan Phipps authored
      Fix test failures with Branch Coverage tests from commit rG9f2967bc
      that failed build on builder clang-x64-windows-msvc while building llvm:
          http://lab.llvm.org:8011/#builders/123/builds/2155
      16f3401e
    • Thomas Lively's avatar
      [WebAssembly] Prototype prefetch instructions · 497026c9
      Thomas Lively authored
      As proposed in https://github.com/WebAssembly/simd/pull/352 and using the
      opcodes used in the V8 prototype:
      https://chromium-review.googlesource.com/c/v8/v8/+/2543167. These instructions
      are only usable via intrinsics and clang builtins to make them opt-in while they
      are being benchmarked.
      
      Differential Revision: https://reviews.llvm.org/D93883
      497026c9
    • Jan Svoboda's avatar
      [clang][cli] Specify correct integer width for -fbuild-session-timestamp · f111cf99
      Jan Svoboda authored
      This fixes an issue where large integer values were rejected as invalid.
      
      Reviewed By: arphaman
      
      Differential Revision: https://reviews.llvm.org/D94101
      f111cf99
    • Arthur Eubanks's avatar
      [NFC] Rename registerAliasAnalyses -> registerDefaultAliasAnalyses · 28a326eb
      Arthur Eubanks authored
      To clarify that this only affects the "default" AA.
      
      Reviewed By: ychen
      
      Differential Revision: https://reviews.llvm.org/D93980
      28a326eb
    • Craig Topper's avatar
      [RISCV] Don't parse 'vmsltu.vi v0, v1, 0' as 'vmsleu.vi v0, v1, -1' · 210bc3dc
      Craig Topper authored
      vmsltu.vi v0, v1, 0 is always false there is no unsigned number
      less than 0. vmsleu.vi v0, v1, -1 on the other hand is always true
      since -1 will be considered unsigned max and all numbers are <=
      unsigned max.
      
      A similar problem exists for vmsgeu.vi v0, v1, 0 which is always true,
      but becomes vmsgtu.vi v0, v1, -1 which is always false.
      
      To match the GNU assembler we'll emit vmsne.vv and vmseq.vv with
      the same register for these cases instead.
      
      I'm using AsmParserOnly pseudo instructions here because we can't
      match an explicit immediate in an InstAlias. And we can't use a
      AsmOperand for the zero because the output we want doesn't use an
      immediate so there's nowhere to name the AsmOperand we want to use.
      
      To keep the implementations similar I'm also handling signed with
      pseudo instructions even though they don't have this issue. This
      way we can avoid the special renderMethod that decremented by 1 so
      the immediate we see for the pseudo instruction in processInstruction
      is 0 and not -1. Another option might have been to have a different
      simm5_plus1 operand for the unsigned case or just live with the
      immediate being pre-decremented. I felt this way was clearer, but I'm
      open to other opinions.
      
      Reviewed By: frasercrmck
      
      Differential Revision: https://reviews.llvm.org/D94035
      210bc3dc
    • Felipe de Azevedo Piovezan's avatar
      [mlir] Gen removeAttr methods with tablegen · 86d68e28
      Felipe de Azevedo Piovezan authored
      If an operation defines an optional attribute (OptionalAttr or
      UnitAttr), transformations may wish to remove these attributes while
      maintaining invariants established by the operation. Currently, the only
      way to do this is by calling `Operation::removeAttr("attrName")`, which
      requires developers to know the exact name of the attribute used by
      table-gen. Furthermore, if the attribute name changes, this won't be
      detected at compile time. Instead, `removeAttr` would return an empty
      attribute and no errors would be raised, unless the caller checks for
      the returned value.
      
      This patch adds table gen support for generating `remove<AttrName>Attr`
      methods for OptionalAttributes defined by operations.
      
      Implementation choice: to preserve camelCase for the method's name, the
      first character of an attribute called `myAttr` is changed to upper case
      in order to preserve the coding style, so the final method would be
      called `removeMyAttr`.
      
      Reviewed By: mehdi_amini
      
      Differential Revision: https://reviews.llvm.org/D93903
      86d68e28
    • Whitney Tsang's avatar
      [LoopNest] Allow empty basic blocks without loops · 601636de
      Whitney Tsang authored
      Addressed Florian's post commit review comments:
      1. included STLExtras.h
      2. changed std::all_of to llvm::all_of
      
      Differential Revision: https://reviews.llvm.org/D93665
      601636de
    • Dan Zheng's avatar
      [NFC] Fix -Wrange-loop-analysis warnings. · 7afd5cfb
      Dan Zheng authored
      Remove unnecessary `&` from loop variables.
      
      Fix warnings: "loop variable is always a copy because the range does not
      return a reference".
      
      ```
      [240/2862] Building CXX object tools/mlir/tools/mlir-tblgen/CMakeFiles/mlir-tblgen.dir/TypeDefGen.cpp.o
      llvm-project/mlir/tools/mlir-tblgen/TypeDefGen.cpp:50:25: warning: loop variable 'typeDef' is always a copy because the range of type 'llvm::iterator_range<llvm::mapped_iterator<std::__1::__wrap_iter<llvm::Record **>, (lambda at llvm-project/mlir/tools/mlir-tblgen/TypeDefGen.cpp:40:16), mlir::tblgen::TypeDef> >' does not return a reference [-Wrange-loop-analysis]
          for (const TypeDef &typeDef : defs)
                              ^
      llvm-project/mlir/tools/mlir-tblgen/TypeDefGen.cpp:50:10: note: use non-reference type 'mlir::tblgen::TypeDef'
          for (const TypeDef &typeDef : defs)
               ^~~~~~~~~~~~~~~~~~~~~~~~
      llvm-project/mlir/tools/mlir-tblgen/TypeDefGen.cpp:64:23: warning: loop variable 'typeDef' is always a copy because the range of type 'llvm::iterator_range<llvm::mapped_iterator<std::__1::__wrap_iter<llvm::Record **>, (lambda at llvm-project/mlir/tools/mlir-tblgen/TypeDefGen.cpp:40:16), mlir::tblgen::TypeDef> >' does not return a reference [-Wrange-loop-analysis]
        for (const TypeDef &typeDef : defs)
                            ^
      llvm-project/mlir/tools/mlir-tblgen/TypeDefGen.cpp:64:8: note: use non-reference type 'mlir::tblgen::TypeDef'
        for (const TypeDef &typeDef : defs)
             ^~~~~~~~~~~~~~~~~~~~~~~~
      2 warnings generated.
      
      [1934/2862] Building CXX object tools...Files/toyc-ch4.dir/mlir/MLIRGen.cpp.o
      llvm-project/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp:139:22: warning: loop variable 'name_value' is always a copy because the range of type 'detail::zippy<detail::zip_shortest, ArrayRef<unique_ptr<VariableExprAST, default_delete<VariableExprAST> > > &, MutableArrayRef<BlockArgument> >' does not return a reference [-Wrange-loop-analysis]
          for (const auto &name_value :
                           ^
      llvm-project/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp:139:10: note: use non-reference type 'std::__1::tuple<const std::__1::unique_ptr<toy::VariableExprAST, std::__1::default_delete<toy::VariableExprAST> > &, mlir::BlockArgument &>'
          for (const auto &name_value :
               ^~~~~~~~~~~~~~~~~~~~~~~~
      1 warning generated.
      
      [1940/2862] Building CXX object tools...Files/toyc-ch5.dir/mlir/MLIRGen.cpp.o
      llvm-project/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp:139:22: warning: loop variable 'name_value' is always a copy because the range of type 'detail::zippy<detail::zip_shortest, ArrayRef<unique_ptr<VariableExprAST, default_delete<VariableExprAST> > > &, MutableArrayRef<BlockArgument> >' does not return a reference [-Wrange-loop-analysis]
          for (const auto &name_value :
                           ^
      llvm-project/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp:139:10: note: use non-reference type 'std::__1::tuple<const std::__1::unique_ptr<toy::VariableExprAST, std::__1::default_delete<toy::VariableExprAST> > &, mlir::BlockArgument &>'
          for (const auto &name_value :
               ^~~~~~~~~~~~~~~~~~~~~~~~
      1 warning generated.
      ```
      
      Reviewed By: jpienaar
      
      Differential Revision: https://reviews.llvm.org/D94003
      7afd5cfb
    • Craig Topper's avatar
      [RISCV] Don't print zext.b alias. · 249d7de1
      Craig Topper authored
      This alias for andi x, 255 was recently added to the spec. If we
      print it, code we output can't be compiled with -fno-integrated-as
      unless the GNU assembler is also a version that supports alias.
      
      Reviewed By: lenary
      
      Differential Revision: https://reviews.llvm.org/D93826
      249d7de1
    • Sanjay Patel's avatar
      [SLP] delete unused pairwise reduction option · 3b8b2c7d
      Sanjay Patel authored
      SLP tries to model 2 forms of vector reductions: pairwise and splitting.
      From the cost model code comments, those are defined using an example as:
      
        /// Pairwise:
        ///  (v0, v1, v2, v3)
        ///  ((v0+v1), (v2+v3), undef, undef)
        /// Split:
        ///  (v0, v1, v2, v3)
        ///  ((v0+v2), (v1+v3), undef, undef)
      
      I don't know the full history of this functionality, but it was partly
      added back in D29402. There are apparently no users at this point (no
      regression tests change). X86 might have managed to work-around the need
      for this through cost model and codegen improvements.
      
      Removing this code makes it easier to continue the work that was started
      in D87416 / D88193. The alternative -- if there is some target that is
      silently using this option -- is to move this logic into LoopUtils. We
      have related/duplicate functionality there via llvm::createTargetReduction().
      
      Differential Revision: https://reviews.llvm.org/D93860
      3b8b2c7d
    • Craig Topper's avatar
      [RISCV] Match vmslt(u).vx intrinsics with a small immediate to vmsle(u).vx. · c707716c
      Craig Topper authored
      There are vmsle(u).vx and vmsle(u).vi instructions, but there is
      only vmslt(u).vx and no vmslt(u).vi. vmslt(u).vi can be emulated
      for some immediates by decrementing the immediate and using vmsle(u).vi.
      
      To avoid the user needing to know about this, this patch does this
      conversion.
      
      The assembler does the same thing for vmslt(u).vi and vmsge(u).vi
      pseudoinstructions. There is no vmsge(u).vx intrinsic or
      instruction so this patch is limited to vmslt(u).
      
      Reviewed By: frasercrmck
      
      Differential Revision: https://reviews.llvm.org/D94070
      c707716c
    • Sergey Dmitriev's avatar
      [llvm-link] fix linker behavior when linking archives with --only-needed option · 761aca1e
      Sergey Dmitriev authored
      This patch fixes linker behavior when archive is linked with other inputs
      as a library (i.e. when --only-needed option is specified). In this case library
      is expected to be normally linked first into a separate module and only after
      that linker should import required symbols from the linked library module.
      
      Reviewed By: tra
      
      Differential Revision: https://reviews.llvm.org/D92535
      761aca1e
    • Matt Arsenault's avatar
      a427f15d
    • Yitzhak Mandelbaum's avatar
      [libTooling] Add support for smart pointers to relevant Transformer `Stencil`s. · 675a2973
      Yitzhak Mandelbaum authored
      Stencils `maybeDeref` and `maybeAddressOf` are designed to handle nodes that may
      be pointers. Currently, they only handle native pointers. This patch extends the
      support to recognize smart pointers and handle them as well.
      
      Differential Revision: https://reviews.llvm.org/D93637
      675a2973
    • Jonas Devlieghere's avatar
    • Hanhan Wang's avatar
      [mlir][Linalg] Add a test case that consumer has "reduction" loops. · 30dcbb2a
      Hanhan Wang authored
      In the past, this was a missing test case and the fusion was not supported. It's
      supported after the revisit of init_tensor in Linalg.
      
      Reviewed By: nicolasvasilache
      
      Differential Revision: https://reviews.llvm.org/D94093
      30dcbb2a
    • Stephen Kelly's avatar
    • David Green's avatar