Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Dialect conversion crash: unlinked block #324

Open
bondhugula opened this issue Dec 15, 2019 · 0 comments
Open

Dialect conversion crash: unlinked block #324

bondhugula opened this issue Dec 15, 2019 · 0 comments
Assignees

Comments

@bondhugula
Copy link
Contributor

This should be reproducible with the trunk: f33f6e1. More inspection shows that we have a block with a null parent region. (This was likely exposed from the folding being done during dialect conversion.) Although -convert-linalg-to-llvm will go away, there is likely an underlying issue.

func @crash(%arg0: memref<256x256xf32>, %arg1: memref<256x256xf32>, %arg2: memref<256x256xf32>) {
  affine.for %arg3 = 0 to 2 {
    affine.for %arg4 = 0 to 4 {
      affine.for %arg5 = (d0) -> (d0 * 32)(%arg3) to (d0) -> (d0 * 32   32)(%arg3) {
      }
    }
  }
  return 
}
$ mlir-opt -debug  -convert-linalg-to-llvm   /tmp/crash.mlir 
Args: ../../llvm-project-bondhugula/build/bin/mlir-opt -debug -convert-linalg-to-llvm /tmp/crash.mlir 
	discovered a new reachable node ^bb0
	discovered a new reachable node ^bb0
	discovered a new reachable node ^bb0
	discovered a new reachable node ^bb0
	discovered a new reachable node ^bb0
Legalizing operation : module
-- Success : Operation marked legal by the target
Legalizing operation : func
-* Applying rewrite pattern 'func -> ()'.
** Inserting operation : llvm.func
** Inserting operation : llvm.load
** Inserting operation : llvm.load
** Inserting operation : llvm.load
** Erasing operation : func
Legalizing operation : llvm.func
-- Success : Operation marked legal by the target
Legalizing operation : llvm.load
-- Success : Operation marked legal by the target
Legalizing operation : llvm.load
-- Success : Operation marked legal by the target
Legalizing operation : llvm.load
-- Success : Operation marked legal by the target
Legalizing operation : affine.for
-* Applying rewrite pattern 'affine.for -> ()'.
** Inserting operation : std.constant
** Inserting operation : std.constant
** Inserting operation : std.constant
** Inserting operation : loop.for
** Erasing operation : affine.for
Legalizing operation : std.constant
-* Applying rewrite pattern 'std.constant -> ()'.
** Inserting operation : llvm.mlir.constant
** Replacing operation : std.constant
Legalizing operation : llvm.mlir.constant
-- Success : Operation marked legal by the target
Legalizing operation : std.constant
-* Applying rewrite pattern 'std.constant -> ()'.
** Inserting operation : llvm.mlir.constant
** Replacing operation : std.constant
Legalizing operation : llvm.mlir.constant
-- Success : Operation marked legal by the target
Legalizing operation : std.constant
-* Applying rewrite pattern 'std.constant -> ()'.
** Inserting operation : llvm.mlir.constant
** Replacing operation : std.constant
Legalizing operation : llvm.mlir.constant
-- Success : Operation marked legal by the target
Legalizing operation : loop.for
-* Applying rewrite pattern 'loop.for -> ()'.
** Inserting operation : std.addi
** Inserting operation : std.br
** Inserting operation : std.br
** Inserting operation : std.cmpi
** Inserting operation : std.cond_br
** Erasing operation : loop.for
Legalizing operation : std.addi
-* Applying rewrite pattern 'std.addi -> ()'.
** Inserting operation : llvm.add
** Replacing operation : std.addi
Legalizing operation : llvm.add
-- Success : Operation marked legal by the target
Legalizing operation : std.br
-* Applying rewrite pattern 'std.br -> ()'.
** Inserting operation : llvm.br
** Replacing operation : std.br
Legalizing operation : llvm.br
-- Success : Operation marked legal by the target
Legalizing operation : std.br
-* Applying rewrite pattern 'std.br -> ()'.
** Inserting operation : llvm.br
** Replacing operation : std.br
Legalizing operation : llvm.br
-- Success : Operation marked legal by the target
Legalizing operation : std.cmpi
-* Applying rewrite pattern 'std.cmpi -> ()'.
** Inserting operation : llvm.icmp
** Replacing operation : std.cmpi
Legalizing operation : llvm.icmp
-- Success : Operation marked legal by the target
Legalizing operation : std.cond_br
-* Applying rewrite pattern 'std.cond_br -> ()'.
** Inserting operation : llvm.cond_br
** Replacing operation : std.cond_br
Legalizing operation : llvm.cond_br
-- Success : Operation marked legal by the target
Legalizing operation : affine.for
-* Applying rewrite pattern 'affine.for -> ()'.
** Inserting operation : std.constant
** Inserting operation : std.constant
** Inserting operation : std.constant
** Inserting operation : loop.for
** Erasing operation : affine.for
Legalizing operation : std.constant
-* Applying rewrite pattern 'std.constant -> ()'.
** Inserting operation : llvm.mlir.constant
** Replacing operation : std.constant
Legalizing operation : llvm.mlir.constant
-- Success : Operation marked legal by the target
Legalizing operation : std.constant
-* Applying rewrite pattern 'std.constant -> ()'.
** Inserting operation : llvm.mlir.constant
** Replacing operation : std.constant
Legalizing operation : llvm.mlir.constant
-- Success : Operation marked legal by the target
Legalizing operation : std.constant
-* Applying rewrite pattern 'std.constant -> ()'.
** Inserting operation : llvm.mlir.constant
** Replacing operation : std.constant
Legalizing operation : llvm.mlir.constant
-- Success : Operation marked legal by the target
Legalizing operation : loop.for
-* Applying rewrite pattern 'loop.for -> ()'.
** Inserting operation : std.addi
** Inserting operation : std.br
** Inserting operation : std.br
** Inserting operation : std.cmpi
** Inserting operation : std.cond_br
** Erasing operation : loop.for
Legalizing operation : std.addi
-* Applying rewrite pattern 'std.addi -> ()'.
** Inserting operation : llvm.add
** Replacing operation : std.addi
Legalizing operation : llvm.add
-- Success : Operation marked legal by the target
Legalizing operation : std.br
-* Applying rewrite pattern 'std.br -> ()'.
** Inserting operation : llvm.br
** Replacing operation : std.br
Legalizing operation : llvm.br
-- Success : Operation marked legal by the target
Legalizing operation : std.br
-* Applying rewrite pattern 'std.br -> ()'.
** Inserting operation : llvm.br
** Replacing operation : std.br
Legalizing operation : llvm.br
-- Success : Operation marked legal by the target
Legalizing operation : std.cmpi
-* Applying rewrite pattern 'std.cmpi -> ()'.
** Inserting operation : llvm.icmp
** Replacing operation : std.cmpi
Legalizing operation : llvm.icmp
-- Success : Operation marked legal by the target
Legalizing operation : std.cond_br
-* Applying rewrite pattern 'std.cond_br -> ()'.
** Inserting operation : llvm.cond_br
** Replacing operation : std.cond_br
Legalizing operation : llvm.cond_br
-- Success : Operation marked legal by the target
Legalizing operation : affine.for
Stack dump:
0.	Program arguments: ../../llvm-project-bondhugula/build/bin/mlir-opt -debug -convert-linalg-to-llvm /tmp/crash.mlir 
 #0 0x0000000000d9f609 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/uday/llvm-project-bondhugula/llvm/lib/Support/Unix/Signals.inc:548:11
 #1 0x0000000000d9f7b9 PrintStackTraceSignalHandler(void*) /home/uday/llvm-project-bondhugula/llvm/lib/Support/Unix/Signals.inc:609:1
 #2 0x0000000000d9e016 llvm::sys::RunSignalHandlers() /home/uday/llvm-project-bondhugula/llvm/lib/Support/Signals.cpp:67:5
 #3 0x0000000000d9ff4b SignalHandler(int) /home/uday/llvm-project-bondhugula/llvm/lib/Support/Unix/Signals.inc:390:1
 #4 0x00007fd4e19ccc70 __restore_rt (/lib64/libpthread.so.0 0x12c70)
 #5 0x0000000000cc642c mlir::Region::getParentOp() /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/IR/Region.cpp:50:43
 #6 0x00000000004d3cc5 isFunctionRegion(mlir::Region*) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Dialect/AffineOps/AffineOps.cpp:112:28
 #7 0x00000000004d3c6d mlir::isTopLevelValue(mlir::Value*) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Dialect/AffineOps/AffineOps.cpp:120:5
 #8 0x00000000004d3f62 mlir::isValidSymbol(mlir::Value*) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Dialect/AffineOps/AffineOps.cpp:203:3
 #9 0x00000000004e5572 void canonicalizePromotedSymbols<mlir::AffineMap>(mlir::AffineMap*, llvm::SmallVectorImpl<mlir::Value*>*) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Dialect/AffineOps/AffineOps.cpp:639:11
#10 0x00000000004d6639 void canonicalizeMapOrSetAndOperands<mlir::AffineMap>(mlir::AffineMap*, llvm::SmallVectorImpl<mlir::Value*>*) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Dialect/AffineOps/AffineOps.cpp:679:33
#11 0x00000000004d655d mlir::canonicalizeMapAndOperands(mlir::AffineMap*, llvm::SmallVectorImpl<mlir::Value*>*) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Dialect/AffineOps/AffineOps.cpp:744:1
#12 0x00000000004dac63 canonicalizeLoopBounds(mlir::AffineForOp) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Dialect/AffineOps/AffineOps.cpp:1411:38
#13 0x00000000004daaa4 mlir::AffineForOp::fold(llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Dialect/AffineOps/AffineOps.cpp:1448:23
#14 0x00000000004f845a mlir::FoldingHook<mlir::AffineForOp, false, void>::foldHook(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/include/mlir/IR/OpDefinition.h:276:35
#15 0x0000000000cb7037 mlir::Operation::fold(llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/IR/Operation.cpp:646:31
#16 0x0000000000c6bb31 mlir::OpBuilder::tryFold(mlir::Operation*, llvm::SmallVectorImpl<mlir::Value*>&) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/IR/Builders.cpp:366:18
#17 0x0000000000a11a30 (anonymous namespace)::OperationLegalizer::legalizeWithFold(mlir::Operation*, mlir::ConversionPatternRewriter&) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Transforms/DialectConversion.cpp:1042:23
#18 0x0000000000a1154a (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Transforms/DialectConversion.cpp:1012:17
#19 0x0000000000a110e3 (anonymous namespace)::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Transforms/DialectConversion.cpp:1346:26
#20 0x0000000000a0c75b (anonymous namespace)::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>, mlir::TypeConverter*) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Transforms/DialectConversion.cpp:1393:16
#21 0x0000000000a0c924 mlir::applyFullConversion(llvm::ArrayRef<mlir::Operation*>, mlir::ConversionTarget&, mlir::OwningRewritePatternList const&, mlir::TypeConverter*) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Transforms/DialectConversion.cpp:1702:22
#22 0x0000000000a0c982 mlir::applyFullConversion(mlir::Operation*, mlir::ConversionTarget&, mlir::OwningRewritePatternList const&, mlir::TypeConverter*) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Transforms/DialectConversion.cpp:1708:10
#23 0x0000000000529d95 (anonymous namespace)::ConvertLinalgToLLVMPass::runOnModule() /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp:547:14
#24 0x0000000000529bd6 mlir::ModulePass<(anonymous namespace)::ConvertLinalgToLLVMPass>::runOnOperation() /home/uday/llvm-project-bondhugula/llvm/projects/mlir/include/mlir/Pass/Pass.h:323:48
#25 0x0000000000733e7d mlir::Pass::run(mlir::Operation*, mlir::AnalysisManager) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Pass/Pass.cpp:75:3
#26 0x0000000000734b97 mlir::OpPassManager::run(mlir::Operation*, mlir::AnalysisManager) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Pass/Pass.cpp:228:22
#27 0x0000000000736361 mlir::PassManager::run(mlir::ModuleOp) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Pass/Pass.cpp:582:28
#28 0x00000000006f3336 performActions(llvm::raw_ostream&, bool, bool, llvm::SourceMgr&, mlir::MLIRContext*, mlir::PassPipelineCLParser const&) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Support/MlirOptMain.cpp:66:17
#29 0x00000000006f3190 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, bool, bool, mlir::PassPipelineCLParser const&) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Support/MlirOptMain.cpp:91:12
#30 0x00000000006f305d mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, mlir::PassPipelineCLParser const&, bool, bool, bool) /home/uday/llvm-project-bondhugula/llvm/projects/mlir/lib/Support/MlirOptMain.cpp:124:10
#31 0x0000000000c155de main /home/uday/llvm-project-bondhugula/llvm/projects/mlir/tools/mlir-opt/mlir-opt.cpp:83:17
#32 0x00007fd4e1462f43 __libc_start_main (/lib64/libc.so.6 0x23f43)
#33 0x00000000004116ce _start (../../llvm-project-bondhugula/build/bin/mlir-opt 0x4116ce)
Segmentation fault (core dumped)
@River707 River707 self-assigned this Dec 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants