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

inlineRegionBefore breaks -debug #53921

Open
tpopp opened this issue Feb 18, 2022 · 2 comments
Open

inlineRegionBefore breaks -debug #53921

tpopp opened this issue Feb 18, 2022 · 2 comments
Labels
mlir:core MLIR Core Infrastructure

Comments

@tpopp
Copy link
Contributor

tpopp commented Feb 18, 2022

Currently, calls to RewriterBase::inlineRegionBefore will result in a failure to use -debug functionality by default. It works with the addition of -mlir-print-op-generic, but without will result in failures such as:

affine.for mlir-opt: llvm-project/mlir/include/mlir/IR/OpDefinition.h:838: mlir::Block *mlir::OpTrait::SingleBlock<mlir::AffineForOp>::getBody(unsigned int) [ConcreteType = mlir::AffineForOp]: Assertion `!region.empty() && "unexpected empty region"' failed. 
...
 #9 0x0000000000511d3a mlir::AffineForOp::print(mlir::OpAsmPrinter&) (build/bin/mlir-opt+0x511d3a)
#10 0x000000000052eeef mlir::Op<mlir::AffineForOp, mlir::OpTrait::OneRegion, mlir::OpTrait::VariadicResults, mlir::OpTrait::ZeroSuccessor, mlir::O
pTrait::VariadicOperands, mlir::OpTrait::SingleBlockImplicitTerminator<mlir::AffineYieldOp>::Impl, mlir::OpTrait::HasRecursiveSideEffects, mlir::L
oopLikeOpInterface::Trait>::printAssembly(mlir::Operation*, mlir::OpAsmPrinter&, llvm::StringRef) (build/bin/mlir-opt+0x52eeef)
#11 0x00000000012ed367 (anonymous namespace)::OperationPrinter::print(mlir::Operation*) AsmPrinter.cpp:0:0
#12 0x00000000012ee080 (anonymous namespace)::OperationPrinter::print(mlir::Block*, bool, bool) AsmPrinter.cpp:0:0
#13 0x00000000012f36dd (anonymous namespace)::OperationPrinter::printRegion(mlir::Region&, bool, bool, bool) AsmPrinter.cpp:0:0
#14 0x00000000013546bf mlir::function_interface_impl::printFunctionOp(mlir::OpAsmPrinter&, mlir::Operation*, llvm::ArrayRef<mlir::Type>, bool, llv
m::ArrayRef<mlir::Type>) (build/bin/mlir-opt+0x13546bf)
#15 0x0000000001322668 mlir::Op<mlir::FuncOp, mlir::OpTrait::OneRegion, mlir::OpTrait::ZeroResult, mlir::OpTrait::ZeroSuccessor, mlir::OpTrait::Ze
roOperands, mlir::OpTrait::AffineScope, mlir::OpTrait::AutomaticAllocationScope, mlir::CallableOpInterface::Trait, mlir::FunctionOpInterface::Trai
t, mlir::OpTrait::IsIsolatedFromAbove, mlir::SymbolOpInterface::Trait>::printAssembly(mlir::Operation*, mlir::OpAsmPrinter&, llvm::StringRef) (build/bin/mlir-opt+0x1322668)
#16 0x00000000012ed367 (anonymous namespace)::OperationPrinter::print(mlir::Operation*) AsmPrinter.cpp:0:0
#17 0x00000000012eb06f mlir::Operation::print(llvm::raw_ostream&, mlir::AsmState&) (build/bin/mlir-opt+0x12eb06f)
#18 0x00000000012eaf35 mlir::Operation::print(llvm::raw_ostream&, mlir::OpPrintingFlags const&) (build/bin/mlir-opt+0x12eaf35)
#19 0x00000000012ed4f4 mlir::Operation::dump() (build/bin/mlir-opt+0x12ed4f4)
#20 0x00000000026f427a mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern c
onst&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>) (build/bin/mlir-opt+0x26f427a)

This makes debugging of passes including dialect conversion often painful as either the less clear generic form has to be used, or the pattern has to insert a block into the deleted operation to avoid the assertion failure.

The above stack trace was generated by adding -debug to Conversion/AffineToStandard/lower-affine.mlir

@tpopp tpopp added the mlir:core MLIR Core Infrastructure label Feb 18, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 18, 2022

@llvm/issue-subscribers-mlir-core

@River707
Copy link
Contributor

This isn't really specific to inlineRegionBefore in any way. A lot of things within the conversion process can break invariants in ways that will crash pretty printers, it kind of just comes with the territory. https://reviews.llvm.org/D117834 is realistically the path forward to removing the crashes during printing for invalid ops, but defaulting to the generic form is not something we will always be able to avoid during conversions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir:core MLIR Core Infrastructure
Projects
None yet
Development

No branches or pull requests

3 participants