Skip to content

Instantly share code, notes, and snippets.

@bjacob
Created February 21, 2024 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjacob/d2f18c72c484bcd92986ea7897099a21 to your computer and use it in GitHub Desktop.
Save bjacob/d2f18c72c484bcd92986ea7897099a21 to your computer and use it in GitHub Desktop.

Trying to change ukernels calling convention back to "default", instead of ParameterStruct.

Problem: they are returning void, which leads to an assertion failure in ConvertToLLVM due to a discrepancy in how void llvm.call is represented, either returning nothing or returning one value of type !llvm.void

Getting this:

iree-compile: /home/benoit/iree/third_party/llvm-project/mlir/lib/IR/PatternMatch.cpp:153: virtual void mlir::RewriterBase::replaceOp(Operation *, ValueRange): Assertion `op->getNumResults() == newValues.size() && "incorrect # of replacement values"' failed.

Thread 7 "llvm-worker-5" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffcf7fe6c0 (LWP 259929)]
__pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44
44      ./nptl/pthread_kill.c: No such file or directory.
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00007fffe0a428e6 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007fffe0a268b7 in __GI_abort () at ./stdlib/abort.c:79
#5  0x00007fffe0a267db in __assert_fail_base (fmt=0x7fffe0bc5168 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x7fffe45df43f "op->getNumResults() == newValues.size() && \"incorrect # of replacement values\"", 
    file=file@entry=0x7fffe444e9b9 "/home/benoit/iree/third_party/llvm-project/mlir/lib/IR/PatternMatch.cpp", line=line@entry=153, 
    function=function@entry=0x7fffe4151810 "virtual void mlir::RewriterBase::replaceOp(Operation *, ValueRange)") at ./assert/assert.c:92
#6  0x00007fffe0a39206 in __assert_fail (assertion=0x7fffe45df43f "op->getNumResults() == newValues.size() && \"incorrect # of replacement values\"", 
    file=0x7fffe444e9b9 "/home/benoit/iree/third_party/llvm-project/mlir/lib/IR/PatternMatch.cpp", line=153, 
    function=0x7fffe4151810 "virtual void mlir::RewriterBase::replaceOp(Operation *, ValueRange)") at ./assert/assert.c:101
#7  0x00007fffeb859070 in mlir::RewriterBase::replaceOp (this=0x7fffcf7f90d0, op=0x7fffc41da760, newValues=...)
    at /home/benoit/iree/third_party/llvm-project/mlir/lib/IR/PatternMatch.cpp:152
#8  0x00007fffedd4cdde in mlir::iree_compiler::(anonymous namespace)::RewriteCallOpABI::matchAndRewrite (this=0x7fffc40b91e0, callOp=..., rewriter=...)
    at /home/benoit/iree/compiler/src/iree/compiler/Codegen/LLVMCPU/ConvertToLLVM.cpp:784
#9  0x00007fffedd5ca7b in mlir::detail::OpOrInterfaceRewritePatternBase<mlir::LLVM::CallOp>::matchAndRewrite (this=0x7fffc40b91e0, op=0x7fffc41da760, 
    rewriter=...) at /home/benoit/iree/third_party/llvm-project/mlir/include/mlir/IR/PatternMatch.h:330
#10 0x00007ffff1b68f66 in mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>)::$_0::operator()() const (
    this=0x7fffcf7f85e0) at /home/benoit/iree/third_party/llvm-project/mlir/lib/Rewrite/PatternApplicator.cpp:212
#11 0x00007ffff1b68da5 in llvm::function_ref<void ()>::callback_fn<mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>)::$_0>(long) (callable=140736674629088) at /home/benoit/iree/third_party/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45
#12 0x00007fffeab70489 in llvm::function_ref<void ()>::operator()() const (this=0x7fffcf7f8520)
    at /home/benoit/iree/third_party/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68
#13 0x00007ffff1b6a7b5 in mlir::MLIRContext::executeAction<mlir::ApplyPatternAction, mlir::Pattern const&>(llvm::function_ref<void ()>, llvm::ArrayRef<mlir::IRUnit>, mlir::Pattern const&) (this=0x5555555f0220, actionFn=..., irUnits=..., args=...)
    at /home/benoit/iree/third_party/llvm-project/mlir/include/mlir/IR/MLIRContext.h:275
#14 0x00007ffff1b67327 in mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>) (this=0x7fffcf7f91d0, op=0x7fffc41da760, 
    rewriter=..., canApply=..., onFailure=..., onSuccess=...) at /home/benoit/iree/third_party/llvm-project/mlir/lib/Rewrite/PatternApplicator.cpp:195
#15 0x00007ffff1b2d8a9 in (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist (this=0x7fffcf7f90d0)
    at /home/benoit/iree/third_party/llvm-project/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp:599
#16 0x00007ffff1b2cbd1 in (anonymous namespace)::RegionPatternRewriteDriver::simplify(bool*) &&::$_2::operator()() const (this=0x7fffcf7f8f70)
    at /home/benoit/iree/third_party/llvm-project/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp:839
#17 0x00007ffff1b2cba5 in llvm::function_ref<void ()>::callback_fn<(anonymous namespace)::RegionPatternRewriteDriver::simplify(bool*) &&::$_2>(long) (
    callable=140736674631536) at /home/benoit/iree/third_party/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45
#18 0x00007fffeab70489 in llvm::function_ref<void ()>::operator()() const (this=0x7fffcf7f8f10)
    at /home/benoit/iree/third_party/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68
#19 0x00007ffff1b2c2f5 in mlir::MLIRContext::executeAction<(anonymous namespace)::GreedyPatternRewriteIteration, long&>(llvm::function_ref<void ()>, llvm::ArrayRef<mlir::IRUnit>, long&) (this=0x5555555f0220, actionFn=..., irUnits=..., args=@0x7fffcf7f9078: 1)
--Type <RET> for more, q to quit, c to continue without paging--q
Quit
(gdb) frame 7
#7  0x00007fffeb859070 in mlir::RewriterBase::replaceOp (this=0x7fffcf7f90d0, op=0x7fffc41da760, newValues=...)
    at /home/benoit/iree/third_party/llvm-project/mlir/lib/IR/PatternMatch.cpp:152
152       assert(op->getNumResults() == newValues.size() &&
(gdb) p newValues.size()
$1 = 1
(gdb) call newValues[0].dump()
%235 = "llvm.call"(%230, %209, %109, %231, %218, %128, %232, %229, %154, %201, %207, %92, %11, %10, %9, %8, %234) <{CConv = #llvm.cconv<ccc>, callee = @iree_uk_mmt4d, fastmathFlags = #llvm.fastmath<none>}> : (!llvm.ptr, i64, i64, !llvm.ptr, i64, i64, !llvm.ptr, i64, i64, i64, i64, i64, i32, i32, i32, i32, !llvm.ptr) -> !llvm.void
(gdb) call op->dump()
llvm.call @iree_uk_mmt4d(%230, %209, %109, %231, %218, %128, %232, %229, %154, %201, %207, %92, %11, %10, %9, %8) : (!llvm.ptr, i64, i64, !llvm.ptr, i64, i64, !llvm.ptr, i64, i64, i64, i64, i64, i32, i32, i32, i32) -> ()
(gdb) p op->getNumResults()
$2 = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment