Skip to content

Conversation

@thurstond
Copy link
Contributor

Reverts #135429 due buildbot breakage: https://lab.llvm.org/buildbot/#/builders/169/builds/10405

Based on the ASan output, I think after the replaceOp on line 775, it's no longer valid to do getSize() on sliceOp:

   775      rewriter.replaceOp(sliceOp, newSliceOp.getResult());
   776
   777      // Remove const_shape size op when it no longer has use point.
   778      Operation *sizeConstShape = sliceOp.getSize().getDefiningOp();

@thurstond thurstond added the skip-precommit-approval PR for CI feedback, not intended for review label Apr 13, 2025
@thurstond thurstond requested a review from sahas3 April 13, 2025 07:07
@thurstond thurstond merged commit d6e2aee into main Apr 13, 2025
9 of 13 checks passed
@thurstond thurstond deleted the revert-135429-sliceShapeCanonicalize branch April 13, 2025 07:07
@llvmbot
Copy link
Member

llvmbot commented Apr 13, 2025

@llvm/pr-subscribers-mlir-tosa

@llvm/pr-subscribers-mlir

Author: Thurston Dang (thurstond)

Changes

Reverts llvm/llvm-project#135429 due buildbot breakage: https://lab.llvm.org/buildbot/#/builders/169/builds/10405

Based on the ASan output, I think after the replaceOp on line 775, it's no longer valid to do getSize() on sliceOp:

   775      rewriter.replaceOp(sliceOp, newSliceOp.getResult());
   776
   777      // Remove const_shape size op when it no longer has use point.
   778      Operation *sizeConstShape = sliceOp.getSize().getDefiningOp();

Full diff: https://github.com/llvm/llvm-project/pull/135525.diff

2 Files Affected:

  • (modified) mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp (+1-54)
  • (modified) mlir/test/Dialect/Tosa/canonicalize.mlir (-15)
diff --git a/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp b/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp
index 84f89bfd7f2d3..c4ef7d0bb9ff5 100644
--- a/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp
+++ b/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp
@@ -731,62 +731,9 @@ struct ConcatSliceOptimization : public OpRewritePattern<tosa::SliceOp> {
   }
 };
 
-// Update size operand of tosa.slice if size has dynamic dims but corresponding
-// output dim is static
-struct SliceDynamicSizeCanonicalization
-    : public OpRewritePattern<tosa::SliceOp> {
-  using OpRewritePattern<tosa::SliceOp>::OpRewritePattern;
-
-  LogicalResult matchAndRewrite(tosa::SliceOp sliceOp,
-                                PatternRewriter &rewriter) const override {
-    ShapedType resultType = cast<ShapedType>(sliceOp.getType());
-
-    ElementsAttr sizeElems;
-    if (!matchPattern(sliceOp.getSize(), m_Constant(&sizeElems))) {
-      return rewriter.notifyMatchFailure(
-          sliceOp, "size of slice must be a static ranked shape");
-    }
-
-    llvm::SmallVector<int64_t> sliceSizes =
-        llvm::to_vector(sizeElems.getValues<int64_t>());
-
-    bool replaceSliceSize{false};
-    // if size op has -1 indicating dynamic shape but corresponding dim on the
-    // output is statically known, update size to match with known output dim
-    // shape
-    for (const auto &[index, size] : llvm::enumerate(sliceSizes)) {
-      if (size == -1 && !resultType.isDynamicDim(index)) {
-        sliceSizes[index] = resultType.getDimSize(index);
-        replaceSliceSize = true;
-      }
-    }
-
-    if (!replaceSliceSize) {
-      return rewriter.notifyMatchFailure(
-          sliceOp, "no dimension of size of slice is dynamic that resolves "
-                   "to static output shape");
-    }
-
-    auto size_op = getTosaConstShape(rewriter, sliceOp.getLoc(), sliceSizes);
-    auto newSliceOp = rewriter.create<tosa::SliceOp>(
-        sliceOp.getLoc(), sliceOp.getType(), sliceOp.getInput1(),
-        sliceOp.getStart(), size_op);
-
-    rewriter.replaceOp(sliceOp, newSliceOp.getResult());
-
-    // Remove const_shape size op when it no longer has use point.
-    Operation *sizeConstShape = sliceOp.getSize().getDefiningOp();
-    if (sizeConstShape->getResult(0).hasOneUse())
-      rewriter.eraseOp(sizeConstShape);
-
-    return success();
-  }
-};
-
 void SliceOp::getCanonicalizationPatterns(RewritePatternSet &results,
                                           MLIRContext *context) {
-  results.add<ConcatSliceOptimization, SliceDynamicSizeCanonicalization>(
-      context);
+  results.add<ConcatSliceOptimization>(context);
 }
 
 //===----------------------------------------------------------------------===//
diff --git a/mlir/test/Dialect/Tosa/canonicalize.mlir b/mlir/test/Dialect/Tosa/canonicalize.mlir
index a754a46be603f..b366b4f1e4fd4 100644
--- a/mlir/test/Dialect/Tosa/canonicalize.mlir
+++ b/mlir/test/Dialect/Tosa/canonicalize.mlir
@@ -1212,18 +1212,3 @@ func.func @do_not_fold_intdiv_division_by_0() -> tensor<1x24x2xi32> {
   %16 = tosa.intdiv %4, %1 : (tensor<1x24x2xi32>, tensor<1x24x2xi32>) -> tensor<1x24x2xi32>
   return %16 : tensor<1x24x2xi32>
 }
-
-
-// ----
-// CHECK-LABEL:   func.func @slice_dynamic_size_static_output_canonicalize(
-// CHECK-SAME:                     %[[ARG0:.*]]: tensor<2x60x59x?xf32>) -> tensor<2x60x58x?xf32> {
-// CHECK:           %[[START:.*]] = tosa.const_shape  {values = dense<0> : tensor<4xindex>} : () -> !tosa.shape<4>
-// CHECK:           %[[SIZE:.*]] = tosa.const_shape  {values = dense<[2, 60, 58, -1]> : tensor<4xindex>} : () -> !tosa.shape<4>
-// CHECK:           %[[SLICE:.*]] = tosa.slice %[[ARG0]], %[[START]], %[[SIZE]] : (tensor<2x60x59x?xf32>, !tosa.shape<4>, !tosa.shape<4>) -> tensor<2x60x58x?xf32>
-// CHECK:           return %[[SLICE]]
-func.func @slice_dynamic_size_static_output_canonicalize(%arg0: tensor<2x60x59x?xf32>) -> tensor<2x60x58x?xf32> {
-    %0 = tosa.const_shape  {values = dense<0> : tensor<4xindex>} : () -> !tosa.shape<4>
-    %1 = tosa.const_shape  {values = dense<[-1, 60, 58, -1]> : tensor<4xindex>} : () -> !tosa.shape<4>
-    %2 = tosa.slice %arg0, %0, %1 : (tensor<2x60x59x?xf32>, !tosa.shape<4>, !tosa.shape<4>) -> tensor<2x60x58x?xf32>
-    return %2 : tensor<2x60x58x?xf32>
-  }

@llvm-ci
Copy link
Collaborator

llvm-ci commented Apr 13, 2025

LLVM Buildbot has detected a new failure on builder sanitizer-aarch64-linux-bootstrap-ubsan running on sanitizer-buildbot10 while building mlir at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/85/builds/7596

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld.lld: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 87692 tests, 72 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80..
FAIL: LLVM :: tools/llvm-reduce/flaky-interestingness.ll (78047 of 87692)
******************** TEST 'LLVM :: tools/llvm-reduce/flaky-interestingness.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
rm -f /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/test/tools/llvm-reduce/Output/flaky-interestingness.ll.tmp # RUN: at line 2
+ rm -f /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/test/tools/llvm-reduce/Output/flaky-interestingness.ll.tmp
llvm-reduce -j=1 --delta-passes=instructions --test "/usr/bin/python3" --test-arg /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/tools/llvm-reduce/Inputs/flaky-test.py --test-arg /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/test/tools/llvm-reduce/Output/flaky-interestingness.ll.tmp /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/tools/llvm-reduce/flaky-interestingness.ll -o /dev/null 2>&1 | /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/tools/llvm-reduce/flaky-interestingness.ll # RUN: at line 3
+ llvm-reduce -j=1 --delta-passes=instructions --test /usr/bin/python3 --test-arg /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/tools/llvm-reduce/Inputs/flaky-test.py --test-arg /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/test/tools/llvm-reduce/Output/flaky-interestingness.ll.tmp /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/tools/llvm-reduce/flaky-interestingness.ll -o /dev/null
+ /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/tools/llvm-reduce/flaky-interestingness.ll

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
Slowest Tests:
--------------------------------------------------------------------------
188.45s: Clang :: Driver/fsanitize.c
143.45s: Clang :: Driver/arm-cortex-cpus-2.c
139.34s: Clang :: Driver/arm-cortex-cpus-1.c
92.20s: Clang :: Driver/clang_f_opts.c
89.58s: Clang :: OpenMP/target_defaultmap_codegen_01.cpp
88.89s: Clang :: Analysis/a_flaky_crash.cpp
87.05s: Clang :: Driver/linux-ld.c
83.71s: Clang :: Driver/x86-target-features.c
81.14s: Clang :: Driver/cl-options.c
73.04s: Clang :: Preprocessor/riscv-target-features.c
69.78s: Clang :: OpenMP/target_update_codegen.cpp
64.42s: Clang :: Driver/debug-options.c
58.35s: Clang :: Preprocessor/arm-target-features.c
58.27s: Clang :: Preprocessor/aarch64-target-features.c
52.03s: Clang :: Driver/riscv-arch.c
49.81s: Clang :: Preprocessor/predefined-arch-macros.c
49.37s: Clang :: Driver/amdgpu-macros.cl
48.21s: Clang :: Driver/aarch64-fp16.c
48.11s: Clang :: Driver/fopenmp.c
48.04s: Clang :: Driver/cl-outputs.c

Step 11 (stage2/ubsan check) failure: stage2/ubsan check (failure)
...
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld.lld: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 87692 tests, 72 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80..
FAIL: LLVM :: tools/llvm-reduce/flaky-interestingness.ll (78047 of 87692)
******************** TEST 'LLVM :: tools/llvm-reduce/flaky-interestingness.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
rm -f /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/test/tools/llvm-reduce/Output/flaky-interestingness.ll.tmp # RUN: at line 2
+ rm -f /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/test/tools/llvm-reduce/Output/flaky-interestingness.ll.tmp
llvm-reduce -j=1 --delta-passes=instructions --test "/usr/bin/python3" --test-arg /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/tools/llvm-reduce/Inputs/flaky-test.py --test-arg /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/test/tools/llvm-reduce/Output/flaky-interestingness.ll.tmp /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/tools/llvm-reduce/flaky-interestingness.ll -o /dev/null 2>&1 | /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/tools/llvm-reduce/flaky-interestingness.ll # RUN: at line 3
+ llvm-reduce -j=1 --delta-passes=instructions --test /usr/bin/python3 --test-arg /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/tools/llvm-reduce/Inputs/flaky-test.py --test-arg /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/test/tools/llvm-reduce/Output/flaky-interestingness.ll.tmp /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/tools/llvm-reduce/flaky-interestingness.ll -o /dev/null
+ /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/tools/llvm-reduce/flaky-interestingness.ll

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
Slowest Tests:
--------------------------------------------------------------------------
188.45s: Clang :: Driver/fsanitize.c
143.45s: Clang :: Driver/arm-cortex-cpus-2.c
139.34s: Clang :: Driver/arm-cortex-cpus-1.c
92.20s: Clang :: Driver/clang_f_opts.c
89.58s: Clang :: OpenMP/target_defaultmap_codegen_01.cpp
88.89s: Clang :: Analysis/a_flaky_crash.cpp
87.05s: Clang :: Driver/linux-ld.c
83.71s: Clang :: Driver/x86-target-features.c
81.14s: Clang :: Driver/cl-options.c
73.04s: Clang :: Preprocessor/riscv-target-features.c
69.78s: Clang :: OpenMP/target_update_codegen.cpp
64.42s: Clang :: Driver/debug-options.c
58.35s: Clang :: Preprocessor/arm-target-features.c
58.27s: Clang :: Preprocessor/aarch64-target-features.c
52.03s: Clang :: Driver/riscv-arch.c
49.81s: Clang :: Preprocessor/predefined-arch-macros.c
49.37s: Clang :: Driver/amdgpu-macros.cl
48.21s: Clang :: Driver/aarch64-fp16.c
48.11s: Clang :: Driver/fopenmp.c
48.04s: Clang :: Driver/cl-outputs.c


sahas3 added a commit to sahas3/llvm-project that referenced this pull request Apr 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mlir:tosa mlir skip-precommit-approval PR for CI feedback, not intended for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants