llvm-project
llvm-project copied to clipboard
Assertion `Ptr >= BufStart && Ptr <= Buffer->getBufferEnd()' failed.
Test on commit: 0f9720a6
steps to reproduce:
mlir-opt temp.mlir -transform-interpreter
test case:
module attributes {transform.with_named_sequence} {
func.func @example_transform_function(%input: memref<4 x 64 x f32>, %scale: f32, %token: !gpu.async.token) -> memref<4 x 64 x f32> {
%one = arith.constant 1 : index
%c63 = arith.constant 63 : index
%c3 = arith.constant 3 : index
%launch = gpu.launch async[%token] blocks(%arg0, %arg1) in (%arg3 = %one, %arg4 = %one, %arg5 = %one)
threads(%arg2, %arg2, %arg2) in (%arg6 = %one, %arg7 = %one, %arg8 = %one) {
scf.forall (%i, %j) in (%c3, %c63) {
%val = memref.load %input[%i, %j] : memref<4 x 64 x f32>
%scaled_val = arith.mulf %scale, %val : f32
memref.store %scaled_val, %input[%i, %j] : memref<4 x 64 x f32>
} { mapping = [#gpu.thread<x>, #gpu.thread<y>] }
gpu.terminator
}
return %input : memref<4 x 64 x f32>
}
transform.named_sequence @__transform_execute(%arg0: !transform.any_op {transform.readonly}) {
%func_match = transform.structured.match ops{["gpu.launch"]} in %arg0 : (!transform.any_op) -> !transform.any_op
transform.gpu.map_nested_forall_to_threads %func_match block_dims = [512, 3, 1] : (!transform.any_op) -> !transform.any_op
transform.yield
}
}
crash trace:
mlir-opt: /home/fuzzing/llvm-project/llvm/lib/Support/SourceMgr.cpp:109: unsigned int llvm::SourceMgr::SrcBuffer::getLineNumberSpecialized(const char *) const [T = unsigned short]: Assertion `Ptr >= BufStart && Ptr <= Buffer->getBufferEnd()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/fuzzing/llvm-project/build/bin/mlir-opt temp.mlir -transform-interpreter
1. MLIR Parser: custom op parser 'builtin.module'
2. MLIR Parser: custom op parser 'func.func'
3. MLIR Parser: custom op parser 'gpu.launch'
#0 0x000000000113ce77 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x113ce77)
#1 0x000000000113aa0e llvm::sys::RunSignalHandlers() (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x113aa0e)
#2 0x000000000113d855 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x0000718015367520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007180153bb9fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x0000718015367476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000071801534d7f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x000071801534d71b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x000071801535ee96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000011cad82 unsigned int llvm::SourceMgr::SrcBuffer::getLineNumberSpecialized<unsigned short>(char const*) const (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x11cad82)
#10 0x00000000069b292a mlir::Lexer::getEncodedSourceLocation(llvm::SMLoc) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x69b292a)
#11 0x00000000069c1a85 (anonymous namespace)::OperationParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) Parser.cpp:0:0
#12 0x00000000069bfbf9 (anonymous namespace)::CustomOpAsmParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) Parser.cpp:0:0
#13 0x00000000018165ba mlir::gpu::LaunchOp::parse(mlir::OpAsmParser&, mlir::OperationState&) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x18165ba)
#14 0x00000000069b881e (anonymous namespace)::OperationParser::parseOperation() Parser.cpp:0:0
#15 0x00000000069c3d01 (anonymous namespace)::OperationParser::parseBlock(mlir::Block*&) Parser.cpp:0:0
#16 0x00000000069c1b2a (anonymous namespace)::OperationParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) Parser.cpp:0:0
#17 0x00000000069bfbf9 (anonymous namespace)::CustomOpAsmParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) Parser.cpp:0:0
#18 0x00000000069bfc3c (anonymous namespace)::CustomOpAsmParser::parseOptionalRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) Parser.cpp:0:0
#19 0x0000000006ac872b mlir::function_interface_impl::parseFunctionOp(mlir::OpAsmParser&, mlir::OperationState&, bool, mlir::StringAttr, llvm::function_ref<mlir::Type (mlir::Builder&, llvm::ArrayRef<mlir::Type>, llvm::ArrayRef<mlir::Type>, mlir::function_interface_impl::VariadicFlag, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)>, mlir::StringAttr, mlir::StringAttr) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x6ac872b)
#20 0x00000000017e4928 mlir::func::FuncOp::parse(mlir::OpAsmParser&, mlir::OperationState&) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x17e4928)
#21 0x00000000069b881e (anonymous namespace)::OperationParser::parseOperation() Parser.cpp:0:0
#22 0x00000000069c3d01 (anonymous namespace)::OperationParser::parseBlock(mlir::Block*&) Parser.cpp:0:0
#23 0x00000000069c198e (anonymous namespace)::OperationParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) Parser.cpp:0:0
#24 0x00000000069bfbf9 (anonymous namespace)::CustomOpAsmParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) Parser.cpp:0:0
#25 0x00000000043648ce mlir::ModuleOp::parse(mlir::OpAsmParser&, mlir::OperationState&) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x43648ce)
#26 0x00000000069b881e (anonymous namespace)::OperationParser::parseOperation() Parser.cpp:0:0
#27 0x00000000069b7108 mlir::parseAsmSourceFile(llvm::SourceMgr const&, mlir::Block*, mlir::ParserConfig const&, mlir::AsmParserState*, mlir::AsmParserCodeCompleteContext*) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x69b7108)
#28 0x000000000424207f mlir::parseSourceFile(std::shared_ptr<llvm::SourceMgr> const&, mlir::Block*, mlir::ParserConfig const&, mlir::LocationAttr*) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x424207f)
#29 0x0000000004240f8e mlir::parseSourceFileForTool(std::shared_ptr<llvm::SourceMgr> const&, mlir::ParserConfig const&, bool) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x4240f8e)
#30 0x0000000004240793 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#31 0x0000000004240503 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&)::$_3>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#32 0x00000000042ec4e8 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) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x42ec4e8)
#33 0x000000000423a151 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x423a151)
#34 0x000000000423a403 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x423a403)
#35 0x000000000423a612 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x423a612)
#36 0x000000000111a8d7 main (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x111a8d7)
#37 0x000071801534ed90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#38 0x000071801534ee40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#39 0x000000000111a435 _start (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x111a435)
Aborted (core dumped)
@llvm/issue-subscribers-mlir
Author: None (RiRi114)
Test on commit: 0f9720a6
steps to reproduce:
mlir-opt temp.mlir -transform-interpreter
test case:
module attributes {transform.with_named_sequence} {
func.func @<!-- -->example_transform_function(%input: memref<4 x 64 x f32>, %scale: f32, %token: !gpu.async.token) -> memref<4 x 64 x f32> {
%one = arith.constant 1 : index
%c63 = arith.constant 63 : index
%c3 = arith.constant 3 : index
%launch = gpu.launch async[%token] blocks(%arg0, %arg1) in (%arg3 = %one, %arg4 = %one, %arg5 = %one)
threads(%arg2, %arg2, %arg2) in (%arg6 = %one, %arg7 = %one, %arg8 = %one) {
scf.forall (%i, %j) in (%c3, %c63) {
%val = memref.load %input[%i, %j] : memref<4 x 64 x f32>
%scaled_val = arith.mulf %scale, %val : f32
memref.store %scaled_val, %input[%i, %j] : memref<4 x 64 x f32>
} { mapping = [#gpu.thread<x>, #gpu.thread<y>] }
gpu.terminator
}
return %input : memref<4 x 64 x f32>
}
transform.named_sequence @<!-- -->__transform_execute(%arg0: !transform.any_op {transform.readonly}) {
%func_match = transform.structured.match ops{["gpu.launch"]} in %arg0 : (!transform.any_op) -> !transform.any_op
transform.gpu.map_nested_forall_to_threads %func_match block_dims = [512, 3, 1] : (!transform.any_op) -> !transform.any_op
transform.yield
}
}
crash trace:
mlir-opt: /home/fuzzing/llvm-project/llvm/lib/Support/SourceMgr.cpp:109: unsigned int llvm::SourceMgr::SrcBuffer::getLineNumberSpecialized(const char *) const [T = unsigned short]: Assertion `Ptr >= BufStart && Ptr <= Buffer->getBufferEnd()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/fuzzing/llvm-project/build/bin/mlir-opt temp.mlir -transform-interpreter
1. MLIR Parser: custom op parser 'builtin.module'
2. MLIR Parser: custom op parser 'func.func'
3. MLIR Parser: custom op parser 'gpu.launch'
#<!-- -->0 0x000000000113ce77 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x113ce77)
#<!-- -->1 0x000000000113aa0e llvm::sys::RunSignalHandlers() (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x113aa0e)
#<!-- -->2 0x000000000113d855 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#<!-- -->3 0x0000718015367520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#<!-- -->4 0x00007180153bb9fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#<!-- -->5 0x0000718015367476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#<!-- -->6 0x000071801534d7f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#<!-- -->7 0x000071801534d71b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#<!-- -->8 0x000071801535ee96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#<!-- -->9 0x00000000011cad82 unsigned int llvm::SourceMgr::SrcBuffer::getLineNumberSpecialized<unsigned short>(char const*) const (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x11cad82)
#<!-- -->10 0x00000000069b292a mlir::Lexer::getEncodedSourceLocation(llvm::SMLoc) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x69b292a)
#<!-- -->11 0x00000000069c1a85 (anonymous namespace)::OperationParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) Parser.cpp:0:0
#<!-- -->12 0x00000000069bfbf9 (anonymous namespace)::CustomOpAsmParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) Parser.cpp:0:0
#<!-- -->13 0x00000000018165ba mlir::gpu::LaunchOp::parse(mlir::OpAsmParser&, mlir::OperationState&) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x18165ba)
#<!-- -->14 0x00000000069b881e (anonymous namespace)::OperationParser::parseOperation() Parser.cpp:0:0
#<!-- -->15 0x00000000069c3d01 (anonymous namespace)::OperationParser::parseBlock(mlir::Block*&) Parser.cpp:0:0
#<!-- -->16 0x00000000069c1b2a (anonymous namespace)::OperationParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) Parser.cpp:0:0
#<!-- -->17 0x00000000069bfbf9 (anonymous namespace)::CustomOpAsmParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) Parser.cpp:0:0
#<!-- -->18 0x00000000069bfc3c (anonymous namespace)::CustomOpAsmParser::parseOptionalRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) Parser.cpp:0:0
#<!-- -->19 0x0000000006ac872b mlir::function_interface_impl::parseFunctionOp(mlir::OpAsmParser&, mlir::OperationState&, bool, mlir::StringAttr, llvm::function_ref<mlir::Type (mlir::Builder&, llvm::ArrayRef<mlir::Type>, llvm::ArrayRef<mlir::Type>, mlir::function_interface_impl::VariadicFlag, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)>, mlir::StringAttr, mlir::StringAttr) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x6ac872b)
#<!-- -->20 0x00000000017e4928 mlir::func::FuncOp::parse(mlir::OpAsmParser&, mlir::OperationState&) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x17e4928)
#<!-- -->21 0x00000000069b881e (anonymous namespace)::OperationParser::parseOperation() Parser.cpp:0:0
#<!-- -->22 0x00000000069c3d01 (anonymous namespace)::OperationParser::parseBlock(mlir::Block*&) Parser.cpp:0:0
#<!-- -->23 0x00000000069c198e (anonymous namespace)::OperationParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) Parser.cpp:0:0
#<!-- -->24 0x00000000069bfbf9 (anonymous namespace)::CustomOpAsmParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) Parser.cpp:0:0
#<!-- -->25 0x00000000043648ce mlir::ModuleOp::parse(mlir::OpAsmParser&, mlir::OperationState&) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x43648ce)
#<!-- -->26 0x00000000069b881e (anonymous namespace)::OperationParser::parseOperation() Parser.cpp:0:0
#<!-- -->27 0x00000000069b7108 mlir::parseAsmSourceFile(llvm::SourceMgr const&, mlir::Block*, mlir::ParserConfig const&, mlir::AsmParserState*, mlir::AsmParserCodeCompleteContext*) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x69b7108)
#<!-- -->28 0x000000000424207f mlir::parseSourceFile(std::shared_ptr<llvm::SourceMgr> const&, mlir::Block*, mlir::ParserConfig const&, mlir::LocationAttr*) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x424207f)
#<!-- -->29 0x0000000004240f8e mlir::parseSourceFileForTool(std::shared_ptr<llvm::SourceMgr> const&, mlir::ParserConfig const&, bool) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x4240f8e)
#<!-- -->30 0x0000000004240793 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#<!-- -->31 0x0000000004240503 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&)::$_3>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#<!-- -->32 0x00000000042ec4e8 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) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x42ec4e8)
#<!-- -->33 0x000000000423a151 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x423a151)
#<!-- -->34 0x000000000423a403 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x423a403)
#<!-- -->35 0x000000000423a612 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x423a612)
#<!-- -->36 0x000000000111a8d7 main (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x111a8d7)
#<!-- -->37 0x000071801534ed90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#<!-- -->38 0x000071801534ee40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#<!-- -->39 0x000000000111a435 _start (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x111a435)
Aborted (core dumped)
@RiRi114, currently, your example is not valid: https://godbolt.org/z/Me5qEaPWK It says:
<source>:8:24: error: region entry argument '%arg2' is already in use
threads(%arg2, %arg2, %arg2) in (%arg6 = %one, %arg7 = %one, %arg8 = %one) {
^
<source>:8:17: note: previously referenced here
threads(%arg2, %arg2, %arg2) in (%arg6 = %one, %arg7 = %one, %arg8 = %one) {
^
Compiler returned: 1
Is it what you expect from this code?
repro.mlir:7:19: error: custom op 'gpu.launch' blocks expects 3 arguments, but got 2
%launch = gpu.launch async[%token] blocks(%arg0, %arg1) in (%arg3 = %one, %arg4 = %one, %arg5 = %one)
Unable to reproduce issue.