[mlir](test-emulate-narrow-int) mlir-opt crashes at Types.cpp:125 with assertion `isIntOrFloat() && "only integers and floats have a bitwidth"' failed.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
git version: e192ec42b426f6ffbc25419238a90f3c59088587
MLIR Program:
```mlir
module {
func.func @m() {
%alloca_0 = memref.alloca() : memref>
%1 = memref.load %alloca_0[] : memref>
return
}
}
```
Reproduce Command: `mlir-opt --test-emulate-narrow-int a.mlir`
StackTrace:
```
mlir-opt: /data2/dependency/dev/llvm-project/mlir/lib/IR/Types.cpp:125: unsigned int mlir::Type::getIntOrFloatBitWidth() const: Assertion `isIntOrFloat() && "only integers and floats have a bitwidth"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: /data2/dependency/dev/llvm-project/build/bin/mlir-opt --test-emulate-narrow-int a.mlir
#0 0x000056282b657daf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x259adaf)
#1 0x000056282b65455c llvm::sys::RunSignalHandlers() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x259755c)
#2 0x000056282b6546f7 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007f6ed91ae420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f6ed8c9900b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007f6ed8c78859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007f6ed8c78729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007f6ed8c89fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x000056283488c90a mlir::Type::getIntOrFloatBitWidth() const (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb7cf90a)
#9 0x0000562832a177de (anonymous namespace)::ConvertMemRefLoad::matchAndRewrite(mlir::memref::LoadOp, mlir::memref::LoadOpAdaptor, mlir::ConversionPatternRewriter&) const EmulateNarrowType.cpp:0:0
#10 0x000056282d0594b5 llvm::LogicalResult mlir::ConversionPattern::dispatchTo1To1, mlir::memref::LoadOp>(mlir::OpConversionPattern const&, mlir::memref::LoadOp, mlir::memref::LoadOp::GenericAdaptor>, mlir::ConversionPatternRewriter&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x3f9c4b5)
#11 0x000056282d0595d1 mlir::OpConversionPattern::matchAndRewrite(mlir::Operation*, llvm::ArrayRef, mlir::ConversionPatternRewriter&) const (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x3f9c5d1)
#12 0x000056283442a7a8 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb36d7a8)
#13 0x0000562834471412 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref, llvm::function_ref, llvm::function_ref)::'lambda'()::operator()() const PatternApplicator.cpp:0:0
#14 0x0000562834472978 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref, llvm::function_ref, llvm::function_ref) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb3b5978)
#15 0x00005628344252ab (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*) DialectConversion.cpp:0:0
#16 0x00005628344257a6 mlir::OperationConverter::convert(mlir::Operation*, bool) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb3687a6)
#17 0x00005628344307aa mlir::OperationConverter::applyConversion(llvm::ArrayRef) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb3737aa)
#18 0x0000562834432068 applyConversion(llvm::ArrayRef, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig, (anonymous namespace)::OpConversionMode) DialectConversion.cpp:0:0
#19 0x0000562834432246 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb375246)
#20 0x000056282b78c306 (anonymous namespace)::TestEmulateNarrowTypePass::runOnOperation() (.part.0) TestEmulateNarrowType.cpp:0:0
#21 0x00005628344dd041 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb420041)
#22 0x00005628344dd3d0 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb4203d0)
#23 0x00005628344ddcae mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::'lambda12'(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&)::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const Pass.cpp:0:0
#24 0x00005628344dbff0 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb41eff0)
#25 0x00005628344dcf1b mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb41ff1b)
#26 0x00005628344dd3d0 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb4203d0)
#27 0x00005628344df484 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb422484)
#28 0x00005628344e0501 mlir::PassManager::run(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb423501)
#29 0x000056282b71ddab performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#30 0x000056282b71e833 processBuffer(llvm::raw_ostream&, std::unique_ptr>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#31 0x000056282b71eabb llvm::LogicalResult llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>::callback_fn>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::'lambda'(std::unique_ptr>, llvm::MemoryBufferRef, llvm::raw_ostream&)>(long, std::unique_ptr>, llvm::MemoryBufferRef const&, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#32 0x00005628348b0e25 mlir::splitAndProcessBuffer(std::unique_ptr>, llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb7f3e25)
#33 0x000056282b714b04 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#34 0x000056282b71efd7 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2661fd7)
#35 0x000056282b71f213 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2662213)
#36 0x000056282b59aa9c main (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x24dda9c)
#37 0x00007f6ed8c7a083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#38 0x000056282b63435e _start (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x257735e)
Aborted (core dumped)
```
Contributor guide
Research direction
Start by running the supplied MLIR input with `mlir-opt --test-emulate-narrow-int a.mlir` and inspect the `ConvertMemRefLoad` path in `EmulateNarrowType.cpp`, identified by the stack trace. Trace how the `memref.load` result type is handled for the vector of i1 elements. Done means this reproducer no longer aborts at `Type::getIntOrFloatBitWidth()` and has a regression check for the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100