From 86f362ce8e878188d40393e6f2feba0c60ddbcf0 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 22 Jun 2019 16:18:42 -0400 Subject: elide redundant safety check when switching on tagged unions --- src/codegen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index 5b7169f312..4eea729dd9 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -3890,7 +3890,7 @@ static LLVMValueRef ir_render_union_field_ptr(CodeGen *g, IrExecutable *executab LLVMValueRef tag_value = bigint_to_llvm_const(get_llvm_type(g, union_type->data.unionation.tag_type), &field->enum_field->value); gen_store_untyped(g, tag_value, tag_field_ptr, 0, false); - } else if (ir_want_runtime_safety(g, &instruction->base)) { + } else if (instruction->safety_check_on && ir_want_runtime_safety(g, &instruction->base)) { LLVMValueRef tag_field_ptr = LLVMBuildStructGEP(g->builder, union_ptr, union_type->data.unionation.gen_tag_index, ""); LLVMValueRef tag_value = gen_load_untyped(g, tag_field_ptr, 0, false, ""); -- cgit v1.2.3