Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mlir] Convert-openacc-to-scf triggers crashes in OperationLegalizer #60058

Closed
CelestineSmith opened this issue Jan 16, 2023 · 4 comments
Closed
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mlir

Comments

@CelestineSmith
Copy link

CelestineSmith commented Jan 16, 2023

Hi, I was trying mlir-opt --convert-openacc-to-scf on the following temp.mlir.

It crashed, the log is as follows:

Assertion failed: ((replacedRoot() || updatedRootInPlace()) && "expected pattern to replace the root operation"), function legalizePatternResult, file DialectConversion.cpp, line 2036.
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 --convert-openacc-to-scf 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                 0x00000001003b05bc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  mlir-opt                 0x00000001003af624 llvm::sys::RunSignalHandlers() + 112
2  mlir-opt                 0x00000001003b0c54 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                 0x0000000101ce7198 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>::callback_fn<(anonymous namespace)::OperationLegalizer::legalizeWithPattern(mlir::Operation*, mlir::ConversionPatternRewriter&)::$_20>(long, mlir::Pattern const&) (.cold.2) + 0
8  mlir-opt                 0x00000001015fed88 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>::callback_fn<(anonymous namespace)::OperationLegalizer::legalizeWithPattern(mlir::Operation*, mlir::ConversionPatternRewriter&)::$_20>(long, mlir::Pattern const&) + 184
9  mlir-opt                 0x000000010184fa78 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&)>) + 1096
10 mlir-opt                 0x00000001015fd4b0 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) + 1948
11 mlir-opt                 0x00000001015f6b1c (anonymous namespace)::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>, llvm::function_ref<void (mlir::Diagnostic&)>) + 928
12 mlir-opt                 0x00000001015f8d18 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget&, mlir::FrozenRewritePatternSet const&, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>*) + 80
13 mlir-opt                 0x000000010127f674 (anonymous namespace)::ConvertOpenACCToSCFPass::runOnOperation() + 820
14 mlir-opt                 0x00000001015bb4dc mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) + 420
15 mlir-opt                 0x00000001015bba0c mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) + 320
16 mlir-opt                 0x00000001015bd388 mlir::PassManager::run(mlir::Operation*) + 1148
17 mlir-opt                 0x00000001015b6840 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                 0x00000001015b6410 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                 0x000000010162102c 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                 0x00000001015b4838 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                 0x00000001015b4d2c mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) + 1208
22 mlir-opt                 0x00000001002530a0 main + 108
23 dyld                     0x0000000104c9d088 start + 516

Building commit: db6961d

@EugeneZelenko EugeneZelenko added mlir crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Jan 16, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Jan 16, 2023

@llvm/issue-subscribers-mlir

@python3kgae
Copy link
Contributor

Cannot find the temp.mlir :(

@CelestineSmith
Copy link
Author

func.func @func(%arg0: memref<10xf32, #spirv.storage_class<StorageBuffer>>) {
  %true = arith.constant true
  acc.update if(%true) host(%arg0 : memref<10xf32, #spirv.storage_class<StorageBuffer>>)
  return
}

Sorry for that

@python3kgae
Copy link
Contributor

Created PR https://reviews.llvm.org/D142286

CarlosAlbertoEnciso pushed a commit to SNSystems/llvm-debuginfo-analyzer that referenced this issue Jan 24, 2023
…nPatterns

Fixes #60058  llvm/llvm-project#60058
It hit assert when legalizePatternResult on success of ExpandIfCondition which did nothing just return success when if condition is constant.

Added RemoveConstantIfCondition to remove the if cond by getCanonicalizationPatterns.
Also remove the check for constant if cond in ExpandIfCondition and
change check ifCond to assert because only op with ifCond will need legalize in ConvertOpenACCToSCFPass

Differential Revision: https://reviews.llvm.org/D142286
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mlir
Projects
None yet
Development

No branches or pull requests

4 participants