mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
codegen: do all the allocas at beginning of function
fixes debugging
This commit is contained in:
parent
113f0c9450
commit
5dfe4d6387
2 changed files with 3 additions and 3 deletions
|
|
@ -55,7 +55,6 @@ compromises backward compatibility.
|
||||||
|
|
||||||
### Roadmap
|
### Roadmap
|
||||||
|
|
||||||
* debugging for variables
|
|
||||||
* structs
|
* structs
|
||||||
* loops
|
* loops
|
||||||
* enums
|
* enums
|
||||||
|
|
|
||||||
|
|
@ -528,8 +528,6 @@ static LLVMValueRef gen_expr(CodeGen *g, AstNode *node) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
} else {
|
} else {
|
||||||
add_debug_source_node(g, node);
|
add_debug_source_node(g, node);
|
||||||
variable->value_ref = LLVMBuildAlloca(g->builder,
|
|
||||||
variable->type->type_ref, buf_ptr(&variable->name));
|
|
||||||
LLVMValueRef store_instr = LLVMBuildStore(g->builder, value, variable->value_ref);
|
LLVMValueRef store_instr = LLVMBuildStore(g->builder, value, variable->value_ref);
|
||||||
|
|
||||||
LLVMZigDILocation *debug_loc = LLVMZigGetDebugLoc(node->line + 1, node->column + 1,
|
LLVMZigDILocation *debug_loc = LLVMZigGetDebugLoc(node->line + 1, node->column + 1,
|
||||||
|
|
@ -779,6 +777,9 @@ static void do_code_gen(CodeGen *g) {
|
||||||
} else {
|
} else {
|
||||||
tag = LLVMZigTag_DW_auto_variable();
|
tag = LLVMZigTag_DW_auto_variable();
|
||||||
arg_no = 0;
|
arg_no = 0;
|
||||||
|
|
||||||
|
add_debug_source_node(g, var->decl_node);
|
||||||
|
var->value_ref = LLVMBuildAlloca(g->builder, var->type->type_ref, buf_ptr(&var->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
var->di_loc_var = LLVMZigCreateLocalVariable(g->dbuilder, tag,
|
var->di_loc_var = LLVMZigCreateLocalVariable(g->dbuilder, tag,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue