mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Stop statement generation after terminating instruction in current block (LLVM C API)
This commit is contained in:
@@ -3878,7 +3878,32 @@ lbValue lb_emit_logical_binary_expr(lbProcedure *p, TokenKind op, Ast *left, Ast
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool lb_is_instr_terminating(LLVMValueRef instr) {
|
||||||
|
|
||||||
|
if (instr != nullptr) {
|
||||||
|
LLVMOpcode op = LLVMGetInstructionOpcode(instr);
|
||||||
|
switch (op) {
|
||||||
|
case LLVMRet:
|
||||||
|
case LLVMBr:
|
||||||
|
case LLVMSwitch:
|
||||||
|
case LLVMIndirectBr:
|
||||||
|
case LLVMInvoke:
|
||||||
|
case LLVMUnreachable:
|
||||||
|
case LLVMCallBr:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void lb_build_stmt(lbProcedure *p, Ast *node) {
|
void lb_build_stmt(lbProcedure *p, Ast *node) {
|
||||||
|
if (p->curr_block != nullptr) {
|
||||||
|
LLVMValueRef last_instr = LLVMGetLastInstruction(p->curr_block->block);
|
||||||
|
if (lb_is_instr_terminating(last_instr)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
u64 prev_state_flags = p->module->state_flags;
|
u64 prev_state_flags = p->module->state_flags;
|
||||||
defer (p->module->state_flags = prev_state_flags);
|
defer (p->module->state_flags = prev_state_flags);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user