llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.97k stars 11.54k forks source link

[mlir]Test-Expand-Math Pass triggered Assertion failure "succeeded(ConcreteT::verify(getDefaultDiagnosticEmitFn(ctx), args...))" #60582

Closed CelestineSmith closed 1 year ago

CelestineSmith commented 1 year ago

MLIR built at commit https://github.com/llvm/llvm-project/commit/034bab4c Reproduced with:

mlir-opt --test-expand-math temp.mlir

temp.mlir:

  func.func @func(%a : vector<4xf32>) {
    %r = math.tanh %a : vector<4xf32>
    vector.print %r : vector<4xf32>
    return
  }

trace:

Assertion failed: (succeeded(ConcreteT::verify(getDefaultDiagnosticEmitFn(ctx), args...))), function get, file StorageUniquerSupport.h, line 153.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.  Program arguments: mlir-opt --test-expand-math temp.mlir
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  mlir-opt                 0x00000001049bcd04 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  mlir-opt                 0x00000001049bbd6c llvm::sys::RunSignalHandlers() + 112
2  mlir-opt                 0x00000001049bd39c SignalHandler(int) + 344
3  libsystem_platform.dylib 0x00000001a56894c4 _sigtramp + 56
4  libsystem_pthread.dylib  0x00000001a5671ee0 pthread_kill + 288
5  libsystem_c.dylib        0x00000001a55ac340 abort + 168
6  libsystem_c.dylib        0x00000001a55ab754 err + 0
7  mlir-opt                 0x000000010631e7f4 mlir::FloatAttr::get(mlir::Type, double) (.cold.1) + 0
8  mlir-opt                 0x0000000105c778a4 mlir::FloatAttr mlir::detail::StorageUserBase<mlir::FloatAttr, mlir::Attribute, mlir::detail::FloatAttrStorage, mlir::detail::AttributeUniquer, mlir::TypedAttr::Trait>::get<mlir::Type, llvm::APFloat>(mlir::MLIRContext*, mlir::Type, llvm::APFloat) + 296
9  mlir-opt                 0x0000000105c77940 mlir::FloatAttr::get(mlir::Type, double) + 152
10 mlir-opt                 0x00000001050e53c4 convertTanhOp(mlir::math::TanhOp, mlir::PatternRewriter&) + 72
11 mlir-opt                 0x0000000105e779d0 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>) + 1440
12 mlir-opt                 0x0000000105c322e4 mlir::applyPatternsAndFoldGreedily(llvm::MutableArrayRef<mlir::Region>, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig) + 4000
13 mlir-opt                 0x00000001059b4500 (anonymous namespace)::TestExpandMathPass::runOnOperation() + 284
14 mlir-opt                 0x0000000105be3384 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) + 420
15 mlir-opt                 0x0000000105be38b4 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) + 320
16 mlir-opt                 0x0000000105be5230 mlir::PassManager::run(mlir::Operation*) + 1148
17 mlir-opt                 0x0000000105bde6e8 performActions(llvm::raw_ostream&, bool, bool, std::__1::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, bool, bool) + 504
18 mlir-opt                 0x0000000105bde2b8 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool)::$_0>(long, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) + 704
19 mlir-opt                 0x0000000105c49834 mlir::splitAndProcessBuffer(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) + 656
20 mlir-opt                 0x0000000105bdc6e0 mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool) + 216
21 mlir-opt                 0x0000000105bdcbd4 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) + 1208
22 mlir-opt                 0x000000010485f7a4 main + 108
23 dyld                     0x00000001092e9088 start + 516
llvmbot commented 1 year ago

@llvm/issue-subscribers-mlir

Lewuathe commented 1 year ago

We have introduced the support for the vector type and confirmed the issue is not reproduced in the current HEAD branch.

https://github.com/llvm/llvm-project/commit/711c58938f36d91af1dc4209946bcf5e70869445

./bin/mlir-opt --test-expand-math temp.mlir
module {
  func.func @func(%arg0: vector<4xf32>) {
    %cst = arith.constant dense<1.000000e+00> : vector<4xf32>
    %cst_0 = arith.constant dense<2.000000e+00> : vector<4xf32>
    %cst_1 = arith.constant dense<0.000000e+00> : vector<4xf32>
    %0 = arith.mulf %arg0, %cst_0 : vector<4xf32>
    %1 = arith.negf %0 : vector<4xf32>
    %2 = math.exp %1 : vector<4xf32>
    %3 = arith.subf %cst, %2 : vector<4xf32>
    %4 = arith.addf %2, %cst : vector<4xf32>
    %5 = arith.divf %3, %4 : vector<4xf32>
    %6 = math.exp %0 : vector<4xf32>
    %7 = arith.subf %6, %cst : vector<4xf32>
    %8 = arith.addf %6, %cst : vector<4xf32>
    %9 = arith.divf %7, %8 : vector<4xf32>
    %10 = arith.cmpf oge, %arg0, %cst_1 : vector<4xf32>
    %11 = arith.select %10, %5, %9 : vector<4xi1>, vector<4xf32>
    vector.print %11 : vector<4xf32>
    return
  }
}