Issue |
120001
|
Summary |
[Mlir][affine] --lower-affine crashes in AffineOps.cpp:foldLoopBounds
|
Labels |
mlir
|
Assignees |
|
Reporter |
Emilyaxe
|
git version: ff939b06a5
system: `Ubuntu 18.04.6 LTS`
reproduce with: `/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt a.mlir --lower-affine`
a.mlir:
```
#map = affine_map<() -> ()>
module {
llvm.mlir.global private constant @__constant_1x10x7xi32_1(dense<7267> : tensor<1x10x7xi32>) {addr_space = 0 : i32, alignment = 64 : i64} : !llvm.array<1 x array<10 x array<7 x i32>>>
func.func @main() {
%0 = llvm.mlir.addressof @__constant_1x10x7xi32_1 : !llvm.ptr
%1 = llvm.mlir.constant(0 : index) : i64
%2 = llvm.mlir.undef : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%3 = llvm.mlir.constant(3735928559 : index) : i64
%4 = llvm.mlir.constant(1 : index) : i64
%5 = llvm.mlir.constant(10 : index) : i64
%6 = llvm.mlir.constant(7 : index) : i64
%7 = llvm.mlir.constant(70 : index) : i64
%8 = llvm.getelementptr %0[0, 0, 0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.array<1 x array<10 x array<7 x i32>>>
%9 = llvm.inttoptr %3 : i64 to !llvm.ptr
%10 = llvm.insertvalue %9, %2[0] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%11 = llvm.insertvalue %8, %10[1] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%12 = llvm.insertvalue %1, %11[2] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%13 = llvm.insertvalue %4, %12[3, 0] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%14 = llvm.insertvalue %5, %13[3, 1] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%15 = llvm.insertvalue %6, %14[3, 2] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%16 = llvm.insertvalue %7, %15[4, 0] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%17 = llvm.insertvalue %6, %16[4, 1] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%18 = llvm.insertvalue %4, %17[4, 2] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%19 = builtin.unrealized_conversion_cast %18 : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)> to memref<1x10x7xi32>
%alloc = memref.alloc() : memref<1x10x7xi32>
affine.for %arg0 = max #map() to min #map() {
affine.for %arg1 = 0 to 7 {
%20 = affine.load %19[0, %arg0, %arg1] : memref<1x10x7xi32>
affine.store %20, %alloc[0, %arg0, %arg1] : memref<1x10x7xi32>
}
}
return
}
}
```
stack trace:
```
mlir-opt: /data/szy/MLIR/llvm-release/llvm-project/mlir/lib/Dialect/Affine/IR/AffineOps.cpp:2201: auto foldLoopBounds(AffineForOp)::(anonymous class)::operator()(bool) const: Assertion `boundMap.getNumResults() >= 1 && "bound maps should have at least one result"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt a.mlir --lower-affine
#0 0x000055dc725e3348 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x111f348)
#1 0x000055dc725e0e5e llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x111ce5e)
#2 0x000055dc725e3cdd SignalHandler(int) Signals.cpp:0:0
#3 0x00007f02fb714420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f02fad5100b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#5 0x00007f02fad30859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
#6 0x00007f02fad30729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
#7 0x00007f02fad30729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
#8 0x00007f02fad41fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#9 0x000055dc726afb93 foldLoopBounds(mlir::affine::AffineForOp)::$_0::operator()(bool) const AffineOps.cpp:0:0
#10 0x000055dc72683251 mlir::affine::AffineForOp::fold(mlir::affine::AffineForOpGenericAdaptor<llvm::ArrayRef<mlir::Attribute>>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11bf251)
#11 0x000055dc726bfca2 llvm::LogicalResult mlir::Op<mlir::affine::AffineForOp, mlir::OpTrait::OneRegion, mlir::OpTrait::VariadicResults, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::VariadicOperands, mlir::OpTrait::AttrSizedOperandSegments, mlir::OpTrait::SingleBlock, mlir::OpTrait::SingleBlockImplicitTerminator<mlir::affine::AffineYieldOp>::Impl, mlir::OpTrait::OpInvariants, mlir::BytecodeOpInterface::Trait, mlir::OpTrait::AutomaticAllocationScope, mlir::ConditionallySpeculatable::Trait, mlir::OpTrait::HasRecursiveMemoryEffects, mlir::LoopLikeOpInterface::Trait, mlir::RegionBranchOpInterface::Trait>::foldHook<mlir::affine::AffineForOp>(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11fbca2)
#12 0x000055dc726bd810 mlir::RegisteredOperationName::Model<mlir::affine::AffineForOp>::foldHook(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11f9810)
#13 0x000055dc7569456d mlir::Operation::fold(llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41d056d)
#14 0x000055dc75694913 mlir::Operation::fold(llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41d0913)
#15 0x000055dc755d397a mlir::OpBuilder::tryFold(mlir::Operation*, llvm::SmallVectorImpl<mlir::Value>&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x410f97a)
#16 0x000055dc7554c39c (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#17 0x000055dc7554b767 mlir::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4087767)
#18 0x000055dc7554c93f mlir::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x408893f)
#19 0x000055dc75552afb mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x408eafb)
#20 0x000055dc74f28ccd (anonymous namespace)::LowerAffinePass::runOnOperation() AffineToStandard.cpp:0:0
#21 0x000055dc754ee3d6 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x402a3d6)
#22 0x000055dc754eed00 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x402ad00)
#23 0x000055dc754f12d2 mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x402d2d2)
#24 0x000055dc754e9a4a performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#25 0x000055dc754e969d llvm::LogicalResult llvm::function_ref<llvm::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&)::$_0>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#26 0x000055dc75595235 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x40d1235)
#27 0x000055dc754e3685 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x401f685)
#28 0x000055dc754e392f mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x401f92f)
#29 0x000055dc754e3c5e mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x401fc5e)
#30 0x000055dc725c3e37 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10ffe37)
#31 0x00007f02fad32083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#32 0x000055dc725c39ae _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10ff9ae)
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs