| author | |
| committer | |
| log | 0ff9a4d21c1b65c574659be295446f2dd7591723 |
| tree | f9e68028c1ac06222194b00015fd741f7dae4f27 |
| parent | 0e5fa87ac9695378683e770fbe0d577521860d35 |
3 files changed, 29 insertions(+), 6 deletions(-)
src/stage1/analyze.cpp+1-4| ... | @@ -5674,7 +5674,7 @@ static uint32_t hash_combine_const_val(uint32_t hash_val, ZigValue *const_val) { | ... | @@ -5674,7 +5674,7 @@ static uint32_t hash_combine_const_val(uint32_t hash_val, ZigValue *const_val) { |
| 5674 | // return hash_combine(hash_val, &const_val); | 5674 | // return hash_combine(hash_val, &const_val); |
| 5675 | // } | 5675 | // } |
| 5676 | if (const_val->special != ConstValSpecialStatic) { | 5676 | if (const_val->special != ConstValSpecialStatic) { |
| 5677 | printf("\nInvalid special: %d\n", const_val->special); | 5677 | fprintf(stderr, "\nInvalid special: %d\n", const_val->special); |
| 5678 | } | 5678 | } |
| 5679 | assert(const_val->special == ConstValSpecialStatic); | 5679 | assert(const_val->special == ConstValSpecialStatic); |
| 5680 | hash_val = hash_combine(hash_val, &const_val->type->id); | 5680 | hash_val = hash_combine(hash_val, &const_val->type->id); |
| ... | @@ -5776,9 +5776,6 @@ static uint32_t hash_combine_const_val(uint32_t hash_val, ZigValue *const_val) { | ... | @@ -5776,9 +5776,6 @@ static uint32_t hash_combine_const_val(uint32_t hash_val, ZigValue *const_val) { |
| 5776 | } | 5776 | } |
| 5777 | zig_unreachable(); | 5777 | zig_unreachable(); |
| 5778 | } | 5778 | } |
| 5779 | static uint32_t hash_const_val(ZigValue *const_val) { | ||
| 5780 | return hash_combine_const_val(HASH_INIT, const_val); | ||
| 5781 | } | ||
| 5782 | 5779 | ||
| 5783 | uint32_t generic_fn_type_id_hash(GenericFnTypeId *id) { | 5780 | uint32_t generic_fn_type_id_hash(GenericFnTypeId *id) { |
| 5784 | uint32_t result = HASH_INIT; | 5781 | uint32_t result = HASH_INIT; |
src/stage1/ir.cpp+24-1| ... | @@ -12754,6 +12754,29 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour | ... | @@ -12754,6 +12754,29 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 12754 | bool cacheable = fn_eval_cacheable(exec_scope, return_type); | 12754 | bool cacheable = fn_eval_cacheable(exec_scope, return_type); |
| 12755 | ZigValue *result = nullptr; | 12755 | ZigValue *result = nullptr; |
| 12756 | if (cacheable) { | 12756 | if (cacheable) { |
| 12757 | // We are about to put ZigValues into a hash map. The hash of a lazy value and a | ||
| 12758 | // fully resolved value must equal, and so we must resolve the lazy values here. | ||
| 12759 | // The hash function asserts that none of the values are lazy. | ||
| 12760 | { | ||
| 12761 | Scope *scope = exec_scope; | ||
| 12762 | while (scope) { | ||
| 12763 | if (scope->id == ScopeIdVarDecl) { | ||
| 12764 | ScopeVarDecl *var_scope = (ScopeVarDecl *)scope; | ||
| 12765 | if ((err = ir_resolve_lazy_recurse(ira, | ||
| 12766 | var_scope->var->decl_node, | ||
| 12767 | var_scope->var->const_value))) | ||
| 12768 | { | ||
| 12769 | return ira->codegen->invalid_inst_gen; | ||
| 12770 | } | ||
| 12771 | } else if (scope->id == ScopeIdFnDef) { | ||
| 12772 | break; | ||
| 12773 | } else { | ||
| 12774 | zig_unreachable(); | ||
| 12775 | } | ||
| 12776 | scope = scope->parent; | ||
| 12777 | } | ||
| 12778 | } | ||
| 12779 | |||
| 12757 | auto entry = ira->codegen->memoized_fn_eval_table.maybe_get(exec_scope); | 12780 | auto entry = ira->codegen->memoized_fn_eval_table.maybe_get(exec_scope); |
| 12758 | if (entry) | 12781 | if (entry) |
| 12759 | result = entry->value; | 12782 | result = entry->value; |
| ... | @@ -25558,7 +25581,7 @@ static Error ir_resolve_lazy_recurse(IrAnalyze *ira, AstNode *source_node, ZigVa | ... | @@ -25558,7 +25581,7 @@ static Error ir_resolve_lazy_recurse(IrAnalyze *ira, AstNode *source_node, ZigVa |
| 25558 | // This shouldn't be possible, it indicates an ICE. | 25581 | // This shouldn't be possible, it indicates an ICE. |
| 25559 | // NO_COMMIT | 25582 | // NO_COMMIT |
| 25560 | ir_add_error_node(ira, source_node, | 25583 | ir_add_error_node(ira, source_node, |
| 25561 | buf_sprintf("This is a bug in the Zig compiler. Runtime value found in comptime known parameter.")); | 25584 | buf_sprintf("This is a bug in the Zig compiler. Runtime value found in comptime known value.")); |
| 25562 | return ErrorSemanticAnalyzeFail; | 25585 | return ErrorSemanticAnalyzeFail; |
| 25563 | } | 25586 | } |
| 25564 | if (val->special != ConstValSpecialStatic) | 25587 | if (val->special != ConstValSpecialStatic) |
src/stage1/zig0.cpp+4-1| ... | @@ -265,6 +265,7 @@ int main(int argc, char **argv) { | ... | @@ -265,6 +265,7 @@ int main(int argc, char **argv) { |
| 265 | const char *override_lib_dir = nullptr; | 265 | const char *override_lib_dir = nullptr; |
| 266 | const char *mcpu = nullptr; | 266 | const char *mcpu = nullptr; |
| 267 | bool single_threaded = false; | 267 | bool single_threaded = false; |
| 268 | bool is_test_build = false; | ||
| 268 | 269 | ||
| 269 | for (int i = 1; i < argc; i += 1) { | 270 | for (int i = 1; i < argc; i += 1) { |
| 270 | char *arg = argv[i]; | 271 | char *arg = argv[i]; |
| ... | @@ -272,6 +273,8 @@ int main(int argc, char **argv) { | ... | @@ -272,6 +273,8 @@ int main(int argc, char **argv) { |
| 272 | if (arg[0] == '-') { | 273 | if (arg[0] == '-') { |
| 273 | if (strcmp(arg, "--") == 0) { | 274 | if (strcmp(arg, "--") == 0) { |
| 274 | fprintf(stderr, "Unexpected end-of-parameter mark: %s\n", arg); | 275 | fprintf(stderr, "Unexpected end-of-parameter mark: %s\n", arg); |
| 276 | } else if (strcmp(arg, "--test") == 0) { | ||
| 277 | is_test_build = true; | ||
| 275 | } else if (strcmp(arg, "-ODebug") == 0) { | 278 | } else if (strcmp(arg, "-ODebug") == 0) { |
| 276 | optimize_mode = BuildModeDebug; | 279 | optimize_mode = BuildModeDebug; |
| 277 | } else if (strcmp(arg, "-OReleaseFast") == 0) { | 280 | } else if (strcmp(arg, "-OReleaseFast") == 0) { |
| ... | @@ -446,7 +449,7 @@ int main(int argc, char **argv) { | ... | @@ -446,7 +449,7 @@ int main(int argc, char **argv) { |
| 446 | nullptr, 0, | 449 | nullptr, 0, |
| 447 | in_file, strlen(in_file), | 450 | in_file, strlen(in_file), |
| 448 | override_lib_dir, strlen(override_lib_dir), | 451 | override_lib_dir, strlen(override_lib_dir), |
| 449 | &target, false); | 452 | &target, is_test_build); |
| 450 | 453 | ||
| 451 | stage1->main_progress_node = root_progress_node; | 454 | stage1->main_progress_node = root_progress_node; |
| 452 | stage1->root_name_ptr = out_name; | 455 | stage1->root_name_ptr = out_name; |