Closed
Description
Content of input.mlir
:
func.func @call_opaque_with_template_arg() {
emitc.call_opaque "init_tile"() {template_args = [512 : index]} : () -> ()
return
}
Command:
mlir-translate -mlir-to-cpp input.mlir
Output:
void test_template_arg_in_call_opaque() {
init_tile<mlir-translate: /home2/vimal/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:454: T &llvm::MutableArrayRef<mlir::OpOperand>::operator[](size_t) const [T = mlir::OpOperand]: Assertion `Index < this->size() && "Invalid index!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: ./build/bin/mlir-translate --mlir-to-cpp test.mlir
#0 0x00007e60ae022e88 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home2/vimal/llvm-project/build/bin/../lib/libLLVMSupport.so.21.0git+0x222e88)
#1 0x00007e60ae020a0e llvm::sys::RunSignalHandlers() (/home2/vimal/llvm-project/build/bin/../lib/libLLVMSupport.so.21.0git+0x220a0e)
#2 0x00007e60ae023581 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007e60ad642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007e60ad6969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x00007e60ad6969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x00007e60ad6969fc pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x00007e60ad642476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007e60ad6287f3 abort ./stdlib/abort.c:81:7
#9 0x00007e60ad62871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007e60ad639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x00007e60b6b458ba printOperation((anonymous namespace)::CppEmitter&, mlir::emitc::CallOpaqueOp)::$_0::operator()(mlir::Attribute) const TranslateToCpp.cpp:0:0
#12 0x00007e60b6b3ba7f (anonymous namespace)::CppEmitter::emitOperation(mlir::Operation&, bool) TranslateToCpp.cpp:0:0
#13 0x00007e60b6b47922 printFunctionBody((anonymous namespace)::CppEmitter&, mlir::Operation*, llvm::iplist<mlir::Block>&) TranslateToCpp.cpp:0:0
#14 0x00007e60b6b3ee34 (anonymous namespace)::CppEmitter::emitOperation(mlir::Operation&, bool) TranslateToCpp.cpp:0:0
#15 0x00007e60b6b3a800 (anonymous namespace)::CppEmitter::emitOperation(mlir::Operation&, bool) TranslateToCpp.cpp:0:0
#16 0x00007e60b6b3a585 mlir::emitc::translateToCpp(mlir::Operation*, llvm::raw_ostream&, bool, llvm::StringRef) (/home2/vimal/llvm-project/build/bin/../lib/libMLIRTargetCpp.so.21.0git+0x11585)
#17 0x00007e60b4a39bd6 std::_Function_handler<llvm::LogicalResult (std::shared_ptr<llvm::SourceMgr> const&, llvm::raw_ostream&, mlir::MLIRContext*), mlir::TranslateFromMLIRRegistration::TranslateFromMLIRRegistration(llvm::StringRef, llvm::StringRef, std::function<llvm::LogicalResult (mlir::Operation*, llvm::raw_ostream&)> const&, std::function<void (mlir::DialectRegistry&)> const&)::$_0>::_M_invoke(std::_Any_data const&, std::shared_ptr<llvm::SourceMgr> const&, llvm::raw_ostream&, mlir::MLIRContext*&&) Translation.cpp:0:0
#18 0x00007e60b4a37cf2 llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::mlirTranslateMain(int, char**, llvm::StringRef)::$_1>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirTranslateMain.cpp:0:0
#19 0x00007e60ae5d27a5 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) (/home2/vimal/llvm-project/build/bin/../lib/libMLIRSupport.so.21.0git+0x2b7a5)
#20 0x00007e60b4a34242 mlir::mlirTranslateMain(int, char**, llvm::StringRef) (/home2/vimal/llvm-project/build/bin/../lib/libMLIRTranslateLib.so.21.0git+0x9242)
#21 0x00005c8a639e7d30 main (./build/bin/mlir-translate+0x3d30)
#22 0x00007e60ad629d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#23 0x00007e60ad629e40 call_init ./csu/../csu/libc-start.c:128:20
#24 0x00007e60ad629e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#25 0x00005c8a639e7c25 _start (./build/bin/mlir-translate+0x3c25)
Aborted (core dumped)
I'm not entirely sure if the provided input IR is valid. But if I understand the context correctly, #141451 fixes the issue.