llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.11k stars 12.01k forks source link

constant ui32 crash #45567

Closed bondhugula closed 3 years ago

bondhugula commented 4 years ago
Bugzilla Link 46222
Resolution FIXED
Resolved on Dec 10, 2020 13:11
Version unspecified
OS Linux
CC @joker-eph,@jpienaar,@River707

Extended Description

This is from close to HEAD 70ad03d93818532ef19f149f8ff89bcd8af80163 (Jun 4).

From a discussion on MLIR discourse some time back, it looks like support for unsigned int's (and attributes for it etc.) were added. But looks like constant ui32's never got tested. It's currently impossible to create such an op or parse one!

$ cat ui.mlir
func @​ui() {
  %c = constant 9 : ui32
  return
}

$ mlir-opt ui.mlir
mlir-opt: /home/uday/llvm-project-github/mlir/lib/IR/Attributes.cpp:326: int64_t mlir::IntegerAttr::getInt() const: Assertion `(getImpl()->getType().isIndex() || getImpl()->getType().isSignlessInteger()) && "must be signless integer"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.  Program arguments: build/bin/mlir-opt /tmp/test.mlir 
 #​0 0x00000000004c0108 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/uday/llvm-project-github/llvm/lib/Support/Unix/Signals.inc:564:22
 #​1 0x00000000004c019b PrintStackTraceSignalHandler(void*) /home/uday/llvm-project-github/llvm/lib/Support/Unix/Signals.inc:625:1
 #​2 0x00000000004be24a llvm::sys::RunSignalHandlers() /home/uday/llvm-project-github/llvm/lib/Support/Signals.cpp:68:20
 #​3 0x00000000004bfb4a SignalHandler(int) /home/uday/llvm-project-github/llvm/lib/Support/Unix/Signals.inc:406:1
 #​4 0x00007faa33440b20 __restore_rt (/lib64/libpthread.so.0+0x14b20)
 #​5 0x00007faa32ee8625 raise (/lib64/libc.so.6+0x3c625)
 #​6 0x00007faa32ed18d9 abort (/lib64/libc.so.6+0x258d9)
 #​7 0x00007faa32ed17a9 _nl_load_domain.cold (/lib64/libc.so.6+0x257a9)
 #​8 0x00007faa32ee0a66 (/lib64/libc.so.6+0x34a66)
 #​9 0x0000000001033184 mlir::IntegerAttr::getInt() const /home/uday/llvm-project-github/mlir/lib/IR/Attributes.cpp:326:3
#&#8203;10 0x0000000000a9f858 mlir::ConstantOp::getAsmResultNames(llvm::function_ref<void (mlir::Value, llvm::StringRef)>) /home/uday/llvm-project-github/mlir/lib/Dialect/StandardOps/IR/Ops.cpp:1153:41
#&#8203;11 0x0000000000b4ebc9 mlir::detail::OpAsmOpInterfaceInterfaceTraits::Model<mlir::ConstantOp>::getAsmResultNames(mlir::Operation*, llvm::function_ref<void (mlir::Value, llvm::StringRef)>) /home/uday/llvm-project-github/build/tools/mlir/include/mlir/IR/OpAsmInterface.h.inc:23:5
#&#8203;12 0x0000000001010969 mlir::OpAsmOpInterface::getAsmResultNames(llvm::function_ref<void (mlir::Value, llvm::StringRef)>) /home/uday/llvm-project-github/build/tools/mlir/include/mlir/IR/OpAsmInterface.cpp.inc:10:68
#&#8203;13 0x00000000010131d7 (anonymous namespace)::SSANameState::numberValuesInOp(mlir::Operation&, mlir::DialectInterfaceCollection<mlir::OpAsmDialectInterface>&) /home/uday/llvm-project-github/mlir/lib/IR/AsmPrinter.cpp:736:35
#&#8203;14 0x0000000001012f89 (anonymous namespace)::SSANameState::numberValuesInBlock(mlir::Block&, mlir::DialectInterfaceCollection<mlir::OpAsmDialectInterface>&) /home/uday/llvm-project-github/mlir/lib/IR/AsmPrinter.cpp:712:19
#&#8203;15 0x0000000001012a54 (anonymous namespace)::SSANameState::numberValuesInRegion(mlir::Region&, mlir::DialectInterfaceCollection<mlir::OpAsmDialectInterface>&) /home/uday/llvm-project-github/mlir/lib/IR/AsmPrinter.cpp:663:22
#&#8203;16 0x0000000001012ba3 (anonymous namespace)::SSANameState::numberValuesInRegion(mlir::Region&, mlir::DialectInterfaceCollection<mlir::OpAsmDialectInterface>&) /home/uday/llvm-project-github/mlir/lib/IR/AsmPrinter.cpp:674:7
#&#8203;17 0x00000000010122de (anonymous namespace)::SSANameState::SSANameState(mlir::Operation*, mlir::DialectInterfaceCollection<mlir::OpAsmDialectInterface>&) /home/uday/llvm-project-github/mlir/lib/IR/AsmPrinter.cpp:572:3
#&#8203;18 0x000000000101de50 mlir::detail::AsmStateImpl::AsmStateImpl(mlir::Operation*, llvm::DenseMap<mlir::Operation*, std::pair<unsigned int, unsigned int>, llvm::DenseMapInfo<mlir::Operation*>, llvm::detail::DenseMapPair<mlir::Operation*, std::pair<unsigned int, unsigned int> > >*) /home/uday/llvm-project-github/mlir/lib/IR/AsmPrinter.cpp:870:32
#&#8203;19 0x0000000001021389 std::_MakeUniq<mlir::detail::AsmStateImpl>::__single_object std::make_unique<mlir::detail::AsmStateImpl, mlir::Operation*&, llvm::DenseMap<mlir::Operation*, std::pair<unsigned int, unsigned int>, llvm::DenseMapInfo<mlir::Operation*>, llvm::detail::DenseMapPair<mlir::Operation*, std::pair<unsigned int, unsigned int> > >*&>(mlir::Operation*&, llvm::DenseMap<mlir::Operation*, std::pair<unsigned int, unsigned int>, llvm::DenseMapInfo<mlir::Operation*>, llvm::detail::DenseMapPair<mlir::Operation*, std::pair<unsigned int, unsigned int> > >*&) /usr/include/c++/9/bits/unique_ptr.h:857:69
#&#8203;20 0x0000000001013bd5 mlir::AsmState::AsmState(mlir::Operation*, llvm::DenseMap<mlir::Operation*, std::pair<unsigned int, unsigned int>, llvm::DenseMapInfo<mlir::Operation*>, llvm::detail::DenseMapPair<mlir::Operation*, std::pair<unsigned int, unsigned int> > >*) /home/uday/llvm-project-github/mlir/lib/IR/AsmPrinter.cpp:913:62
#&#8203;21 0x000000000101a522 mlir::ModuleOp::print(llvm::raw_ostream&, mlir::OpPrintingFlags) /home/uday/llvm-project-github/mlir/lib/IR/AsmPrinter.cpp:2512:33
#&#8203;22 0x0000000000d3dc1d performActions(llvm::raw_ostream&, bool, bool, llvm::SourceMgr&, mlir::MLIRContext*, mlir::PassPipelineCLParser const&) /home/uday/llvm-project-github/mlir/lib/Support/MlirOptMain.cpp:67:16
#&#8203;23 0x0000000000d3dd95 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, bool, bool, bool, mlir::PassPipelineCLParser const&) /home/uday/llvm-project-github/mlir/lib/Support/MlirOptMain.cpp:93:49
#&#8203;24 0x0000000000d3e000 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, mlir::PassPipelineCLParser const&, bool, bool, bool, bool) /home/uday/llvm-project-github/mlir/lib/Support/MlirOptMain.cpp:128:63
#&#8203;25 0x0000000000413995 main /home/uday/llvm-project-github/mlir/tools/mlir-opt/mlir-opt.cpp:178:13
#&#8203;26 0x00007faa32ed31a3 __libc_start_main (/lib64/libc.so.6+0x271a3)
#&#8203;27 0x000000000041346e _start (build/bin/mlir-opt+0x41346e)
Aborted (core dumped)
River707 commented 3 years ago

Fixed the verifier in 1f5f006d9d53e785296d1a8fbb0e90904a5eaf60 to not crash when the constant isn't signless.

bondhugula commented 4 years ago

assigned to @River707