summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNagi5Yeq <wu@x-nagi.com>2020-05-28 02:07:29 +0800
committerNagi5Yeq <wu@x-nagi.com>2020-05-28 02:07:29 +0800
commit404afbef3c9223bc44ddd91066c52c44349e43c7 (patch)
tree696460b4ca58bddfbf6d3bef44f2de6a341a4bb5
parent5fc580a0fe1ef35f0706394ec9ebb2a088deb5e9 (diff)
create br at the start of while, repeat.
fix the "Basic Block in function '...' does not have terminator!" error
-rw-r--r--node/StatementNode.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/node/StatementNode.cc b/node/StatementNode.cc
index e29398d..9ae5a9c 100644
--- a/node/StatementNode.cc
+++ b/node/StatementNode.cc
@@ -94,6 +94,7 @@ Value WhileStatementNode::CodeGen() {
llvm::BasicBlock::Create(GlobalLLVMContext, "loop");
llvm::BasicBlock* EndBlock =
llvm::BasicBlock::Create(GlobalLLVMContext, "done");
+ builder->CreateBr(StartBlock);
builder->SetInsertPoint(StartBlock);
Value ExprValue = manager->CreateCast(boolean, expr_->GetType(),
expr_->CodeGen(), context_);
@@ -124,6 +125,7 @@ Value RepeatStatementNode::CodeGen() {
llvm::BasicBlock::Create(GlobalLLVMContext, "loop", body);
llvm::BasicBlock* EndBlock =
llvm::BasicBlock::Create(GlobalLLVMContext, "done");
+ builder->CreateBr(LoopBlock);
builder->SetInsertPoint(LoopBlock);
RepeatBody_->CodeGen();
Value ExprValue = manager->CreateCast(boolean, expr_->GetType(),