Skip to content

Missing return statements crash the compiler #920

@zero9178

Description

@zero9178

A C program as simple as:

#include <stdint.h>
int8_t test16() {}

crash dynamatic with a segmentation fault:

dynamatic> set-src test16.c
dynamatic> compile
/home/mboeck/dynamatic/build/bin/bug14/test16.c:2:18: warning: non-void function does not return a value [-Wreturn-type]
    2 | int8_t test16() {}
      |                  ^
1 warning generated.
[INFO] Compiled to LLVM IR
[INFO] Optimized LLVM IR
[INFO] Applied memory dependency analysis to LLVM IR
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /home/mboeck/dynamatic/build/bin/translate-llvm-to-std /home/mboeck/dynamatic/build/bin/bug14/out/comp/clang.opt.dep.ll -function-name test16 -csource /home/mboeck/dynamatic/build/bin/bug14/test16.c -dynamatic-path /home/mboeck/dynamatic -o /home/mboeck/dynamatic/build/bin/bug14/out/comp/cf.mlir
 #0 0x0000000000606bd8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x606bd8)
 #1 0x000000000060485e llvm::sys::RunSignalHandlers() (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x60485e)
 #2 0x00000000006074ed SignalHandler(int) (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x6074ed)
 #3 0x00007f1e388af990 __restore_rt (/lib64/libpthread.so.0+0x12990)
 #4 0x00000000007d5ad5 mlir::detail::OperandStorage::OperandStorage(mlir::Operation*, mlir::OpOperand*, mlir::ValueRange) (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x7d5ad5)
 #5 0x00000000007cc05d mlir::Operation::create(mlir::Location, mlir::OperationName, mlir::TypeRange, mlir::ValueRange, mlir::DictionaryAttr, mlir::OpaqueProperties, mlir::BlockRange, unsigned int) (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x7cc05d)
 #6 0x00000000007cb877 mlir::Operation::create(mlir::Location, mlir::OperationName, mlir::TypeRange, mlir::ValueRange, mlir::NamedAttrList&&, mlir::OpaqueProperties, mlir::BlockRange, mlir::RegionRange) (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x7cb877)
 #7 0x00000000007cb734 mlir::Operation::create(mlir::OperationState const&) (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x7cb734)
 #8 0x000000000075a910 mlir::OpBuilder::create(mlir::OperationState const&) (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x75a910)
 #9 0x00000000005881e0 mlir::func::ReturnOp mlir::OpBuilder::create<mlir::func::ReturnOp, mlir::Value&>(mlir::Location, mlir::Value&) (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x5881e0)
#10 0x0000000000584b10 TranslateLLVMToStd::translateInstruction(llvm::Instruction*) (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x584b10)
#11 0x0000000000582907 TranslateLLVMToStd::translateFunction(llvm::Function*) (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x582907)
#12 0x0000000000581889 TranslateLLVMToStd::translateLLVMModule() (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x581889)
#13 0x0000000000580153 main (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x580153)
#14 0x00007f1e37f54865 __libc_start_main (/lib64/libc.so.6+0x3a865)
#15 0x000000000057f28e _start (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x57f28e)
/home/mboeck/dynamatic/tools/dynamatic/scripts/compile.sh: line 203: 390621 Segmentation fault      (core dumped) $LLVM_TO_STD_TRANSLATION_BIN "$F_CLANG_OPTIMIZED_DEPENDENCY" -function-name "$KERNEL_NAME" -csource "$F_C_SOURCE" -dynamatic-path "$DYNAMATIC_DIR" -o "$F_CF"
[FATAL] Failed to convert to std dialect

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions