Skip to content

Commit

Permalink
First quickfix for some of the problems mentioned in issue #163.
Browse files Browse the repository at this point in the history
* C backend: do not expect body->arg(0) to always exist in emit_epilogue.
* LLVM Backend: Do not expect ret to exist in CodeGen::convert(Type*).
  • Loading branch information
m-kurtenacker committed Jun 24, 2024
1 parent 7bc8434 commit 607e79f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/thorin/be/c/c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,9 @@ void CCodeGen::emit_epilogue(Continuation* cont) {
auto&& bb = cont2bb_[cont];
assert(cont->has_body());
auto body = cont->body();
emit_debug_info(bb.tail, body->arg(0));
if (body->num_args() > 0) {
emit_debug_info(bb.tail, body->arg(0));
}

if ((lang_ == Lang::OpenCL || (lang_ == Lang::HLS && hls_top_scope)) && (cont->is_exported()))
emit_fun_decl(cont);
Expand Down
5 changes: 4 additions & 1 deletion src/thorin/be/llvm/llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ llvm::Type* CodeGen::convert(const Type* type) {
} else
ops.push_back(convert(op));
}
assert(ret);

if (!ret) {
ret = llvm::Type::getVoidTy(context());
}

if (type->tag() == Node_FnType) {
auto llvm_type = llvm::FunctionType::get(ret, ops, false);
Expand Down

0 comments on commit 607e79f

Please sign in to comment.