<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/61863>61863</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [MLIR]`tosa-to-linalg` pass crashes in `FastMathFlagsAttr` with LLVM ERROR: can't create Attribute 'mlir::arith::FastMathFlagsAttr' 
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          BealZephyr
      </td>
    </tr>
</table>

<pre>
    Test commit: [00701d3](https://github.com/llvm/llvm-project/commit/b206145323fafc75d82efcc7e154218e37480953)

Steps to reproduce:
```
mlir-opt test.mlir -pass-pipeline=builtin.module(func.func(tosa-to-linalg))
```
Test case:
```
module {
  llvm.func @main(%arg0:f32)  {
    %1 = math.log2 %arg0 : f32
    llvm.return 
  }
}
```
Crash trace:
```
LLVM ERROR: can't create Attribute 'mlir::arith::FastMathFlagsAttr' because storage uniquer isn't initialized: the dialect was likely not loaded, or the attribute wasn't added with addAttributes<...>() in the Dialect::initialize() method.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /home/ty/llvm-project/build/bin/mlir-opt test.mlir -pass-pipeline=builtin.module(func.func(tosa-to-linalg))
1.      MLIR Parser: custom op parser 'builtin.module'
2.      MLIR Parser: custom op parser 'llvm.func'
3.     MLIR Parser: custom op parser 'math.log2'
 #0 0x000055c5186c65fa llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/ty/llvm-project/build/bin/mlir-opt+0x22b5fa)
 #1 0x000055c5186c388c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fc15e3b6980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #3 0x00007fc15d067e87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #4 0x00007fc15d0697f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0
 #5 0x000055c5186dff3d llvm::report_fatal_error(llvm::Twine const&, bool) (/home/ty/llvm-project/build/bin/mlir-opt+0x244f3d)
 #6 0x000055c51887b1c0 mlir::arith::FastMathFlagsAttr mlir::detail::StorageUserBase<mlir::arith::FastMathFlagsAttr, mlir::Attribute, mlir::arith::detail::FastMathFlagsAttrStorage, mlir::detail::AttributeUniquer>::get<mlir::arith::FastMathFlags>(mlir::MLIRContext*, mlir::arith::FastMathFlags) (/home/ty/llvm-project/build/bin/mlir-opt+0x3e01c0)
 #7 0x000055c518fed152 mlir::math::AbsFOp::populateDefaultAttrs(mlir::OperationName const&, mlir::NamedAttrList&) (/home/ty/llvm-project/build/bin/mlir-opt+0xb52152)
 #8 0x000055c51a17edab mlir::Operation::create(mlir::Location, mlir::OperationName, mlir::TypeRange, mlir::ValueRange, mlir::NamedAttrList&&, mlir::BlockRange, mlir::RegionRange) (/home/ty/llvm-project/build/bin/mlir-opt+0x1ce3dab)
 #9 0x000055c51a17f18c mlir::Operation::create(mlir::OperationState const&) (/home/ty/llvm-project/build/bin/mlir-opt+0x1ce418c)
#10 0x000055c51a0e918c mlir::OpBuilder::create(mlir::OperationState const&) (/home/ty/llvm-project/build/bin/mlir-opt+0x1c4e18c)
#11 0x000055c51a405b79 (anonymous namespace)::OperationParser::parseOperation() Parser.cpp:0:0
#12 0x000055c51a4078cd (anonymous namespace)::OperationParser::parseBlockBody(mlir::Block*) Parser.cpp:0:0
#13 0x000055c51a4080e8 (anonymous namespace)::OperationParser::parseRegionBody(mlir::Region&, llvm::SMLoc, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) Parser.cpp:0:0
#14 0x000055c51a4084bc (anonymous namespace)::OperationParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) Parser.cpp:0:0
#15 0x000055c51a409b93 (anonymous namespace)::CustomOpAsmParser::parseOptionalRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) Parser.cpp:0:0
#16 0x000055c518f01453 mlir::LLVM::LLVMFuncOp::parse(mlir::OpAsmParser&, mlir::OperationState&) (/home/ty/llvm-project/build/bin/mlir-opt+0xa66453)
#17 0x000055c51a404d74 (anonymous namespace)::OperationParser::parseOperation() Parser.cpp:0:0
#18 0x000055c51a4078cd (anonymous namespace)::OperationParser::parseBlockBody(mlir::Block*) Parser.cpp:0:0
#19 0x000055c51a4080e8 (anonymous namespace)::OperationParser::parseRegionBody(mlir::Region&, llvm::SMLoc, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) Parser.cpp:0:0
#20 0x000055c51a4084bc (anonymous namespace)::OperationParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) Parser.cpp:0:0
#21 0x000055c51a409b3c (anonymous namespace)::CustomOpAsmParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) Parser.cpp:0:0
#22 0x000055c51a11a4b8 mlir::ModuleOp::parse(mlir::OpAsmParser&, mlir::OperationState&) (/home/ty/llvm-project/build/bin/mlir-opt+0x1c7f4b8)
#23 0x000055c51a404d74 (anonymous namespace)::OperationParser::parseOperation() Parser.cpp:0:0
#24 0x000055c51a406db0 mlir::parseAsmSourceFile(llvm::SourceMgr const&, mlir::Block*, mlir::ParserConfig const&, mlir::AsmParserState*, mlir::AsmParserCodeCompleteContext*) (/home/ty/llvm-project/build/bin/mlir-opt+0x1f6bdb0)
#25 0x000055c519fdade4 mlir::parseSourceFile(std::shared_ptr<llvm::SourceMgr> const&, mlir::Block*, mlir::ParserConfig const&, mlir::LocationAttr*) (/home/ty/llvm-project/build/bin/mlir-opt+0x1b3fde4)
#26 0x000055c519fda086 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#27 0x000055c519fda971 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPool*) MlirOptMain.cpp:0:0
#28 0x000055c519fdab61 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::'lambda'(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#29 0x000055c51a0aca70 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (/home/ty/llvm-project/build/bin/mlir-opt+0x1c11a70)
#30 0x000055c519fd5c83 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/home/ty/llvm-project/build/bin/mlir-opt+0x1b3ac83)
#31 0x000055c519fd84ae mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) (/home/ty/llvm-project/build/bin/mlir-opt+0x1b3d4ae)
#32 0x000055c518692560 main (/home/ty/llvm-project/build/bin/mlir-opt+0x1f7560)
#33 0x00007fc15d04ac87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0
#34 0x000055c5186a53ca _start (/home/ty/llvm-project/build/bin/mlir-opt+0x20a3ca)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWklz2zj2_zTwBWUVCHA9-CDLVv3_U_bEZaf70BcVCIASJiTBAcC2NZ9-CqAsEfQSJUoynp6qxCKxvPd7OxZSY-S6FeICJJcguTqjvd0ofXEpaP2H6DZbfVYqvr34LIyFTDWNtIDMIUguEcpQxAlIrgDON9Z2BpA5wEuAl2tpN305Y6oBeFnXfz7_nHda_UMwC_ByRwovS4zSKE4IJhWtWJbwHIuKsUxESYyjXJAszlGREIALgK4Amg9_H6zoDLQKatFpxXsmHPdhQIp2__xrU0t9rjoLrTB25t7geUeNOe9kJ2rZCkCuyl7WVrazRvG-FgDnVd-ymfsDcG6VoedWndeypfXa4dhDCTkNOqLmbSiePATZ5fAOodOK5wNBjBoqW4BzgBOq1wiQeUUwwAUcT4AQ4CSCgFzBhtrNrFZrDHczoLOMm7Mf68lrYXvdwudWkF3twO0fQpQLTc0GWk3f1unNze-38Pr-_tO9Y8loC3BmIdOCWgHn1mpZ9lZAgDOnb0eFzKmWdjM8Lqmxt9RuljVdGzcc4AyWgtHeCGis0nQtYN_Kf_ZCQ2kG6rKVVtJa_ktwx9RuBOSS1oJZ-EgNrOUXUW9hqyysFeWCA7yASvtxdI_oke6oUc4Fh4_SbtzjHrIBZDGbzQC59oYooGw9hauB0wD_gGQ3qBF2o_hs0M3dzfX84RqavmykhRSW_do5qdLWues3B4o0phcG4CWkLYeyZXXPhcfEvJ1Kyr54W82eA4OyL5D3Tbc3HpoBVNxptda0gVSv-0a01vgwxsuNagTAS7t9ydpFBXe_zi2XPzGOIgfw9ub_7-Ed1UZo71S9saqBqoOdb3PONCWfDdPxDB43fx9t-6lk5sIEHjF3H237uRBggiB6QgihJGFJlKcsTSrqo27wFLM1w8Odlq31pvns4wrnh0GaPq6UsVrQBuDUua1srXMr713fbiCAL9ETxmVS0b2GHdZogpXkOYM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