From b025193de5b951734e5108e4762e5dc40359431b Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 17 Jun 2019 13:31:19 -0400 Subject: inferred comptime values rather than elided scopes because of this example: ```zig export fn entry(b: bool) usize { var runtime = [1]i32{3}; comptime var i: usize = 0; inline while (i < 2) : (i += 1) { const result = if (i == 0) [1]i32{2} else runtime; } comptime { return i; } } ``` The problem is that the concept of "resetting" a result location, introduced in the previous commit, cannot handle elision scopes. This concept is inherently broken with inline loops. --- src/codegen.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index 4c212c95ab..547840514a 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -722,7 +722,6 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) { case ScopeIdCompTime: case ScopeIdCoroPrelude: case ScopeIdRuntime: - case ScopeIdElide: return get_di_scope(g, scope->parent); } zig_unreachable(); @@ -5761,12 +5760,10 @@ static void ir_render(CodeGen *g, ZigFn *fn_entry) { if (instruction->ref_count == 0 && !ir_has_side_effects(instruction)) continue; - if (!scope_is_elided(instruction->scope)) { - if (!g->strip_debug_symbols) { - set_debug_location(g, instruction); - } - instruction->llvm_value = ir_render_instruction(g, executable, instruction); + if (!g->strip_debug_symbols) { + set_debug_location(g, instruction); } + instruction->llvm_value = ir_render_instruction(g, executable, instruction); } current_block->llvm_exit_block = LLVMGetInsertBlock(g->builder); } -- cgit v1.2.3