Skip to content

[CfToHandshake] hlstool crashes with unused memref #9807

@zhengyao-lin

Description

@zhengyao-lin

Consider these two functions:

func.func @bad(%arg0: memref<1024xi32>, %arg1: memref<1024xi32>) {
    %c1_i32 = arith.constant 1 : i32
    affine.store %c1_i32, %arg1[0] : memref<1024xi32>
    return
}

func.func @good(%arg0: memref<1024xi32>, %arg1: memref<1024xi32>) {
    %c1_i32 = arith.constant 1 : i32
    affine.store %c1_i32, %arg0[0] : memref<1024xi32>
    return
}

On the latest commit of CIRCT, hlstool crashes on the first function with the following assertion error

$ hlstool --ir --output-level=core --dynamic-hw <bad.mlir>

Assertion failed: (use_empty() && "Cannot destroy a value that still has uses!"), function ~IRObjectWithUseList, file UseDefLists.h, line 198.
PLEASE submit a bug report to https://github.com/llvm/circt and include the crash backtrace.
Stack dump:
0.      Program arguments: hlstool bad.mlir --ir --output-level=core --dynamic-hw
 #0 0x0000000100ace810 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (hlstool+0x100072810)
 #1 0x0000000100acc904 llvm::sys::RunSignalHandlers() (hlstool+0x100070904)
 #2 0x0000000100acf2a0 SignalHandler(int, __siginfo*, void*) (hlstool+0x1000732a0)
 #3 0x000000019748f744 (/usr/lib/system/libsystem_platform.dylib+0x1804e3744)
 #4 0x0000000197485888 (/usr/lib/system/libsystem_pthread.dylib+0x1804d9888)
 #5 0x000000019738a850 (/usr/lib/system/libsystem_c.dylib+0x1803de850)
 #6 0x0000000197389a84 (/usr/lib/system/libsystem_c.dylib+0x1803dda84)
 #7 0x0000000101186264 mlir::Block::getTerminator() (.cold.1) (hlstool+0x10072a264)
 #8 0x00000001011858bc mlir::Block::getTerminator() (hlstool+0x1007298bc)
 #9 0x0000000101185784 mlir::Block::eraseArguments(llvm::BitVector const&) (hlstool+0x100729784)
#10 0x00000001017cd1ac mlir::function_interface_impl::eraseFunctionArguments(mlir::FunctionOpInterface, llvm::BitVector const&, mlir::Type) (hlstool+0x100d711ac)
#11 0x0000000100cf0c6c mlir::detail::FunctionOpInterfaceTrait<circt::handshake::FuncOp>::eraseArgument(unsigned int) (hlstool+0x100294c6c)
#12 0x0000000100ceee14 (anonymous namespace)::HandshakeLowerExtmemToHWPass::lowerExtmemToHW(circt::handshake::FuncOp) (hlstool+0x100292e14)
#13 0x0000000100ced184 (anonymous namespace)::HandshakeLowerExtmemToHWPass::runOnOperation() (hlstool+0x100291184)
#14 0x0000000101672240 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (hlstool+0x100c16240)
#15 0x0000000101672d54 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (hlstool+0x100c16d54)
#16 0x0000000101678584 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (hlstool+0x100c1c584)
#17 0x0000000101677d1c mlir::PassManager::run(mlir::Operation*) (hlstool+0x100c1bd1c)
#18 0x0000000100a61854 processBuffer(mlir::MLIRContext&, mlir::TimingScope&, llvm::SourceMgr&, std::__1::optional<std::__1::unique_ptr<llvm::ToolOutputFile, std::__1::default_delete<llvm::ToolOutputFile>>>&) (hlstool+0x100005854)
#19 0x0000000100a60848 processInputSplit(mlir::MLIRContext&, mlir::TimingScope&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, std::__1::optional<std::__1::unique_ptr<llvm::ToolOutputFile, std::__1::default_delete<llvm::ToolOutputFile>>>&) (hlstool+0x100004848)
#20 0x0000000100a5ea0c executeHlstool(mlir::MLIRContext&) (hlstool+0x100002a0c)
#21 0x0000000100a5e128 main (hlstool+0x100002128)
#22 0x00000001970bdd54

The second function @good works fine though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions