diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2015-12-07 23:40:58 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2015-12-07 23:40:58 -0700 |
| commit | 5dfe4d6387f874a83a51a13446eb04fb6b77de94 (patch) | |
| tree | 0f9f3b9cf2e68812528a28f50d3790a6337b55ce /src/codegen.cpp | |
| parent | 113f0c9450398655717ea8bb5196a9df88f15000 (diff) | |
| download | zig-5dfe4d6387f874a83a51a13446eb04fb6b77de94.tar.gz zig-5dfe4d6387f874a83a51a13446eb04fb6b77de94.zip | |
codegen: do all the allocas at beginning of function
fixes debugging
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 0d53a12c97..183722d14e 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -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, |
