mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Clean up lb_end_procedure_body logic
This commit is contained in:
+1
-1
@@ -403,7 +403,7 @@ namespace lbAbi386 {
|
|||||||
// TODO(bill): LLVM is probably bugged here and doesn't correctly generate the right code
|
// TODO(bill): LLVM is probably bugged here and doesn't correctly generate the right code
|
||||||
// So even though it is "technically" wrong, no cast might be the best option
|
// So even though it is "technically" wrong, no cast might be the best option
|
||||||
LLVMTypeRef cast_type = nullptr;
|
LLVMTypeRef cast_type = nullptr;
|
||||||
if (!is_return) {
|
if (true || !is_return) {
|
||||||
cast_type = LLVMVectorType(LLVMInt64TypeInContext(c), 2);
|
cast_type = LLVMVectorType(LLVMInt64TypeInContext(c), 2);
|
||||||
}
|
}
|
||||||
return lb_arg_type_direct(type, cast_type, nullptr, nullptr);
|
return lb_arg_type_direct(type, cast_type, nullptr, nullptr);
|
||||||
|
|||||||
+3
-22
@@ -2575,37 +2575,18 @@ void lb_end_procedure_body(lbProcedure *p) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMBasicBlockRef block = nullptr;
|
|
||||||
LLVMBasicBlockRef first_block = LLVMGetFirstBasicBlock(p->value);
|
LLVMBasicBlockRef first_block = LLVMGetFirstBasicBlock(p->value);
|
||||||
|
LLVMBasicBlockRef block = nullptr;
|
||||||
// Remove dead blocks with no code
|
|
||||||
for (block = first_block;
|
|
||||||
block != nullptr;
|
|
||||||
/**/) {
|
|
||||||
LLVMBasicBlockRef next_block = LLVMGetNextBasicBlock(block);
|
|
||||||
LLVMValueRef instr = LLVMGetLastInstruction(block);
|
|
||||||
if (instr == nullptr) {
|
|
||||||
LLVMDeleteBasicBlock(block);
|
|
||||||
}
|
|
||||||
block = next_block;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Make sure every block terminates, and if not, make it unreachable
|
// Make sure every block terminates, and if not, make it unreachable
|
||||||
for (block = first_block;
|
for (block = first_block; block != nullptr; block = LLVMGetNextBasicBlock(block)) {
|
||||||
block != nullptr;
|
|
||||||
block = LLVMGetNextBasicBlock(block)) {
|
|
||||||
LLVMValueRef instr = LLVMGetLastInstruction(block);
|
LLVMValueRef instr = LLVMGetLastInstruction(block);
|
||||||
if (!lb_is_instr_terminating(instr)) {
|
if (instr == nullptr) {
|
||||||
// NOTE(bill): This is a sanity check
|
|
||||||
LLVMBasicBlockRef prev_block = block;
|
|
||||||
LLVMPositionBuilderAtEnd(p->builder, block);
|
LLVMPositionBuilderAtEnd(p->builder, block);
|
||||||
LLVMBuildUnreachable(p->builder);
|
LLVMBuildUnreachable(p->builder);
|
||||||
LLVMPositionBuilderAtEnd(p->builder, prev_block);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
p->curr_block = nullptr;
|
p->curr_block = nullptr;
|
||||||
p->module->state_flags = 0;
|
p->module->state_flags = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user