IR: if and switch guaranteed compile time if target expr is

This commit is contained in:
Andrew Kelley
2016-12-19 00:04:51 -05:00
parent 956ff8a7f9
commit 09c34352f8
6 changed files with 257 additions and 118 deletions

View File

@@ -1646,8 +1646,6 @@ static LLVMValueRef ir_render_ctz(CodeGen *g, IrExecutable *executable, IrInstru
}
static LLVMValueRef ir_render_switch_br(CodeGen *g, IrExecutable *executable, IrInstructionSwitchBr *instruction) {
assert(!instruction->is_inline);
LLVMValueRef target_value = ir_llvm_value(g, instruction->target_value);
LLVMBasicBlockRef else_block = instruction->else_block->llvm_block;
LLVMValueRef switch_instr = LLVMBuildSwitch(g->builder, target_value, else_block, instruction->case_count);
@@ -2197,6 +2195,7 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable,
case IrInstructionIdMemberCount:
case IrInstructionIdAlignOf:
case IrInstructionIdFnProto:
case IrInstructionIdTestComptime:
zig_unreachable();
case IrInstructionIdReturn:
return ir_render_return(g, executable, (IrInstructionReturn *)instruction);
@@ -2897,7 +2896,7 @@ static void do_code_gen(CodeGen *g) {
if (!type_has_bits(var->type)) {
continue;
}
if (var->is_inline)
if (ir_get_var_is_comptime(var))
continue;
if (var->src_arg_index == SIZE_MAX) {