| Issue |
177818
|
| Summary |
mlir-opt --convert-scf-to-spirv crashes on signed integer constant (si32)
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
Subway2023
|
# Description
Running mlir-opt --convert-scf-to-spirv on a module containing an arith.constant or spirv.Constant with a signed integer type (si32) triggers an assertion failure in IntegerAttr::getInt()
# Reproduce
mlir-opt version: 22.1.0-rc1
location: If the **vector.from_elements** is commented out, the crash no longer occurs.
```
module {
func.func @main() {
%0 = gpu.thread_id x
%2 = spirv.Constant -5 : si32
%3 = vector.from_elements %2 : vector<1xsi32>
return
}
}
```
```
mlir-opt --convert-scf-to-spirv test.mlir
```
```
mlir-opt: /mnt/sdd1/sbw/mlir/tool/llvm-project-llvmorg-22.1.0-rc1/mlir/lib/IR/BuiltinAttributes.cpp:365: int64_t mlir::IntegerAttr::getInt() const: Assertion `(getType().isIndex() || getType().isSignlessInteger()) && "must be signless integer"' 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: /mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt --convert-scf-to-spirv /mnt/sdd1/sbw/mlir/data/genProgram_0103/031343_ec9e/mlir_steps/031343_ec9e_3.mlir
#0 0x000056d4bd469e32 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x252fe32)
#1 0x000056d4bd4665af llvm::sys::RunSignalHandlers() (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x252c5af)
#2 0x000056d4bd4666fc SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x0000761841645330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#4 0x000076184169eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x000076184169eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x000076184169eb2c pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x000076184164527e raise ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007618416288ff abort ./stdlib/abort.c:81:7
#9 0x000076184162881b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x000076184163b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#11 0x000056d4c4fc4375 mlir::IntegerAttr::getInt() const (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0xa08a375)
#12 0x000056d4c0d05a88 convertIntegerAttr(mlir::IntegerAttr, mlir::IntegerType, mlir::Builder) ArithToSPIRV.cpp:0:0
#13 0x000056d4c0d0c001 (anonymous namespace)::ConstantScalarOpPattern::matchAndRewrite(mlir::arith::ConstantOp, mlir::arith::ConstantOpAdaptor, mlir::ConversionPatternRewriter&) const ArithToSPIRV.cpp:0:0
#14 0x000056d4beb0f320 llvm::LogicalResult mlir::ConversionPattern::dispatchTo1To1<mlir::OpConversionPattern<mlir::arith::ConstantOp>, mlir::arith::ConstantOp>(mlir::OpConversionPattern<mlir::arith::ConstantOp> const&, mlir::arith::ConstantOp, mlir::arith::ConstantOp::GenericAdaptor<llvm::ArrayRef<mlir::ValueRange>>, mlir::ConversionPatternRewriter&) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x3bd5320)
#15 0x000056d4beb0f44c mlir::OpConversionPattern<mlir::arith::ConstantOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::ValueRange>, mlir::ConversionPatternRewriter&) const (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x3bd544c)
#16 0x000056d4c4c4732e mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x9d0d32e)
#17 0x000056d4c4c94e03 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>)::'lambda'()::operator()() const PatternApplicator.cpp:0:0
#18 0x000056d4c4c963af mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x9d5c3af)
#19 0x000056d4c4c4247c (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*) DialectConversion.cpp:0:0
#20 0x000056d4c4c41af9 (anonymous namespace)::OperationLegalizer::legalizeWithFold(mlir::Operation*) DialectConversion.cpp:0:0
#21 0x000056d4c4c424cb (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*) DialectConversion.cpp:0:0
#22 0x000056d4c4c42944 mlir::OperationConverter::convert(mlir::Operation*, bool) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x9d08944)
#23 0x000056d4c4c4bb16 mlir::OperationConverter::applyConversion(llvm::ArrayRef<mlir::Operation*>) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x9d11b16)
#24 0x000056d4c4c4e2ab applyConversion(llvm::ArrayRef<mlir::Operation*>, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig, (anonymous namespace)::OpConversionMode) DialectConversion.cpp:0:0
#25 0x000056d4c4c4e44f mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x9d1444f)
#26 0x000056d4c0bbde52 (anonymous namespace)::SCFToSPIRVPass::runOnOperation() SCFToSPIRVPass.cpp:0:0
#27 0x000056d4c4d09756 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x9dcf756)
#28 0x000056d4c4d09a8e mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x9dcfa8e)
#29 0x000056d4c4d0a1e2 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x9dd01e2)
#30 0x000056d4c4d0b400 mlir::PassManager::run(mlir::Operation*) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x9dd1400)
#31 0x000056d4bd530767 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#32 0x000056d4bd5314ea llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef const&, 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&)::'lambda'(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef const&, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#33 0x000056d4c50d9731 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::MemoryBufferRef const&, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0xa19f731)
#34 0x000056d4bd5288d0 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#35 0x000056d4bd531b70 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x25f7b70)
#36 0x000056d4bd531da9 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x25f7da9)
#37 0x000056d4bd363023 main (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x2429023)
#38 0x000076184162a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#39 0x000076184162a28b call_init ./csu/../csu/libc-start.c:128:20
#40 0x000076184162a28b __libc_start_main ./csu/../csu/libc-start.c:347:5
#41 0x000056d4bd448405 _start (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x250e405)
Aborted (core dumped)
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs