codegen: do all the allocas at beginning of function

fixes debugging
This commit is contained in:
Andrew Kelley 2015-12-07 23:40:58 -07:00
parent 113f0c9450
commit 5dfe4d6387
2 changed files with 3 additions and 3 deletions

View file

@ -55,7 +55,6 @@ compromises backward compatibility.
### Roadmap
* debugging for variables
* structs
* loops
* enums

View file

@ -528,8 +528,6 @@ static LLVMValueRef gen_expr(CodeGen *g, AstNode *node) {
return nullptr;
} else {
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);
LLVMZigDILocation *debug_loc = LLVMZigGetDebugLoc(node->line + 1, node->column + 1,
@ -779,6 +777,9 @@ static void do_code_gen(CodeGen *g) {
} else {
tag = LLVMZigTag_DW_auto_variable();
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,