Skip to content

Commit

Permalink
[LLVM/CPU] Terminate basic block after "ret" instruction (#6036)
Browse files Browse the repository at this point in the history
* [LLVM/CPU] Terminate basic block after "ret" instruction

"Ret" is a terminator in LLVM IR and there should be no instructions
in the basic block following it. When generating a "ret", end the
current block and start a new one.
  • Loading branch information
Krzysztof Parzyszek authored Jul 10, 2020
1 parent 474d472 commit c9c77c6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/target/llvm/codegen_cpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,9 @@ llvm::Value* CodeGenCPU::CreateIntrinsic(const CallNode* op) {
return CreateStaticHandle();
} else if (op->op.same_as(builtin::tvm_throw_last_error())) {
builder_->CreateRet(ConstInt32(-1));
auto next_block = std::next(builder_->GetInsertBlock()->getIterator());
llvm::BasicBlock* new_bb = llvm::BasicBlock::Create(*ctx_, "cont", function_, &*next_block);
builder_->SetInsertPoint(new_bb);
return ConstInt32(-1);
} else if (op->op.same_as(builtin::tvm_struct_get())) {
CHECK_EQ(op->args.size(), 3U);
Expand Down

0 comments on commit c9c77c6

Please sign in to comment.