authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-02-09 12:43:08-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-02-09 12:43:08-05:00
log92ffcc84a9d5da32a645321eee8d33c179d03562
treeab9e581daac8893d8480f05ad63319378c41d3d1
parentfc100d7b3b27bd514dca4e02c160e5b96d4da648

remove the depends_on_compile_var code

cleanup from the decision in commit 8a859afd580f438f549ee69a to remove "unnecessary if statement" error

4 files changed, 137 insertions(+), 281 deletions(-)

src/all_types.hpp-2
......@@ -149,7 +149,6 @@ enum RuntimeHintMaybe {
149149struct ConstExprValue {
150150 TypeTableEntry *type;
151151 ConstValSpecial special;
152 bool depends_on_compile_var;
153152 LLVMValueRef llvm_value;
154153 LLVMValueRef llvm_global;
155154
......@@ -976,7 +975,6 @@ struct TypeTableEntry {
976975 ZigLLVMDIType *di_type;
977976
978977 bool zero_bits;
979 bool size_depends_on_compile_var;
980978
981979 union {
982980 TypeTableEntryPointer pointer;
src/analyze.cpp-18
......@@ -1146,9 +1146,6 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
11461146 continue;
11471147 }
11481148
1149 enum_type->size_depends_on_compile_var = enum_type->size_depends_on_compile_var ||
1150 field_type->size_depends_on_compile_var;
1151
11521149 if (!type_has_bits(field_type))
11531150 continue;
11541151
......@@ -1320,9 +1317,6 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
13201317 continue;
13211318 }
13221319
1323 struct_type->size_depends_on_compile_var = struct_type->size_depends_on_compile_var ||
1324 field_type->size_depends_on_compile_var;
1325
13261320 if (!type_has_bits(field_type))
13271321 continue;
13281322
......@@ -3348,17 +3342,6 @@ bool const_values_equal(ConstExprValue *a, ConstExprValue *b) {
33483342 zig_unreachable();
33493343}
33503344
3351static bool int_type_depends_on_compile_var(CodeGen *g, TypeTableEntry *int_type) {
3352 assert(int_type->id == TypeTableEntryIdInt);
3353
3354 for (size_t i = 0; i < CIntTypeCount; i += 1) {
3355 if (int_type == g->builtin_types.entry_c_int[i]) {
3356 return true;
3357 }
3358 }
3359 return false;
3360}
3361
33623345static uint64_t max_unsigned_val(TypeTableEntry *type_entry) {
33633346 assert(type_entry->id == TypeTableEntryIdInt);
33643347 if (type_entry->data.integral.bit_count == 64) {
......@@ -3407,7 +3390,6 @@ static int64_t min_signed_val(TypeTableEntry *type_entry) {
34073390void eval_min_max_value(CodeGen *g, TypeTableEntry *type_entry, ConstExprValue *const_val, bool is_max) {
34083391 if (type_entry->id == TypeTableEntryIdInt) {
34093392 const_val->special = ConstValSpecialStatic;
3410 const_val->depends_on_compile_var = int_type_depends_on_compile_var(g, type_entry);
34113393 if (is_max) {
34123394 if (type_entry->data.integral.is_signed) {
34133395 int64_t val = max_signed_val(type_entry);
src/codegen.cpp-3
......@@ -3362,7 +3362,6 @@ static void define_builtin_types(CodeGen *g) {
33623362 bool is_signed = info->is_signed;
33633363
33643364 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdInt);
3365 entry->size_depends_on_compile_var = true;
33663365 entry->type_ref = LLVMIntType(size_in_bits);
33673366
33683367 buf_init_from_str(&entry->name, info->name);
......@@ -3399,7 +3398,6 @@ static void define_builtin_types(CodeGen *g) {
33993398
34003399 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdInt);
34013400 entry->type_ref = LLVMIntType(g->pointer_size_bytes * 8);
3402 entry->size_depends_on_compile_var = true;
34033401
34043402 const char u_or_i = is_signed ? 'i' : 'u';
34053403 buf_resize(&entry->name, 0);
......@@ -3455,7 +3453,6 @@ static void define_builtin_types(CodeGen *g) {
34553453 {
34563454 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdFloat);
34573455 entry->type_ref = LLVMX86FP80Type();
3458 entry->size_depends_on_compile_var = true;
34593456 buf_init_from_str(&entry->name, "c_long_double");
34603457 entry->data.floating.bit_count = 80;
34613458
src/ir.cpp+137-258
......@@ -610,13 +610,12 @@ static IrInstruction *ir_build_return_from(IrBuilder *irb, IrInstruction *old_in
610610}
611611
612612static IrInstruction *ir_create_const(IrBuilder *irb, Scope *scope, AstNode *source_node,
613 TypeTableEntry *type_entry, bool depends_on_compile_var)
613 TypeTableEntry *type_entry)
614614{
615615 assert(type_entry);
616616 IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node);
617617 const_instruction->base.value.type = type_entry;
618618 const_instruction->base.value.special = ConstValSpecialStatic;
619 const_instruction->base.value.depends_on_compile_var = depends_on_compile_var;
620619 return &const_instruction->base;
621620}
622621
......@@ -667,20 +666,19 @@ static IrInstruction *ir_build_const_usize(IrBuilder *irb, Scope *scope, AstNode
667666}
668667
669668static IrInstruction *ir_create_const_type(IrBuilder *irb, Scope *scope, AstNode *source_node,
670 TypeTableEntry *type_entry, bool depends_on_compile_var)
669 TypeTableEntry *type_entry)
671670{
672671 IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node);
673672 const_instruction->base.value.type = irb->codegen->builtin_types.entry_type;
674673 const_instruction->base.value.special = ConstValSpecialStatic;
675 const_instruction->base.value.depends_on_compile_var = depends_on_compile_var;
676674 const_instruction->base.value.data.x_type = type_entry;
677675 return &const_instruction->base;
678676}
679677
680678static IrInstruction *ir_build_const_type(IrBuilder *irb, Scope *scope, AstNode *source_node,
681 TypeTableEntry *type_entry, bool depends_on_compile_var)
679 TypeTableEntry *type_entry)
682680{
683 IrInstruction *instruction = ir_create_const_type(irb, scope, source_node, type_entry, depends_on_compile_var);
681 IrInstruction *instruction = ir_create_const_type(irb, scope, source_node, type_entry);
684682 ir_instruction_append(irb->current_basic_block, instruction);
685683 return instruction;
686684}
......@@ -720,12 +718,11 @@ static IrInstruction *ir_build_const_bool(IrBuilder *irb, Scope *scope, AstNode
720718}
721719
722720static IrInstruction *ir_build_const_bound_fn(IrBuilder *irb, Scope *scope, AstNode *source_node,
723 FnTableEntry *fn_entry, IrInstruction *first_arg, bool depends_on_compile_var)
721 FnTableEntry *fn_entry, IrInstruction *first_arg)
724722{
725723 IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node);
726724 const_instruction->base.value.type = get_bound_fn_type(irb->codegen, fn_entry);
727725 const_instruction->base.value.special = ConstValSpecialStatic;
728 const_instruction->base.value.depends_on_compile_var = depends_on_compile_var;
729726 const_instruction->base.value.data.x_bound_fn.fn = fn_entry;
730727 const_instruction->base.value.data.x_bound_fn.first_arg = first_arg;
731728 return &const_instruction->base;
......@@ -3609,7 +3606,7 @@ static IrInstruction *ir_gen_null_literal(IrBuilder *irb, Scope *scope, AstNode
36093606static IrInstruction *ir_gen_var_literal(IrBuilder *irb, Scope *scope, AstNode *node) {
36103607 assert(node->type == NodeTypeVarLiteral);
36113608
3612 return ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_var, false);
3609 return ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_var);
36133610}
36143611
36153612static IrInstruction *ir_gen_decl_ref(IrBuilder *irb, AstNode *source_node, Tld *tld,
......@@ -3648,7 +3645,7 @@ static IrInstruction *ir_gen_decl_ref(IrBuilder *irb, AstNode *source_node, Tld
36483645 {
36493646 TldTypeDef *tld_typedef = (TldTypeDef *)tld;
36503647 TypeTableEntry *typedef_type = tld_typedef->type_entry;
3651 IrInstruction *ref_instruction = ir_build_const_type(irb, scope, source_node, typedef_type, false);
3648 IrInstruction *ref_instruction = ir_build_const_type(irb, scope, source_node, typedef_type);
36523649 if (lval.is_ptr)
36533650 return ir_build_ref(irb, scope, source_node, ref_instruction, true, false);
36543651 else
......@@ -3665,7 +3662,7 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node,
36653662
36663663 auto primitive_table_entry = irb->codegen->primitive_type_table.maybe_get(variable_name);
36673664 if (primitive_table_entry) {
3668 IrInstruction *value = ir_build_const_type(irb, scope, node, primitive_table_entry->value, false);
3665 IrInstruction *value = ir_build_const_type(irb, scope, node, primitive_table_entry->value);
36693666 if (lval.is_ptr) {
36703667 return ir_build_ref(irb, scope, node, value, lval.is_const, lval.is_volatile);
36713668 } else {
......@@ -4629,7 +4626,7 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo
46294626 }
46304627 child_scope = index_var->child_scope;
46314628
4632 IrInstruction *usize = ir_build_const_type(irb, child_scope, node, irb->codegen->builtin_types.entry_usize, false);
4629 IrInstruction *usize = ir_build_const_type(irb, child_scope, node, irb->codegen->builtin_types.entry_usize);
46334630 IrInstruction *zero = ir_build_const_usize(irb, child_scope, node, 0);
46344631 IrInstruction *one = ir_build_const_usize(irb, child_scope, node, 1);
46354632 ir_build_var_decl(irb, child_scope, index_var_source_node, index_var, usize, zero);
......@@ -4693,7 +4690,7 @@ static IrInstruction *ir_gen_this_literal(IrBuilder *irb, Scope *scope, AstNode
46934690 ScopeDecls *decls_scope = (ScopeDecls *)scope;
46944691 TypeTableEntry *container_type = decls_scope->container_type;
46954692 assert(container_type);
4696 return ir_build_const_type(irb, scope, node, container_type, false);
4693 return ir_build_const_type(irb, scope, node, container_type);
46974694 }
46984695
46994696 if (scope->id == ScopeIdBlock)
......@@ -5260,12 +5257,12 @@ static IrInstruction *ir_gen_continue(IrBuilder *irb, Scope *scope, AstNode *nod
52605257
52615258static IrInstruction *ir_gen_type_literal(IrBuilder *irb, Scope *scope, AstNode *node) {
52625259 assert(node->type == NodeTypeTypeLiteral);
5263 return ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_type, false);
5260 return ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_type);
52645261}
52655262
52665263static IrInstruction *ir_gen_error_type(IrBuilder *irb, Scope *scope, AstNode *node) {
52675264 assert(node->type == NodeTypeErrorType);
5268 return ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_pure_error, false);
5265 return ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_pure_error);
52695266}
52705267
52715268static IrInstruction *ir_gen_defer(IrBuilder *irb, Scope *parent_scope, AstNode *node) {
......@@ -5339,7 +5336,7 @@ static IrInstruction *ir_gen_err_ok_or(IrBuilder *irb, Scope *parent_scope, AstN
53395336 if (var_node) {
53405337 assert(var_node->type == NodeTypeSymbol);
53415338 IrInstruction *var_type = ir_build_const_type(irb, parent_scope, node,
5342 irb->codegen->builtin_types.entry_pure_error, false);
5339 irb->codegen->builtin_types.entry_pure_error);
53435340 Buf *var_name = var_node->data.symbol_expr.symbol;
53445341 bool is_const = true;
53455342 bool is_shadowable = false;
......@@ -5427,7 +5424,7 @@ static IrInstruction *ir_gen_container_decl(IrBuilder *irb, Scope *parent_scope,
54275424 }
54285425 irb->codegen->resolve_queue.append(&tld_container->base);
54295426
5430 return ir_build_const_type(irb, parent_scope, node, container_type, false);
5427 return ir_build_const_type(irb, parent_scope, node, container_type);
54315428}
54325429
54335430static IrInstruction *ir_gen_fn_proto(IrBuilder *irb, Scope *parent_scope, AstNode *node) {
......@@ -5997,7 +5994,6 @@ static void eval_const_expr_implicit_cast(CastOp cast_op,
59975994 ConstExprValue *other_val, TypeTableEntry *other_type,
59985995 ConstExprValue *const_val, TypeTableEntry *new_type)
59995996{
6000 const_val->depends_on_compile_var = other_val->depends_on_compile_var;
60015997 const_val->special = other_val->special;
60025998
60035999 assert(other_val != const_val);
......@@ -6045,7 +6041,7 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst
60456041{
60466042 if (value->value.special != ConstValSpecialRuntime) {
60476043 IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,
6048 source_instr->source_node, wanted_type, false);
6044 source_instr->source_node, wanted_type);
60496045 eval_const_expr_implicit_cast(cast_op, &value->value, value->value.type,
60506046 &result->value, wanted_type);
60516047 return result;
......@@ -6179,9 +6175,7 @@ static TypeTableEntry *ir_finish_anal(IrAnalyze *ira, TypeTableEntry *result_typ
61796175 return result_type;
61806176}
61816177
6182static ConstExprValue *ir_build_const_from(IrAnalyze *ira, IrInstruction *old_instruction,
6183 bool depends_on_compile_var)
6184{
6178static ConstExprValue *ir_build_const_from(IrAnalyze *ira, IrInstruction *old_instruction) {
61856179 IrInstruction *new_instruction;
61866180 if (old_instruction->id == IrInstructionIdVarPtr) {
61876181 IrInstructionVarPtr *old_var_ptr_instruction = (IrInstructionVarPtr *)old_instruction;
......@@ -6205,17 +6199,16 @@ static ConstExprValue *ir_build_const_from(IrAnalyze *ira, IrInstruction *old_in
62056199 ir_link_new_instruction(new_instruction, old_instruction);
62066200 ConstExprValue *const_val = &new_instruction->value;
62076201 const_val->special = ConstValSpecialStatic;
6208 const_val->depends_on_compile_var = depends_on_compile_var;
62096202 return const_val;
62106203}
62116204
62126205static TypeTableEntry *ir_analyze_void(IrAnalyze *ira, IrInstruction *instruction) {
6213 ir_build_const_from(ira, instruction, false);
6206 ir_build_const_from(ira, instruction);
62146207 return ira->codegen->builtin_types.entry_void;
62156208}
62166209
62176210static TypeTableEntry *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instruction,
6218 ConstExprValue *pointee, TypeTableEntry *pointee_type, bool depends_on_compile_var,
6211 ConstExprValue *pointee, TypeTableEntry *pointee_type,
62196212 ConstPtrSpecial special, bool ptr_is_const, bool ptr_is_volatile)
62206213{
62216214 if (pointee_type->id == TypeTableEntryIdMetaType) {
......@@ -6225,8 +6218,7 @@ static TypeTableEntry *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instr
62256218 return ira->codegen->builtin_types.entry_invalid;
62266219 }
62276220
6228 ConstExprValue *const_val = ir_build_const_from(ira, instruction,
6229 depends_on_compile_var || pointee->depends_on_compile_var);
6221 ConstExprValue *const_val = ir_build_const_from(ira, instruction);
62306222 type_ensure_zero_bits_known(ira->codegen, type_entry);
62316223 const_val->data.x_type = get_pointer_to_type_volatile(ira->codegen, type_entry,
62326224 ptr_is_const, ptr_is_volatile);
......@@ -6234,8 +6226,7 @@ static TypeTableEntry *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instr
62346226 } else {
62356227 TypeTableEntry *ptr_type = get_pointer_to_type_volatile(ira->codegen, pointee_type,
62366228 ptr_is_const, ptr_is_volatile);
6237 ConstExprValue *const_val = ir_build_const_from(ira, instruction,
6238 depends_on_compile_var || pointee->depends_on_compile_var);
6229 ConstExprValue *const_val = ir_build_const_from(ira, instruction);
62396230 const_val->data.x_ptr.base_ptr = pointee;
62406231 const_val->data.x_ptr.index = SIZE_MAX;
62416232 const_val->data.x_ptr.special = special;
......@@ -6243,10 +6234,8 @@ static TypeTableEntry *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instr
62436234 }
62446235}
62456236
6246static TypeTableEntry *ir_analyze_const_usize(IrAnalyze *ira, IrInstruction *instruction, uint64_t value,
6247 bool depends_on_compile_var)
6248{
6249 ConstExprValue *const_val = ir_build_const_from(ira, instruction, depends_on_compile_var);
6237static TypeTableEntry *ir_analyze_const_usize(IrAnalyze *ira, IrInstruction *instruction, uint64_t value) {
6238 ConstExprValue *const_val = ir_build_const_from(ira, instruction);
62506239 bignum_init_unsigned(&const_val->data.x_bignum, value);
62516240 return ira->codegen->builtin_types.entry_usize;
62526241}
......@@ -6376,7 +6365,6 @@ static IrInstruction *ir_analyze_maybe_wrap(IrAnalyze *ira, IrInstruction *sourc
63766365 source_instr->scope, source_instr->source_node);
63776366 const_instruction->base.value.type = wanted_type;
63786367 const_instruction->base.value.special = ConstValSpecialStatic;
6379 const_instruction->base.value.depends_on_compile_var = val->depends_on_compile_var;
63806368 const_instruction->base.value.data.x_maybe = val;
63816369 return &const_instruction->base;
63826370 }
......@@ -6435,7 +6423,6 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction
64356423 source_instr->scope, source_instr->source_node);
64366424 const_instruction->base.value.type = wanted_type;
64376425 const_instruction->base.value.special = ConstValSpecialStatic;
6438 const_instruction->base.value.depends_on_compile_var = val->depends_on_compile_var;
64396426 const_instruction->base.value.data.x_err_union.err = nullptr;
64406427 const_instruction->base.value.data.x_err_union.payload = val;
64416428 return &const_instruction->base;
......@@ -6460,7 +6447,6 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so
64606447 source_instr->scope, source_instr->source_node);
64616448 const_instruction->base.value.type = wanted_type;
64626449 const_instruction->base.value.special = ConstValSpecialStatic;
6463 const_instruction->base.value.depends_on_compile_var = val->depends_on_compile_var;
64646450 const_instruction->base.value.data.x_err_union.err = val->data.x_pure_err;
64656451 const_instruction->base.value.data.x_err_union.payload = nullptr;
64666452 return &const_instruction->base;
......@@ -6485,7 +6471,6 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_
64856471 source_instr->scope, source_instr->source_node);
64866472 const_instruction->base.value.type = wanted_type;
64876473 const_instruction->base.value.special = ConstValSpecialStatic;
6488 const_instruction->base.value.depends_on_compile_var = val->depends_on_compile_var;
64896474 const_instruction->base.value.data.x_ptr.base_ptr = val;
64906475 const_instruction->base.value.data.x_ptr.index = SIZE_MAX;
64916476 return &const_instruction->base;
......@@ -6519,7 +6504,6 @@ static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *so
65196504 IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, source_instr->scope, source_instr->source_node);
65206505 const_instruction->base.value.type = wanted_type;
65216506 const_instruction->base.value.special = ConstValSpecialStatic;
6522 const_instruction->base.value.depends_on_compile_var = val->depends_on_compile_var;
65236507 const_instruction->base.value.data.x_maybe = nullptr;
65246508 return &const_instruction->base;
65256509}
......@@ -6534,17 +6518,17 @@ static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *s
65346518
65356519 if (instr_is_comptime(array)) {
65366520 IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,
6537 source_instr->source_node, wanted_type, false);
6521 source_instr->source_node, wanted_type);
65386522 init_const_slice(ira->codegen, &result->value, &array->value, 0, array_type->data.array.len, true);
65396523 return result;
65406524 }
65416525
65426526 IrInstruction *start = ir_create_const(&ira->new_irb, source_instr->scope,
6543 source_instr->source_node, ira->codegen->builtin_types.entry_usize, false);
6527 source_instr->source_node, ira->codegen->builtin_types.entry_usize);
65446528 init_const_usize(ira->codegen, &start->value, 0);
65456529
65466530 IrInstruction *end = ir_create_const(&ira->new_irb, source_instr->scope,
6547 source_instr->source_node, ira->codegen->builtin_types.entry_usize, false);
6531 source_instr->source_node, ira->codegen->builtin_types.entry_usize);
65486532 init_const_usize(ira->codegen, &end->value, array_type->data.array.len);
65496533
65506534 bool is_const;
......@@ -6573,7 +6557,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour
65736557 if (!val)
65746558 return ira->codegen->invalid_instruction;
65756559 IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,
6576 source_instr->source_node, wanted_type, val->depends_on_compile_var);
6560 source_instr->source_node, wanted_type);
65776561 init_const_unsigned_negative(&result->value, wanted_type, val->data.x_enum.tag, false);
65786562 return result;
65796563 }
......@@ -6588,7 +6572,7 @@ static IrInstruction *ir_analyze_undefined_to_anything(IrAnalyze *ira, IrInstruc
65886572 IrInstruction *target, TypeTableEntry *wanted_type)
65896573{
65906574 IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,
6591 source_instr->source_node, wanted_type, target->value.depends_on_compile_var);
6575 source_instr->source_node, wanted_type);
65926576 init_const_undefined(ira->codegen, &result->value);
65936577 return result;
65946578}
......@@ -6603,7 +6587,7 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction
66036587 if (!val)
66046588 return ira->codegen->invalid_instruction;
66056589 IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,
6606 source_instr->source_node, wanted_type, val->depends_on_compile_var);
6590 source_instr->source_node, wanted_type);
66076591 result->value = *val;
66086592 result->value.type = wanted_type;
66096593 return result;
......@@ -6626,7 +6610,7 @@ static IrInstruction *ir_analyze_ptr_to_int(IrAnalyze *ira, IrInstruction *sourc
66266610 return ira->codegen->invalid_instruction;
66276611 if (val->data.x_ptr.special == ConstPtrSpecialRuntime) {
66286612 IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,
6629 source_instr->source_node, wanted_type, val->depends_on_compile_var);
6613 source_instr->source_node, wanted_type);
66306614 bignum_init_unsigned(&result->value.data.x_bignum, val->data.x_ptr.index);
66316615 return result;
66326616 }
......@@ -6648,7 +6632,7 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc
66486632 if (!val)
66496633 return ira->codegen->invalid_instruction;
66506634 IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,
6651 source_instr->source_node, wanted_type, val->depends_on_compile_var);
6635 source_instr->source_node, wanted_type);
66526636 result->value.data.x_ptr.base_ptr = nullptr;
66536637 result->value.data.x_ptr.index = bignum_to_twos_complement(&val->data.x_bignum);
66546638 result->value.data.x_ptr.special = ConstPtrSpecialRuntime;
......@@ -6675,7 +6659,7 @@ static IrInstruction *ir_analyze_int_lit_to_ptr(IrAnalyze *ira, IrInstruction *s
66756659 return ira->codegen->invalid_instruction;
66766660
66776661 IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,
6678 source_instr->source_node, wanted_type, val->depends_on_compile_var);
6662 source_instr->source_node, wanted_type);
66796663 result->value.data.x_ptr.base_ptr = nullptr;
66806664 result->value.data.x_ptr.index = bignum_to_twos_complement(&val->data.x_bignum);
66816665 result->value.data.x_ptr.special = ConstPtrSpecialRuntime;
......@@ -6692,7 +6676,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour
66926676 if (!val)
66936677 return ira->codegen->invalid_instruction;
66946678 IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,
6695 source_instr->source_node, wanted_type, val->depends_on_compile_var);
6679 source_instr->source_node, wanted_type);
66966680 result->value.data.x_enum.tag = val->data.x_bignum.data.x_uint;
66976681 return result;
66986682 }
......@@ -6711,7 +6695,7 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction
67116695 return ira->codegen->invalid_instruction;
67126696
67136697 IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,
6714 source_instr->source_node, wanted_type, true);
6698 source_instr->source_node, wanted_type);
67156699 bignum_init_bignum(&result->value.data.x_bignum, &val->data.x_bignum);
67166700 return result;
67176701}
......@@ -7026,10 +7010,8 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc
70267010 ConstExprValue *pointee = const_ptr_pointee(&ptr->value);
70277011 if (pointee->special != ConstValSpecialRuntime) {
70287012 IrInstruction *result = ir_create_const(&ira->new_irb, source_instruction->scope,
7029 source_instruction->source_node, child_type, false);
7013 source_instruction->source_node, child_type);
70307014 result->value = *pointee;
7031 result->value.depends_on_compile_var = pointee->depends_on_compile_var ||
7032 ptr->value.depends_on_compile_var;
70337015 return result;
70347016 }
70357017 }
......@@ -7046,7 +7028,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc
70467028 if (ptr_type->id == TypeTableEntryIdPointer) {
70477029 TypeTableEntry *child_type = ptr_type->data.pointer.child_type;
70487030 return ir_create_const_type(&ira->new_irb, source_instruction->scope,
7049 source_instruction->source_node, child_type, ptr_val->depends_on_compile_var);
7031 source_instruction->source_node, child_type);
70507032 } else {
70517033 ir_add_error(ira, source_instruction,
70527034 buf_sprintf("attempt to dereference non pointer type '%s'", buf_ptr(&ptr_type->name)));
......@@ -7071,7 +7053,7 @@ static TypeTableEntry *ir_analyze_ref(IrAnalyze *ira, IrInstruction *source_inst
70717053 if (!val)
70727054 return ira->codegen->builtin_types.entry_invalid;
70737055 return ir_analyze_const_ptr(ira, source_instruction, val, value->value.type,
7074 value->value.depends_on_compile_var, ConstPtrSpecialNone, is_const, is_volatile);
7056 ConstPtrSpecialNone, is_const, is_volatile);
70757057 }
70767058
70777059 TypeTableEntry *ptr_type = get_pointer_to_type_volatile(ira->codegen, value->value.type, is_const, is_volatile);
......@@ -7187,8 +7169,7 @@ static TypeTableEntry *ir_analyze_instruction_return(IrAnalyze *ira,
71877169}
71887170
71897171static TypeTableEntry *ir_analyze_instruction_const(IrAnalyze *ira, IrInstructionConst *const_instruction) {
7190 bool depends_on_compile_var = const_instruction->base.value.depends_on_compile_var;
7191 ConstExprValue *out_val = ir_build_const_from(ira, &const_instruction->base, depends_on_compile_var);
7172 ConstExprValue *out_val = ir_build_const_from(ira, &const_instruction->base);
71927173 *out_val = const_instruction->base.value;
71937174 return const_instruction->base.value.type;
71947175}
......@@ -7215,8 +7196,7 @@ static TypeTableEntry *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp
72157196 ConstExprValue *op1_val = &casted_op1->value;
72167197 ConstExprValue *op2_val = &casted_op2->value;
72177198 if (op1_val->special != ConstValSpecialRuntime && op2_val->special != ConstValSpecialRuntime) {
7218 bool depends_on_compile_var = op1_val->depends_on_compile_var || op2_val->depends_on_compile_var;
7219 ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base, depends_on_compile_var);
7199 ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base);
72207200
72217201 assert(casted_op1->value.type->id == TypeTableEntryIdBool);
72227202 assert(casted_op2->value.type->id == TypeTableEntryIdBool);
......@@ -7246,9 +7226,8 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
72467226 (op2->value.type->id == TypeTableEntryIdNullLit && op1->value.type->id == TypeTableEntryIdMaybe) ||
72477227 (op1->value.type->id == TypeTableEntryIdNullLit && op2->value.type->id == TypeTableEntryIdNullLit)))
72487228 {
7249 bool depends_on_compile_var = op1->value.depends_on_compile_var || op2->value.depends_on_compile_var;
72507229 if (op1->value.type->id == TypeTableEntryIdNullLit && op2->value.type->id == TypeTableEntryIdNullLit) {
7251 ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base, depends_on_compile_var);
7230 ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base);
72527231 out_val->data.x_bool = (op_id == IrBinOpCmpEq);
72537232 return ira->codegen->builtin_types.entry_bool;
72547233 }
......@@ -7265,7 +7244,7 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
72657244 if (!maybe_val)
72667245 return ira->codegen->builtin_types.entry_invalid;
72677246 bool is_null = (maybe_val->data.x_maybe == nullptr);
7268 ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base, depends_on_compile_var);
7247 ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base);
72697248 out_val->data.x_bool = (op_id == IrBinOpCmpEq) ? is_null : !is_null;
72707249 return ira->codegen->builtin_types.entry_bool;
72717250 }
......@@ -7389,8 +7368,7 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
73897368 }
73907369 }
73917370
7392 bool depends_on_compile_var = op1_val->depends_on_compile_var || op2_val->depends_on_compile_var;
7393 ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base, depends_on_compile_var);
7371 ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base);
73947372 out_val->data.x_bool = answer;
73957373 return ira->codegen->builtin_types.entry_bool;
73967374 }
......@@ -7463,7 +7441,6 @@ static int ir_eval_bignum(ConstExprValue *op1_val, ConstExprValue *op2_val,
74637441 }
74647442
74657443 out_val->special = ConstValSpecialStatic;
7466 out_val->depends_on_compile_var = op1_val->depends_on_compile_var || op2_val->depends_on_compile_var;
74677444 return 0;
74687445}
74697446
......@@ -7682,8 +7659,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *
76827659 return ira->codegen->builtin_types.entry_invalid;
76837660 }
76847661
7685 bool depends_on_compile_var = op1->value.depends_on_compile_var || op2->value.depends_on_compile_var;
7686 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var);
7662 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
76877663
76887664 TypeTableEntry *result_type;
76897665 ConstExprValue *out_array_val;
......@@ -7757,8 +7733,7 @@ static TypeTableEntry *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp
77577733 return ira->codegen->builtin_types.entry_invalid;
77587734 }
77597735
7760 bool depends_on_compile_var = op1->value.depends_on_compile_var || op2->value.depends_on_compile_var;
7761 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var);
7736 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
77627737
77637738 uint64_t new_array_len = array_len.data.x_uint;
77647739 out_val->data.x_array.size = new_array_len;
......@@ -7913,7 +7888,7 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc
79137888 *mem_slot = casted_init_value->value;
79147889
79157890 if (is_comptime) {
7916 ir_build_const_from(ira, &decl_var_instruction->base, false);
7891 ir_build_const_from(ira, &decl_var_instruction->base);
79177892 return ira->codegen->builtin_types.entry_void;
79187893 }
79197894 }
......@@ -7954,7 +7929,6 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node
79547929 Buf *param_name = param_decl_node->data.param_decl.name;
79557930 VariableTableEntry *var = add_variable(ira->codegen, param_decl_node,
79567931 *exec_scope, param_name, true, arg_val);
7957 var->value.depends_on_compile_var = true;
79587932 *exec_scope = var->child_scope;
79597933 *next_proto_i += 1;
79607934
......@@ -8000,9 +7974,6 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
80007974 arg_val = ir_resolve_const(ira, casted_arg, UndefBad);
80017975 if (!arg_val)
80027976 return false;
8003 // This generic function instance could be called with anything, so when this variable is read it
8004 // needs to know that it depends on compile time variable data.
8005 arg_val->depends_on_compile_var = true;
80067977 } else {
80077978 arg_val = create_const_runtime(casted_arg->value.type);
80087979 }
......@@ -8015,7 +7986,6 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
80157986 if (!is_var_args) {
80167987 VariableTableEntry *var = add_variable(ira->codegen, param_decl_node,
80177988 *child_scope, param_name, true, arg_val);
8018 var->value.depends_on_compile_var = true;
80197989 *child_scope = var->child_scope;
80207990 var->shadowable = !comptime_arg;
80217991
......@@ -8133,8 +8103,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
81338103 ira->codegen->memoized_fn_eval_table.put(exec_scope, result);
81348104 }
81358105
8136 ConstExprValue *out_val = ir_build_const_from(ira, &call_instruction->base,
8137 result->value.depends_on_compile_var);
8106 ConstExprValue *out_val = ir_build_const_from(ira, &call_instruction->base);
81388107 *out_val = result->value;
81398108 return ir_finish_anal(ira, return_type);
81408109 }
......@@ -8212,7 +8181,6 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
82128181 first_var_arg, inst_fn_type_id.param_count);
82138182 VariableTableEntry *var = add_variable(ira->codegen, param_decl_node,
82148183 impl_fn->child_scope, param_name, true, var_args_val);
8215 var->value.depends_on_compile_var = true;
82168184 impl_fn->child_scope = var->child_scope;
82178185 }
82188186 {
......@@ -8398,8 +8366,7 @@ static TypeTableEntry *ir_analyze_unary_prefix_op_err(IrAnalyze *ira, IrInstruct
83988366 case TypeTableEntryIdBoundFn:
83998367 case TypeTableEntryIdEnumTag:
84008368 {
8401 ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base,
8402 value->value.depends_on_compile_var);
8369 ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base);
84038370 TypeTableEntry *result_type = get_error_type(ira->codegen, meta_type);
84048371 out_val->data.x_type = result_type;
84058372 return ira->codegen->builtin_types.entry_type;
......@@ -8443,7 +8410,7 @@ static TypeTableEntry *ir_analyze_dereference(IrAnalyze *ira, IrInstructionUnOp
84438410 // one of the ptr instructions
84448411
84458412 if (value->value.special != ConstValSpecialRuntime) {
8446 ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base, false);
8413 ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base);
84478414 ConstExprValue *pointee = const_ptr_pointee(&value->value);
84488415 *out_val = *pointee;
84498416 return child_type;
......@@ -8488,8 +8455,7 @@ static TypeTableEntry *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op
84888455 case TypeTableEntryIdEnumTag:
84898456 case TypeTableEntryIdArgTuple:
84908457 {
8491 ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base,
8492 value->value.depends_on_compile_var);
8458 ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base);
84938459 out_val->data.x_type = get_maybe_type(ira->codegen, type_entry);
84948460 return ira->codegen->builtin_types.entry_type;
84958461 }
......@@ -8519,8 +8485,7 @@ static TypeTableEntry *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un
85198485 if (!target_const_val)
85208486 return ira->codegen->builtin_types.entry_invalid;
85218487
8522 bool depends_on_compile_var = value->value.depends_on_compile_var;
8523 ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base, depends_on_compile_var);
8488 ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base);
85248489 bignum_negate(&out_val->data.x_bignum, &target_const_val->data.x_bignum);
85258490 if (expr_type->id == TypeTableEntryIdFloat ||
85268491 expr_type->id == TypeTableEntryIdNumLitFloat ||
......@@ -8561,8 +8526,7 @@ static TypeTableEntry *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *ins
85618526 if (!target_const_val)
85628527 return ira->codegen->builtin_types.entry_invalid;
85638528
8564 bool depends_on_compile_var = value->value.depends_on_compile_var;
8565 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var);
8529 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
85668530 bignum_not(&out_val->data.x_bignum, &target_const_val->data.x_bignum,
85678531 expr_type->data.integral.bit_count, expr_type->data.integral.is_signed);
85688532 return expr_type;
......@@ -8669,9 +8633,8 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP
86698633 return ira->codegen->builtin_types.entry_invalid;
86708634
86718635 if (value->value.special != ConstValSpecialRuntime) {
8672 ConstExprValue *out_val = ir_build_const_from(ira, &phi_instruction->base, true);
8636 ConstExprValue *out_val = ir_build_const_from(ira, &phi_instruction->base);
86738637 *out_val = value->value;
8674 out_val->depends_on_compile_var = true;
86758638 } else {
86768639 phi_instruction->base.other = value;
86778640 }
......@@ -8705,7 +8668,7 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP
87058668 }
87068669
87078670 if (new_incoming_blocks.length == 0) {
8708 ir_build_const_from(ira, &phi_instruction->base, true);
8671 ir_build_const_from(ira, &phi_instruction->base);
87098672 return ira->codegen->builtin_types.entry_void;
87108673 }
87118674
......@@ -8752,7 +8715,7 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP
87528715}
87538716
87548717static TypeTableEntry *ir_analyze_var_ptr(IrAnalyze *ira, IrInstruction *instruction,
8755 VariableTableEntry *var, bool is_const_ptr, bool is_volatile_ptr, bool depends_on_compile_var)
8718 VariableTableEntry *var, bool is_const_ptr, bool is_volatile_ptr)
87568719{
87578720 assert(var->value.type);
87588721 if (var->value.type->id == TypeTableEntryIdInvalid)
......@@ -8775,9 +8738,7 @@ static TypeTableEntry *ir_analyze_var_ptr(IrAnalyze *ira, IrInstruction *instruc
87758738 bool is_volatile = (var->value.type->id == TypeTableEntryIdMetaType) ? is_volatile_ptr : false;
87768739 if (mem_slot && mem_slot->special != ConstValSpecialRuntime) {
87778740 ConstPtrSpecial ptr_special = is_comptime ? ConstPtrSpecialInline : ConstPtrSpecialNone;
8778 depends_on_compile_var = mem_slot->depends_on_compile_var || depends_on_compile_var || is_comptime;
8779 return ir_analyze_const_ptr(ira, instruction, mem_slot, var->value.type,
8780 depends_on_compile_var, ptr_special, is_const, is_volatile);
8741 return ir_analyze_const_ptr(ira, instruction, mem_slot, var->value.type, ptr_special, is_const, is_volatile);
87818742 } else {
87828743 ir_build_var_ptr_from(&ira->new_irb, instruction, var, is_const, is_volatile);
87838744 type_ensure_zero_bits_known(ira->codegen, var->value.type);
......@@ -8788,7 +8749,7 @@ static TypeTableEntry *ir_analyze_var_ptr(IrAnalyze *ira, IrInstruction *instruc
87888749static TypeTableEntry *ir_analyze_instruction_var_ptr(IrAnalyze *ira, IrInstructionVarPtr *var_ptr_instruction) {
87898750 VariableTableEntry *var = var_ptr_instruction->var;
87908751 return ir_analyze_var_ptr(ira, &var_ptr_instruction->base, var, var_ptr_instruction->is_const,
8791 var_ptr_instruction->is_volatile, false);
8752 var_ptr_instruction->is_volatile);
87928753}
87938754
87948755static VariableTableEntry *get_fn_var_by_index(FnTableEntry *fn_entry, size_t index) {
......@@ -8858,16 +8819,14 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc
88588819 FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
88598820 assert(fn_entry);
88608821 VariableTableEntry *var = get_fn_var_by_index(fn_entry, abs_index);
8861 bool depends_on_compile_var = array_ptr->value.depends_on_compile_var ||
8862 elem_index->value.depends_on_compile_var;
88638822 bool is_const = true;
88648823 bool is_volatile = false;
88658824 if (var) {
88668825 return ir_analyze_var_ptr(ira, &elem_ptr_instruction->base, var,
8867 is_const, is_volatile, depends_on_compile_var);
8826 is_const, is_volatile);
88688827 } else {
88698828 return ir_analyze_const_ptr(ira, &elem_ptr_instruction->base, &ira->codegen->const_void_val,
8870 ira->codegen->builtin_types.entry_void, depends_on_compile_var, ConstPtrSpecialNone,
8829 ira->codegen->builtin_types.entry_void, ConstPtrSpecialNone,
88718830 is_const, is_volatile);
88728831 }
88738832 } else {
......@@ -8901,9 +8860,7 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc
89018860 array_ptr_val->special != ConstValSpecialRuntime &&
89028861 (array_type->id != TypeTableEntryIdPointer || array_ptr_val->data.x_ptr.special != ConstPtrSpecialRuntime))
89038862 {
8904 bool depends_on_compile_var = array_ptr_val->depends_on_compile_var ||
8905 casted_elem_index->value.depends_on_compile_var;
8906 ConstExprValue *out_val = ir_build_const_from(ira, &elem_ptr_instruction->base, depends_on_compile_var);
8863 ConstExprValue *out_val = ir_build_const_from(ira, &elem_ptr_instruction->base);
89078864 if (array_type->id == TypeTableEntryIdPointer) {
89088865 size_t offset = array_ptr_val->data.x_ptr.index;
89098866 size_t new_index;
......@@ -8974,9 +8931,8 @@ static TypeTableEntry *ir_analyze_container_member_access_inner(IrAnalyze *ira,
89748931 return ira->codegen->builtin_types.entry_invalid;
89758932 TldFn *tld_fn = (TldFn *)tld;
89768933 FnTableEntry *fn_entry = tld_fn->fn_entry;
8977 bool depends_on_compile_var = container_ptr->value.depends_on_compile_var;
89788934 IrInstruction *bound_fn_value = ir_build_const_bound_fn(&ira->new_irb, field_ptr_instruction->base.scope,
8979 field_ptr_instruction->base.source_node, fn_entry, container_ptr, depends_on_compile_var);
8935 field_ptr_instruction->base.source_node, fn_entry, container_ptr);
89808936 return ir_analyze_ref(ira, &field_ptr_instruction->base, bound_fn_value, true, false);
89818937 }
89828938 }
......@@ -9011,11 +8967,8 @@ static TypeTableEntry *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field
90118967 if (value_is_comptime(struct_val)) {
90128968 ConstExprValue *field_val = &struct_val->data.x_struct.fields[field->src_index];
90138969 if (value_is_comptime(field_val)) {
9014 bool depends_on_compile_var = field_val->depends_on_compile_var ||
9015 struct_val->depends_on_compile_var || ptr_val->depends_on_compile_var;
90168970 return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, field_val,
9017 field_val->type, depends_on_compile_var, ConstPtrSpecialNone,
9018 is_const, is_volatile);
8971 field_val->type, ConstPtrSpecialNone, is_const, is_volatile);
90198972 }
90208973 }
90218974 }
......@@ -9045,9 +8998,7 @@ static TypeTableEntry *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field
90458998 }
90468999}
90479000
9048static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_instruction, Tld *tld,
9049 bool depends_on_compile_var)
9050{
9001static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_instruction, Tld *tld) {
90519002 bool pointer_only = false;
90529003 resolve_top_level_decl(ira->codegen, tld, pointer_only);
90539004 if (tld->resolution == TldResolutionInvalid)
......@@ -9060,7 +9011,7 @@ static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source
90609011 {
90619012 TldVar *tld_var = (TldVar *)tld;
90629013 VariableTableEntry *var = tld_var->var;
9063 return ir_analyze_var_ptr(ira, source_instruction, var, false, false, depends_on_compile_var);
9014 return ir_analyze_var_ptr(ira, source_instruction, var, false, false);
90649015 }
90659016 case TldIdFn:
90669017 {
......@@ -9081,7 +9032,7 @@ static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source
90819032 bool ptr_is_const = true;
90829033 bool ptr_is_volatile = false;
90839034 return ir_analyze_const_ptr(ira, source_instruction, const_val, fn_entry->type_entry,
9084 depends_on_compile_var, ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile);
9035 ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile);
90859036 }
90869037 case TldIdTypeDef:
90879038 {
......@@ -9098,7 +9049,7 @@ static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source
90989049 bool ptr_is_const = true;
90999050 bool ptr_is_volatile = false;
91009051 return ir_analyze_const_ptr(ira, source_instruction, const_val, ira->codegen->builtin_types.entry_type,
9101 depends_on_compile_var, ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile);
9052 ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile);
91029053 }
91039054 }
91049055 zig_unreachable();
......@@ -9118,7 +9069,6 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
91189069 zig_unreachable();
91199070 }
91209071
9121 bool depends_on_compile_var = container_ptr->value.depends_on_compile_var;
91229072 Buf *field_name = field_ptr_instruction->field_name;
91239073 AstNode *source_node = field_ptr_instruction->base.source_node;
91249074
......@@ -9142,7 +9092,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
91429092 bool ptr_is_const = true;
91439093 bool ptr_is_volatile = false;
91449094 return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, len_val,
9145 usize, depends_on_compile_var, ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile);
9095 usize, ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile);
91469096 } else {
91479097 ir_add_error_node(ira, source_node,
91489098 buf_sprintf("no member named '%s' in '%s'", buf_ptr(field_name),
......@@ -9166,7 +9116,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
91669116 bool ptr_is_const = true;
91679117 bool ptr_is_volatile = false;
91689118 return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, len_val,
9169 usize, depends_on_compile_var, ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile);
9119 usize, ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile);
91709120 } else {
91719121 ir_add_error_node(ira, source_node,
91729122 buf_sprintf("no member named '%s' in '%s'", buf_ptr(field_name),
......@@ -9204,14 +9154,14 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
92049154 bool ptr_is_const = true;
92059155 bool ptr_is_volatile = false;
92069156 return ir_analyze_const_ptr(ira, &field_ptr_instruction->base,
9207 create_const_enum_tag(child_type, field->value), child_type, depends_on_compile_var,
9157 create_const_enum_tag(child_type, field->value), child_type,
92089158 ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile);
92099159 } else {
92109160 bool ptr_is_const = true;
92119161 bool ptr_is_volatile = false;
92129162 return ir_analyze_const_ptr(ira, &field_ptr_instruction->base,
92139163 create_const_unsigned_negative(child_type->data.enumeration.tag_type, field->value, false),
9214 child_type->data.enumeration.tag_type, depends_on_compile_var,
9164 child_type->data.enumeration.tag_type,
92159165 ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile);
92169166 }
92179167 }
......@@ -9220,7 +9170,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
92209170 auto entry = container_scope->decl_table.maybe_get(field_name);
92219171 Tld *tld = entry ? entry->value : nullptr;
92229172 if (tld) {
9223 return ir_analyze_decl_ref(ira, &field_ptr_instruction->base, tld, depends_on_compile_var);
9173 return ir_analyze_decl_ref(ira, &field_ptr_instruction->base, tld);
92249174 }
92259175 ir_add_error(ira, &field_ptr_instruction->base,
92269176 buf_sprintf("container '%s' has no member called '%s'",
......@@ -9237,7 +9187,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
92379187 bool ptr_is_const = true;
92389188 bool ptr_is_volatile = false;
92399189 return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, const_val,
9240 child_type, depends_on_compile_var, ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile);
9190 child_type, ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile);
92419191 }
92429192
92439193 ir_add_error(ira, &field_ptr_instruction->base,
......@@ -9250,14 +9200,14 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
92509200 return ir_analyze_const_ptr(ira, &field_ptr_instruction->base,
92519201 create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int,
92529202 child_type->data.integral.bit_count, false),
9253 ira->codegen->builtin_types.entry_num_lit_int, depends_on_compile_var,
9203 ira->codegen->builtin_types.entry_num_lit_int,
92549204 ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile);
92559205 } else if (buf_eql_str(field_name, "is_signed")) {
92569206 bool ptr_is_const = true;
92579207 bool ptr_is_volatile = false;
92589208 return ir_analyze_const_ptr(ira, &field_ptr_instruction->base,
92599209 create_const_bool(ira->codegen, child_type->data.integral.is_signed),
9260 ira->codegen->builtin_types.entry_bool, depends_on_compile_var,
9210 ira->codegen->builtin_types.entry_bool,
92619211 ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile);
92629212 } else {
92639213 ir_add_error(ira, &field_ptr_instruction->base,
......@@ -9303,7 +9253,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
93039253 add_error_note(ira->codegen, msg, tld->source_node, buf_sprintf("declared here"));
93049254 return ira->codegen->builtin_types.entry_invalid;
93059255 }
9306 return ir_analyze_decl_ref(ira, &field_ptr_instruction->base, tld, depends_on_compile_var);
9256 return ir_analyze_decl_ref(ira, &field_ptr_instruction->base, tld);
93079257 } else {
93089258 const char *import_name = namespace_import->path ? buf_ptr(namespace_import->path) : "(C import)";
93099259 ir_add_error_node(ira, source_node,
......@@ -9401,10 +9351,7 @@ static TypeTableEntry *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructi
94019351 case TypeTableEntryIdEnumTag:
94029352 case TypeTableEntryIdArgTuple:
94039353 {
9404 ConstExprValue *out_val = ir_build_const_from(ira, &typeof_instruction->base, true);
9405 // TODO depends_on_compile_var should be set based on whether the type of the expression
9406 // depends_on_compile_var. but we currently don't have a thing to tell us if the type of
9407 // something depends on a compile var
9354 ConstExprValue *out_val = ir_build_const_from(ira, &typeof_instruction->base);
94089355 out_val->data.x_type = type_entry;
94099356
94109357 return ira->codegen->builtin_types.entry_type;
......@@ -9438,8 +9385,7 @@ static TypeTableEntry *ir_analyze_instruction_to_ptr_type(IrAnalyze *ira,
94389385 return ira->codegen->builtin_types.entry_invalid;
94399386 }
94409387
9441 ConstExprValue *out_val = ir_build_const_from(ira, &to_ptr_type_instruction->base,
9442 value->value.depends_on_compile_var);
9388 ConstExprValue *out_val = ir_build_const_from(ira, &to_ptr_type_instruction->base);
94439389 out_val->data.x_type = ptr_type;
94449390 return ira->codegen->builtin_types.entry_type;
94459391}
......@@ -9459,8 +9405,7 @@ static TypeTableEntry *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira,
94599405 return ira->codegen->builtin_types.entry_invalid;
94609406 }
94619407
9462 ConstExprValue *out_val = ir_build_const_from(ira, &ptr_type_child_instruction->base,
9463 type_value->value.depends_on_compile_var);
9408 ConstExprValue *out_val = ir_build_const_from(ira, &ptr_type_child_instruction->base);
94649409 out_val->data.x_type = type_entry->data.pointer.child_type;
94659410 return ira->codegen->builtin_types.entry_type;
94669411}
......@@ -9479,7 +9424,7 @@ static TypeTableEntry *ir_analyze_instruction_set_fn_test(IrAnalyze *ira,
94799424 ira->codegen->test_fn_count += 1;
94809425 }
94819426
9482 ir_build_const_from(ira, &set_fn_test_instruction->base, false);
9427 ir_build_const_from(ira, &set_fn_test_instruction->base);
94839428 return ira->codegen->builtin_types.entry_void;
94849429}
94859430
......@@ -9515,7 +9460,7 @@ static TypeTableEntry *ir_analyze_instruction_set_fn_visible(IrAnalyze *ira,
95159460 }
95169461 fn_entry->internal_linkage = !want_export;
95179462
9518 ir_build_const_from(ira, &set_fn_visible_instruction->base, false);
9463 ir_build_const_from(ira, &set_fn_visible_instruction->base);
95199464 return ira->codegen->builtin_types.entry_void;
95209465}
95219466
......@@ -9564,7 +9509,7 @@ static TypeTableEntry *ir_analyze_instruction_set_global_align(IrAnalyze *ira,
95649509 *set_global_align_node = source_node;
95659510 *alignment_ptr = scalar_align;
95669511
9567 ir_build_const_from(ira, &instruction->base, false);
9512 ir_build_const_from(ira, &instruction->base);
95689513 return ira->codegen->builtin_types.entry_void;
95699514}
95709515
......@@ -9603,7 +9548,7 @@ static TypeTableEntry *ir_analyze_instruction_set_global_section(IrAnalyze *ira,
96039548 *set_global_section_node = source_node;
96049549 *section_name_ptr = section_name;
96059550
9606 ir_build_const_from(ira, &instruction->base, false);
9551 ir_build_const_from(ira, &instruction->base);
96079552 return ira->codegen->builtin_types.entry_void;
96089553}
96099554
......@@ -9620,7 +9565,7 @@ static TypeTableEntry *ir_analyze_instruction_set_debug_safety(IrAnalyze *ira,
96209565
96219566 if (ira->new_irb.exec->is_inline) {
96229567 // ignore setDebugSafety when running functions at compile time
9623 ir_build_const_from(ira, &set_debug_safety_instruction->base, false);
9568 ir_build_const_from(ira, &set_debug_safety_instruction->base);
96249569 return ira->codegen->builtin_types.entry_void;
96259570 }
96269571
......@@ -9672,7 +9617,7 @@ static TypeTableEntry *ir_analyze_instruction_set_debug_safety(IrAnalyze *ira,
96729617 *safety_set_node_ptr = source_node;
96739618 *safety_off_ptr = !want_debug_safety;
96749619
9675 ir_build_const_from(ira, &set_debug_safety_instruction->base, false);
9620 ir_build_const_from(ira, &set_debug_safety_instruction->base);
96769621 return ira->codegen->builtin_types.entry_void;
96779622}
96789623
......@@ -9723,8 +9668,7 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira,
97239668 {
97249669 type_ensure_zero_bits_known(ira->codegen, resolved_child_type);
97259670 TypeTableEntry *result_type = get_slice_type(ira->codegen, resolved_child_type, is_const);
9726 ConstExprValue *out_val = ir_build_const_from(ira, &slice_type_instruction->base,
9727 child_type->value.depends_on_compile_var);
9671 ConstExprValue *out_val = ir_build_const_from(ira, &slice_type_instruction->base);
97289672 out_val->data.x_type = result_type;
97299673 return ira->codegen->builtin_types.entry_type;
97309674 }
......@@ -9814,10 +9758,7 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira,
98149758 case TypeTableEntryIdEnumTag:
98159759 {
98169760 TypeTableEntry *result_type = get_array_type(ira->codegen, child_type, size);
9817 bool depends_on_compile_var = child_type_value->value.depends_on_compile_var ||
9818 size_value->value.depends_on_compile_var;
9819 ConstExprValue *out_val = ir_build_const_from(ira, &array_type_instruction->base,
9820 depends_on_compile_var);
9761 ConstExprValue *out_val = ir_build_const_from(ira, &array_type_instruction->base);
98219762 out_val->data.x_type = result_type;
98229763 return ira->codegen->builtin_types.entry_type;
98239764 }
......@@ -9833,7 +9774,7 @@ static TypeTableEntry *ir_analyze_instruction_compile_var(IrAnalyze *ira,
98339774 if (!var_name)
98349775 return ira->codegen->builtin_types.entry_invalid;
98359776
9836 ConstExprValue *out_val = ir_build_const_from(ira, &compile_var_instruction->base, true);
9777 ConstExprValue *out_val = ir_build_const_from(ira, &compile_var_instruction->base);
98379778 if (buf_eql_str(var_name, "is_big_endian")) {
98389779 out_val->data.x_bool = ira->codegen->is_big_endian;
98399780 return ira->codegen->builtin_types.entry_bool;
......@@ -9905,8 +9846,7 @@ static TypeTableEntry *ir_analyze_instruction_size_of(IrAnalyze *ira,
99059846 case TypeTableEntryIdEnumTag:
99069847 {
99079848 uint64_t size_in_bytes = type_size(ira->codegen, type_entry);
9908 ConstExprValue *out_val = ir_build_const_from(ira, &size_of_instruction->base,
9909 type_entry->size_depends_on_compile_var);
9849 ConstExprValue *out_val = ir_build_const_from(ira, &size_of_instruction->base);
99109850 bignum_init_unsigned(&out_val->data.x_bignum, size_in_bytes);
99119851 return ira->codegen->builtin_types.entry_num_lit_int;
99129852 }
......@@ -9927,8 +9867,7 @@ static TypeTableEntry *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrIn
99279867 if (!maybe_val)
99289868 return ira->codegen->builtin_types.entry_invalid;
99299869
9930 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base,
9931 maybe_val->depends_on_compile_var);
9870 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
99329871 out_val->data.x_bool = (maybe_val->data.x_maybe != nullptr);
99339872 return ira->codegen->builtin_types.entry_bool;
99349873 }
......@@ -9936,11 +9875,11 @@ static TypeTableEntry *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrIn
99369875 ir_build_test_nonnull_from(&ira->new_irb, &instruction->base, value);
99379876 return ira->codegen->builtin_types.entry_bool;
99389877 } else if (type_entry->id == TypeTableEntryIdNullLit) {
9939 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, false);
9878 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
99409879 out_val->data.x_bool = false;
99419880 return ira->codegen->builtin_types.entry_bool;
99429881 } else {
9943 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, false);
9882 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
99449883 out_val->data.x_bool = true;
99459884 return ira->codegen->builtin_types.entry_bool;
99469885 }
......@@ -9981,9 +9920,7 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira,
99819920 ir_add_error(ira, &unwrap_maybe_instruction->base, buf_sprintf("unable to unwrap null"));
99829921 return ira->codegen->builtin_types.entry_invalid;
99839922 }
9984 bool depends_on_compile_var = maybe_val->depends_on_compile_var;
9985 ConstExprValue *out_val = ir_build_const_from(ira, &unwrap_maybe_instruction->base,
9986 depends_on_compile_var);
9923 ConstExprValue *out_val = ir_build_const_from(ira, &unwrap_maybe_instruction->base);
99879924 out_val->data.x_ptr.base_ptr = maybe_val->data.x_maybe;
99889925 out_val->data.x_ptr.index = SIZE_MAX;
99899926 return result_type;
......@@ -10003,9 +9940,7 @@ static TypeTableEntry *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionC
100039940 if (value->value.special != ConstValSpecialRuntime) {
100049941 uint32_t result = bignum_ctz(&value->value.data.x_bignum,
100059942 value->value.type->data.integral.bit_count);
10006 bool depends_on_compile_var = value->value.depends_on_compile_var;
10007 ConstExprValue *out_val = ir_build_const_from(ira, &ctz_instruction->base,
10008 depends_on_compile_var);
9943 ConstExprValue *out_val = ir_build_const_from(ira, &ctz_instruction->base);
100099944 bignum_init_unsigned(&out_val->data.x_bignum, result);
100109945 return value->value.type;
100119946 }
......@@ -10027,9 +9962,7 @@ static TypeTableEntry *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionC
100279962 if (value->value.special != ConstValSpecialRuntime) {
100289963 uint32_t result = bignum_clz(&value->value.data.x_bignum,
100299964 value->value.type->data.integral.bit_count);
10030 bool depends_on_compile_var = value->value.depends_on_compile_var;
10031 ConstExprValue *out_val = ir_build_const_from(ira, &clz_instruction->base,
10032 depends_on_compile_var);
9965 ConstExprValue *out_val = ir_build_const_from(ira, &clz_instruction->base);
100339966 bignum_init_unsigned(&out_val->data.x_bignum, result);
100349967 return value->value.type;
100359968 }
......@@ -10062,7 +9995,6 @@ static IrInstruction *ir_analyze_enum_tag(IrAnalyze *ira, IrInstruction *source_
100629995 source_instr->scope, source_instr->source_node);
100639996 const_instruction->base.value.type = value->value.type->data.enumeration.tag_type;
100649997 const_instruction->base.value.special = ConstValSpecialStatic;
10065 const_instruction->base.value.depends_on_compile_var = val->depends_on_compile_var;
100669998 bignum_init_unsigned(&const_instruction->base.value.data.x_bignum, val->data.x_enum.tag);
100679999 return &const_instruction->base;
1006810000 }
......@@ -10178,7 +10110,6 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,
1017810110
1017910111 assert(target_value_ptr->value.type->id == TypeTableEntryIdPointer);
1018010112 TypeTableEntry *target_type = target_value_ptr->value.type->data.pointer.child_type;
10181 bool depends_on_compile_var = target_value_ptr->value.depends_on_compile_var;
1018210113 ConstExprValue *pointee_val = nullptr;
1018310114 if (target_value_ptr->value.special != ConstValSpecialRuntime) {
1018410115 pointee_val = const_ptr_pointee(&target_value_ptr->value);
......@@ -10205,8 +10136,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,
1020510136 case TypeTableEntryIdNamespace:
1020610137 case TypeTableEntryIdPureError:
1020710138 if (pointee_val) {
10208 ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base,
10209 depends_on_compile_var);
10139 ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base);
1021010140 *out_val = *pointee_val;
1021110141 out_val->type = target_type;
1021210142 return target_type;
......@@ -10218,8 +10148,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,
1021810148 {
1021910149 TypeTableEntry *tag_type = target_type->data.enumeration.tag_type;
1022010150 if (pointee_val) {
10221 ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base,
10222 depends_on_compile_var);
10151 ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base);
1022310152 bignum_init_unsigned(&out_val->data.x_bignum, pointee_val->data.x_enum.tag);
1022410153 return tag_type;
1022510154 }
......@@ -10285,8 +10214,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstr
1028510214
1028610215 ConstExprValue *pointee_val = const_ptr_pointee(target_val_ptr);
1028710216 if (pointee_val->type->id == TypeTableEntryIdEnum) {
10288 bool depends_on_compile_var = target_value_ptr->value.depends_on_compile_var;
10289 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var);
10217 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1029010218 out_val->data.x_ptr.base_ptr = pointee_val->data.x_enum.payload;
1029110219 out_val->data.x_ptr.index = SIZE_MAX;
1029210220 return get_pointer_to_type(ira->codegen, pointee_val->type, target_value_ptr->value.type->data.pointer.is_const);
......@@ -10323,9 +10251,8 @@ static TypeTableEntry *ir_analyze_instruction_generated_code(IrAnalyze *ira, IrI
1032310251 if (!val)
1032410252 return ira->codegen->builtin_types.entry_invalid;
1032510253
10326 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, false);
10254 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1032710255 *out_val = *val;
10328 out_val->depends_on_compile_var = true;
1032910256 return value->value.type;
1033010257 }
1033110258
......@@ -10338,7 +10265,6 @@ static TypeTableEntry *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructi
1033810265 Buf *import_target_str = ir_resolve_str(ira, name_value);
1033910266 if (!import_target_str)
1034010267 return ira->codegen->builtin_types.entry_invalid;
10341 bool depends_on_compile_var = name_value->value.depends_on_compile_var;
1034210268
1034310269 AstNode *source_node = import_instruction->base.source_node;
1034410270 ImportTableEntry *import = source_node->owner;
......@@ -10380,7 +10306,7 @@ static TypeTableEntry *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructi
1038010306
1038110307 auto import_entry = ira->codegen->import_table.maybe_get(abs_full_path);
1038210308 if (import_entry) {
10383 ConstExprValue *out_val = ir_build_const_from(ira, &import_instruction->base, depends_on_compile_var);
10309 ConstExprValue *out_val = ir_build_const_from(ira, &import_instruction->base);
1038410310 out_val->data.x_import = import_entry->value;
1038510311 return ira->codegen->builtin_types.entry_namespace;
1038610312 }
......@@ -10401,7 +10327,7 @@ static TypeTableEntry *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructi
1040110327
1040210328 scan_decls(ira->codegen, target_import->decls_scope, target_import->root);
1040310329
10404 ConstExprValue *out_val = ir_build_const_from(ira, &import_instruction->base, depends_on_compile_var);
10330 ConstExprValue *out_val = ir_build_const_from(ira, &import_instruction->base);
1040510331 out_val->data.x_import = target_import;
1040610332 return ira->codegen->builtin_types.entry_namespace;
1040710333
......@@ -10415,16 +10341,14 @@ static TypeTableEntry *ir_analyze_instruction_array_len(IrAnalyze *ira,
1041510341 if (canon_type->id == TypeTableEntryIdInvalid) {
1041610342 return ira->codegen->builtin_types.entry_invalid;
1041710343 } else if (canon_type->id == TypeTableEntryIdArray) {
10418 bool depends_on_compile_var = array_value->value.depends_on_compile_var;
1041910344 return ir_analyze_const_usize(ira, &array_len_instruction->base,
10420 canon_type->data.array.len, depends_on_compile_var);
10345 canon_type->data.array.len);
1042110346 } else if (is_slice(canon_type)) {
1042210347 if (array_value->value.special != ConstValSpecialRuntime) {
1042310348 ConstExprValue *len_val = &array_value->value.data.x_struct.fields[slice_len_index];
1042410349 if (len_val->special != ConstValSpecialRuntime) {
10425 bool depends_on_compile_var = len_val->depends_on_compile_var;
1042610350 return ir_analyze_const_usize(ira, &array_len_instruction->base,
10427 len_val->data.x_bignum.data.x_uint, depends_on_compile_var);
10351 len_val->data.x_bignum.data.x_uint);
1042810352 }
1042910353 }
1043010354 TypeStructField *field = &canon_type->data.structure.fields[slice_len_index];
......@@ -10447,8 +10371,7 @@ static TypeTableEntry *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstructionR
1044710371}
1044810372
1044910373static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruction *instruction,
10450 TypeTableEntry *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields,
10451 bool depends_on_compile_var)
10374 TypeTableEntry *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields)
1045210375{
1045310376 if (container_type->id != TypeTableEntryIdStruct || is_slice(container_type)) {
1045410377 ir_add_error(ira, instruction,
......@@ -10473,7 +10396,6 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru
1047310396 ConstExprValue const_val = {};
1047410397 const_val.special = ConstValSpecialStatic;
1047510398 const_val.type = container_type;
10476 const_val.depends_on_compile_var = depends_on_compile_var;
1047710399 const_val.data.x_struct.fields = allocate<ConstExprValue>(actual_field_count);
1047810400 for (size_t i = 0; i < instr_field_count; i += 1) {
1047910401 IrInstructionContainerInitFieldsField *field = &fields[i];
......@@ -10516,7 +10438,6 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru
1051610438 return ira->codegen->builtin_types.entry_invalid;
1051710439
1051810440 const_val.data.x_struct.fields[field_index] = *field_val;
10519 const_val.depends_on_compile_var = const_val.depends_on_compile_var || field_val->depends_on_compile_var;
1052010441 } else {
1052110442 first_non_const_instruction = casted_field_value;
1052210443 const_val.special = ConstValSpecialRuntime;
......@@ -10536,7 +10457,7 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru
1053610457 return ira->codegen->builtin_types.entry_invalid;
1053710458
1053810459 if (const_val.special == ConstValSpecialStatic) {
10539 ConstExprValue *out_val = ir_build_const_from(ira, instruction, const_val.depends_on_compile_var);
10460 ConstExprValue *out_val = ir_build_const_from(ira, instruction);
1054010461 *out_val = const_val;
1054110462 return container_type;
1054210463 }
......@@ -10567,11 +10488,9 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira
1056710488 if (container_type->id == TypeTableEntryIdInvalid)
1056810489 return ira->codegen->builtin_types.entry_invalid;
1056910490
10570 bool depends_on_compile_var = container_type_value->value.depends_on_compile_var;
10571
1057210491 if (container_type->id == TypeTableEntryIdStruct && !is_slice(container_type) && elem_count == 0) {
1057310492 return ir_analyze_container_init_fields(ira, &instruction->base, container_type,
10574 0, nullptr, depends_on_compile_var);
10493 0, nullptr);
1057510494 } else if (is_slice(container_type)) {
1057610495 TypeTableEntry *pointer_type = container_type->data.structure.fields[slice_ptr_index].type_entry;
1057710496 assert(pointer_type->id == TypeTableEntryIdPointer);
......@@ -10581,7 +10500,6 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira
1058110500 ConstExprValue const_val = {};
1058210501 const_val.special = ConstValSpecialStatic;
1058310502 const_val.type = fixed_size_array_type;
10584 const_val.depends_on_compile_var = depends_on_compile_var;
1058510503 const_val.data.x_array.elements = allocate<ConstExprValue>(elem_count);
1058610504 const_val.data.x_array.size = elem_count;
1058710505
......@@ -10609,7 +10527,6 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira
1060910527 return ira->codegen->builtin_types.entry_invalid;
1061010528
1061110529 const_val.data.x_array.elements[i] = *elem_val;
10612 const_val.depends_on_compile_var = const_val.depends_on_compile_var || elem_val->depends_on_compile_var;
1061310530 } else {
1061410531 first_non_const_instruction = casted_arg;
1061510532 const_val.special = ConstValSpecialRuntime;
......@@ -10618,7 +10535,7 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira
1061810535 }
1061910536
1062010537 if (const_val.special == ConstValSpecialStatic) {
10621 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, const_val.depends_on_compile_var);
10538 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1062210539 *out_val = const_val;
1062310540 for (size_t i = 0; i < elem_count; i += 1) {
1062410541 ConstExprValue *elem_val = &out_val->data.x_array.elements[i];
......@@ -10681,8 +10598,7 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira
1068110598 ConstExprValue *init_val = ir_resolve_const(ira, casted_init_value, UndefOk);
1068210599 if (!init_val)
1068310600 return ira->codegen->builtin_types.entry_invalid;
10684 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base,
10685 casted_init_value->value.depends_on_compile_var);
10601 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1068610602 out_val->data.x_enum.tag = tag_uint;
1068710603 out_val->data.x_enum.payload = init_val;
1068810604 return enum_type;
......@@ -10705,37 +10621,34 @@ static TypeTableEntry *ir_analyze_instruction_container_init_fields(IrAnalyze *i
1070510621 if (type_is_invalid(container_type))
1070610622 return ira->codegen->builtin_types.entry_invalid;
1070710623
10708 bool depends_on_compile_var = container_type_value->value.depends_on_compile_var;
10709
1071010624 return ir_analyze_container_init_fields(ira, &instruction->base, container_type,
10711 instruction->field_count, instruction->fields, depends_on_compile_var);
10625 instruction->field_count, instruction->fields);
1071210626}
1071310627
1071410628static TypeTableEntry *ir_analyze_min_max(IrAnalyze *ira, IrInstruction *source_instruction,
1071510629 IrInstruction *target_type_value, bool is_max)
1071610630{
1071710631 TypeTableEntry *target_type = ir_resolve_type(ira, target_type_value);
10718 bool depends_on_compile_var = target_type_value->value.depends_on_compile_var;
1071910632 TypeTableEntry *canon_type = get_underlying_type(target_type);
1072010633 switch (canon_type->id) {
1072110634 case TypeTableEntryIdInvalid:
1072210635 return ira->codegen->builtin_types.entry_invalid;
1072310636 case TypeTableEntryIdInt:
1072410637 {
10725 ConstExprValue *out_val = ir_build_const_from(ira, source_instruction, depends_on_compile_var);
10638 ConstExprValue *out_val = ir_build_const_from(ira, source_instruction);
1072610639 eval_min_max_value(ira->codegen, canon_type, out_val, is_max);
1072710640 return ira->codegen->builtin_types.entry_num_lit_int;
1072810641 }
1072910642 case TypeTableEntryIdFloat:
1073010643 {
10731 ConstExprValue *out_val = ir_build_const_from(ira, source_instruction, depends_on_compile_var);
10644 ConstExprValue *out_val = ir_build_const_from(ira, source_instruction);
1073210645 eval_min_max_value(ira->codegen, canon_type, out_val, is_max);
1073310646 return ira->codegen->builtin_types.entry_num_lit_float;
1073410647 }
1073510648 case TypeTableEntryIdBool:
1073610649 case TypeTableEntryIdVoid:
1073710650 {
10738 ConstExprValue *out_val = ir_build_const_from(ira, source_instruction, depends_on_compile_var);
10651 ConstExprValue *out_val = ir_build_const_from(ira, source_instruction);
1073910652 eval_min_max_value(ira->codegen, canon_type, out_val, is_max);
1074010653 return target_type;
1074110654 }
......@@ -10815,7 +10728,7 @@ static TypeTableEntry *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInst
1081510728
1081610729 ir_add_error(ira, &instruction->base, buf_sprintf("found compile log statement"));
1081710730
10818 ir_build_const_from(ira, &instruction->base, false);
10731 ir_build_const_from(ira, &instruction->base);
1081910732 return ira->codegen->builtin_types.entry_void;
1082010733}
1082110734
......@@ -10835,8 +10748,7 @@ static TypeTableEntry *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruc
1083510748 ConstExprValue *array_val = create_const_str_lit(ira->codegen, &err->name);
1083610749 err->cached_error_name_val = create_const_slice(ira->codegen, array_val, 0, buf_len(&err->name), true);
1083710750 }
10838 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base,
10839 casted_value->value.depends_on_compile_var);
10751 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1084010752 *out_val = *err->cached_error_name_val;
1084110753 return str_type;
1084210754 }
......@@ -10855,8 +10767,7 @@ static TypeTableEntry *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstru
1085510767 if (!type_entry->cached_const_name_val) {
1085610768 type_entry->cached_const_name_val = create_const_str_lit(ira->codegen, &type_entry->name);
1085710769 }
10858 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base,
10859 type_value->value.depends_on_compile_var);
10770 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1086010771 *out_val = *type_entry->cached_const_name_val;
1086110772 return out_val->type;
1086210773}
......@@ -10905,10 +10816,7 @@ static TypeTableEntry *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruc
1090510816 ast_render_decls(stderr, 4, child_import);
1090610817 }
1090710818
10908 // TODO to get fewer false negatives on this, we would need to track this value in
10909 // the ir executable
10910 bool depends_on_compile_var = true;
10911 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var);
10819 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1091210820 out_val->data.x_import = child_import;
1091310821 return ira->codegen->builtin_types.entry_namespace;
1091410822}
......@@ -10928,7 +10836,7 @@ static TypeTableEntry *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstru
1092810836
1092910837 buf_appendf(c_import_buf, "#include <%s>\n", buf_ptr(include_name));
1093010838
10931 ir_build_const_from(ira, &instruction->base, false);
10839 ir_build_const_from(ira, &instruction->base);
1093210840 return ira->codegen->builtin_types.entry_void;
1093310841}
1093410842
......@@ -10955,7 +10863,7 @@ static TypeTableEntry *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstruc
1095510863
1095610864 buf_appendf(c_import_buf, "#define %s %s\n", buf_ptr(define_name), buf_ptr(define_value));
1095710865
10958 ir_build_const_from(ira, &instruction->base, false);
10866 ir_build_const_from(ira, &instruction->base);
1095910867 return ira->codegen->builtin_types.entry_void;
1096010868}
1096110869
......@@ -10974,7 +10882,7 @@ static TypeTableEntry *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstruct
1097410882
1097510883 buf_appendf(c_import_buf, "#undef %s\n", buf_ptr(undef_name));
1097610884
10977 ir_build_const_from(ira, &instruction->base, false);
10885 ir_build_const_from(ira, &instruction->base);
1097810886 return ira->codegen->builtin_types.entry_void;
1097910887}
1098010888
......@@ -11011,8 +10919,7 @@ static TypeTableEntry *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstr
1101110919 // TODO add dependency on the file we embedded so that we know if it changes
1101210920 // we'll have to invalidate the cache
1101310921
11014 bool depends_on_compile_var = true;
11015 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var);
10922 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1101610923 init_const_str_lit(ira->codegen, out_val, &file_contents);
1101710924
1101810925 return get_array_type(ira->codegen, ira->codegen->builtin_types.entry_u8, buf_len(&file_contents));
......@@ -11161,9 +11068,7 @@ static TypeTableEntry *ir_analyze_instruction_div_exact(IrAnalyze *ira, IrInstru
1116111068 return ira->codegen->builtin_types.entry_invalid;
1116211069 }
1116311070
11164 bool depends_on_compile_var = casted_op1->value.depends_on_compile_var ||
11165 casted_op2->value.depends_on_compile_var;
11166 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var);
11071 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1116711072 bignum_div(&out_val->data.x_bignum, &op1_val->data.x_bignum, &op2_val->data.x_bignum);
1116811073 return result_type;
1116911074 }
......@@ -11215,8 +11120,7 @@ static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruc
1121511120 }
1121611121
1121711122 if (target->value.special == ConstValSpecialStatic) {
11218 bool depends_on_compile_var = dest_type_value->value.depends_on_compile_var || target->value.depends_on_compile_var;
11219 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var);
11123 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1122011124 bignum_init_bignum(&out_val->data.x_bignum, &target->value.data.x_bignum);
1122111125 bignum_truncate(&out_val->data.x_bignum, canon_dest_type->data.integral.bit_count);
1122211126 return dest_type;
......@@ -11237,10 +11141,7 @@ static TypeTableEntry *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstruc
1123711141 if (!ir_resolve_usize(ira, bit_count_value, &bit_count))
1123811142 return ira->codegen->builtin_types.entry_invalid;
1123911143
11240 bool depends_on_compile_var = is_signed_value->value.depends_on_compile_var ||
11241 bit_count_value->value.depends_on_compile_var;
11242
11243 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var);
11144 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1124411145 out_val->data.x_type = get_int_type(ira->codegen, is_signed, bit_count);
1124511146 return ira->codegen->builtin_types.entry_type;
1124611147}
......@@ -11257,8 +11158,7 @@ static TypeTableEntry *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruc
1125711158 return ira->codegen->builtin_types.entry_invalid;
1125811159
1125911160 if (casted_value->value.special != ConstValSpecialRuntime) {
11260 bool depends_on_compile_var = casted_value->value.depends_on_compile_var;
11261 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var);
11161 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1126211162 out_val->data.x_bool = !casted_value->value.data.x_bool;
1126311163 return bool_type;
1126411164 }
......@@ -11357,7 +11257,7 @@ static TypeTableEntry *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructi
1135711257 dest_elements[i] = *byte_val;
1135811258 }
1135911259
11360 ir_build_const_from(ira, &instruction->base, false);
11260 ir_build_const_from(ira, &instruction->base);
1136111261 return ira->codegen->builtin_types.entry_void;
1136211262 }
1136311263
......@@ -11454,7 +11354,7 @@ static TypeTableEntry *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructi
1145411354 dest_elements[dest_start + i] = src_elements[src_start + i];
1145511355 }
1145611356
11457 ir_build_const_from(ira, &instruction->base, false);
11357 ir_build_const_from(ira, &instruction->base);
1145811358 return ira->codegen->builtin_types.entry_void;
1145911359 }
1146011360
......@@ -11515,11 +11415,6 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio
1151511415 casted_start->value.special == ConstValSpecialStatic &&
1151611416 (!end || end->value.special == ConstValSpecialStatic))
1151711417 {
11518 bool depends_on_compile_var =
11519 ptr->value.depends_on_compile_var ||
11520 casted_start->value.depends_on_compile_var ||
11521 (end ? end->value.depends_on_compile_var : false);
11522
1152311418 ConstExprValue *base_ptr;
1152411419 size_t abs_offset;
1152511420 size_t rel_end;
......@@ -11571,7 +11466,7 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio
1157111466 return ira->codegen->builtin_types.entry_invalid;
1157211467 }
1157311468
11574 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var);
11469 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1157511470 out_val->data.x_struct.fields = allocate<ConstExprValue>(2);
1157611471
1157711472 ConstExprValue *ptr_val = &out_val->data.x_struct.fields[slice_ptr_index];
......@@ -11612,8 +11507,7 @@ static TypeTableEntry *ir_analyze_instruction_member_count(IrAnalyze *ira, IrIns
1161211507 return ira->codegen->builtin_types.entry_invalid;
1161311508 }
1161411509
11615 bool depends_on_compile_var = container->value.depends_on_compile_var;
11616 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var);
11510 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1161711511 bignum_init_unsigned(&out_val->data.x_bignum, result);
1161811512 return ira->codegen->builtin_types.entry_num_lit_int;
1161911513}
......@@ -11653,8 +11547,7 @@ static TypeTableEntry *ir_analyze_instruction_alignof(IrAnalyze *ira, IrInstruct
1165311547 return ira->codegen->builtin_types.entry_invalid;
1165411548 } else {
1165511549 uint64_t align_in_bytes = LLVMABISizeOfType(ira->codegen->target_data_ref, type_entry->type_ref);
11656 bool depends_on_compile_var = type_value->value.depends_on_compile_var;
11657 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var);
11550 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1165811551 bignum_init_unsigned(&out_val->data.x_bignum, align_in_bytes);
1165911552 return ira->codegen->builtin_types.entry_num_lit_int;
1166011553 }
......@@ -11705,10 +11598,7 @@ static TypeTableEntry *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInst
1170511598 casted_op2->value.special == ConstValSpecialStatic &&
1170611599 casted_result_ptr->value.special == ConstValSpecialStatic)
1170711600 {
11708 bool depends_on_compile_var = type_value->value.depends_on_compile_var ||
11709 casted_op1->value.depends_on_compile_var || casted_op2->value.depends_on_compile_var ||
11710 casted_result_ptr->value.depends_on_compile_var;
11711 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var);
11601 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1171211602 BigNum *op1_bignum = &casted_op1->value.data.x_bignum;
1171311603 BigNum *op2_bignum = &casted_op2->value.data.x_bignum;
1171411604 ConstExprValue *pointee_val = const_ptr_pointee(&casted_result_ptr->value);
......@@ -11759,8 +11649,7 @@ static TypeTableEntry *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruc
1175911649 return ira->codegen->builtin_types.entry_invalid;
1176011650
1176111651 if (err_union_val->special != ConstValSpecialRuntime) {
11762 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base,
11763 err_union_val->depends_on_compile_var);
11652 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1176411653 out_val->data.x_bool = (err_union_val->data.x_err_union.err != nullptr);
1176511654 return ira->codegen->builtin_types.entry_bool;
1176611655 }
......@@ -11769,11 +11658,11 @@ static TypeTableEntry *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruc
1176911658 ir_build_test_err_from(&ira->new_irb, &instruction->base, value);
1177011659 return ira->codegen->builtin_types.entry_bool;
1177111660 } else if (canon_type->id == TypeTableEntryIdPureError) {
11772 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, false);
11661 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1177311662 out_val->data.x_bool = true;
1177411663 return ira->codegen->builtin_types.entry_bool;
1177511664 } else {
11776 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, false);
11665 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1177711666 out_val->data.x_bool = false;
1177811667 return ira->codegen->builtin_types.entry_bool;
1177911668 }
......@@ -11805,8 +11694,7 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira,
1180511694 ErrorTableEntry *err = err_union_val->data.x_err_union.err;
1180611695 assert(err);
1180711696
11808 bool depends_on_compile_var = ptr_val->depends_on_compile_var || err_union_val->depends_on_compile_var;
11809 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var);
11697 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1181011698 out_val->data.x_pure_err = err;
1181111699 return ira->codegen->builtin_types.entry_pure_error;
1181211700 }
......@@ -11855,8 +11743,7 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira,
1185511743 return ira->codegen->builtin_types.entry_invalid;
1185611744 }
1185711745
11858 bool depends_on_compile_var = ptr_val->depends_on_compile_var || err_union_val->depends_on_compile_var;
11859 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var);
11746 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1186011747 out_val->data.x_ptr.base_ptr = err_union_val->data.x_err_union.payload;
1186111748 out_val->data.x_ptr.index = SIZE_MAX;
1186211749 return result_type;
......@@ -11881,8 +11768,6 @@ static TypeTableEntry *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruc
1188111768 FnTypeId fn_type_id = {0};
1188211769 init_fn_type_id(&fn_type_id, proto_node, proto_node->data.fn_proto.params.length);
1188311770
11884 bool depends_on_compile_var = false;
11885
1188611771 for (; fn_type_id.next_param_index < fn_type_id.param_count; fn_type_id.next_param_index += 1) {
1188711772 AstNode *param_node = proto_node->data.fn_proto.params.at(fn_type_id.next_param_index);
1188811773 assert(param_node->type == NodeTypeParamDecl);
......@@ -11894,17 +11779,14 @@ static TypeTableEntry *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruc
1189411779 param_info->type = ir_resolve_type(ira, param_type_value);
1189511780 if (param_info->type->id == TypeTableEntryIdInvalid)
1189611781 return ira->codegen->builtin_types.entry_invalid;
11897
11898 depends_on_compile_var = depends_on_compile_var || param_type_value->value.depends_on_compile_var;
1189911782 }
1190011783
1190111784 IrInstruction *return_type_value = instruction->return_type->other;
1190211785 fn_type_id.return_type = ir_resolve_type(ira, return_type_value);
1190311786 if (fn_type_id.return_type->id == TypeTableEntryIdInvalid)
1190411787 return ira->codegen->builtin_types.entry_invalid;
11905 depends_on_compile_var = depends_on_compile_var || return_type_value->value.depends_on_compile_var;
1190611788
11907 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var);
11789 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1190811790 out_val->data.x_type = get_fn_type(ira->codegen, &fn_type_id);
1190911791 return ira->codegen->builtin_types.entry_type;
1191011792}
......@@ -11914,7 +11796,7 @@ static TypeTableEntry *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrIn
1191411796 if (value->value.type->id == TypeTableEntryIdInvalid)
1191511797 return ira->codegen->builtin_types.entry_invalid;
1191611798
11917 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, false);
11799 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1191811800 out_val->data.x_bool = instr_is_comptime(value);
1191911801 return ira->codegen->builtin_types.entry_bool;
1192011802}
......@@ -11978,7 +11860,7 @@ static TypeTableEntry *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira
1197811860 } else {
1197911861 // TODO check prongs of types other than enumtag
1198011862 }
11981 ir_build_const_from(ira, &instruction->base, false);
11863 ir_build_const_from(ira, &instruction->base);
1198211864 return ira->codegen->builtin_types.entry_void;
1198311865}
1198411866
......@@ -11988,7 +11870,7 @@ static TypeTableEntry *ir_analyze_instruction_test_type(IrAnalyze *ira, IrInstru
1198811870 if (type_entry->id == TypeTableEntryIdInvalid)
1198911871 return ira->codegen->builtin_types.entry_invalid;
1199011872
11991 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, type_value->value.depends_on_compile_var);
11873 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1199211874 out_val->data.x_bool = (type_entry->id == instruction->type_id);
1199311875 return ira->codegen->builtin_types.entry_bool;
1199411876}
......@@ -12012,10 +11894,7 @@ static TypeTableEntry *ir_analyze_instruction_can_implicit_cast(IrAnalyze *ira,
1201211894 zig_panic("TODO refactor implicit cast tester to return bool without reporting errors");
1201311895 }
1201411896
12015 // TODO in order to known depends_on_compile_var we have to known if the type of the target
12016 // depends on a compile var
12017 bool depends_on_compile_var = true;
12018 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var);
11897 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1201911898 out_val->data.x_bool = (result == ImplicitCastMatchResultYes);
1202011899 return ira->codegen->builtin_types.entry_bool;
1202111900}