-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve collecting of referred symbols in memory_utils::get_symbols()
by detecting sources of Load
ed local raw pointers and references
#6065
Labels
compiler: ir
IRgen and sway-ir including optimization passes
compiler
General compiler. Should eventually become more specific as the issue is triaged
team:compiler
Compiler Team
Comments
This was referenced Jun 23, 2024
ironcev
added a commit
that referenced
this issue
Jun 24, 2024
…6175) ## Description This PR closes #5924 and #6152 by: - changing the `get_symbols` to: - properly cover all possible sources of pointers. - properly cover getting pointers over `u64` addresses. - not follow `u64` addresses coming over `Load`s. - adapting all IR optimizations that rely on referred symbols to correctly treat the (unsafe) `Incomplete` capturing of referred symbols. - propagating the information about `Incomplete` referred symbols to the escape analysis, that now is also `Complete` or `Incomplete`. - adapting all IR optimizations that rely on escape analysis to correctly treat the (unsafe) `Incomplete` result of escape analysis. Additionally, the PR marks the functions that were entries before wrapped in `__entry` as so called "original entries". The information about the original entries is now available in the IR. The reason for this change is given in the below chapter on bytcode size changes. This PR also brought to surface an existing bug independent of this PR that is reported in #6174. This bug makes the following two test failing: - `should_pass/language/break_and_continue_block_ret` - `should_pass/language/abort_control_flow_good` These two tests are temporarily disabled until #6174 is fixed. The reason they fail in this PR is that `main` function is not inlined anymore, as explained in the below chapter on bytcode size changes. Closes #5924. Closes #6152. ## Bytecode size changes Properly treating incomplete escape analysis and referred symbols in IR optimizations was expected to increase bytcode sizes, since we now restrict unsafe optimizations in case of `Incomplete` results. A special care is given to check those increases, to make sure that they are all justified. Out of 442 `should_pass` tests, run as `--no-enocoding-v1`, only 41 changed sizes (~10%), and of those only 15 had more then 1% increase in size. All the cases of size increase include code patterns that we now recognize as unsafe. E.g., pointers coming from `asm` blocks or function calls. Some of the tests actually got decreased in size. The reason is not collecting the symbols that were sources of `Load`s before. Having those symbols wrongly marked as escaping before, has restricted certain optimizations. When run with the encoding v1, almost all of the tests show a slight, constant increase in size. The reason is the encoding related code in the `__entry` function that contains unsafe patterns, e.g., getting pointers from `asm`. This increase is negligible for contracts, scripts, and predicates of realistic sizes. It can also very likely be mittigated once #6065 and #6173 are implemented. Since original entries all get inlined in the `__entry` before, those unsafe patterns made the code in the original entries also not being optimized. To overcome this, _we now forbid inlining of original entries_. This restriction might be lifted once the above two improvements are implemented. Also, we expect some of the tests to again decrese in size once #6065 gets implemented. <details> <summary>Click here for the numbers</summary> Test | Before | After | Increase % -- | -- | -- | -- blanket_impl | 40 | 40 | 0 blanket_impl_u16 | 40 | 40 | 0 break_in_strange_positions | 520 | 520 | 0 conditional_compilation/run | 40 | 40 | 0 continue_in_strange_positions | 1072 | 1072 | 0 dca/alias_lib | 80 | 80 | 0 dca/alias_type_ascription | 32 | 32 | 0 dca/alias_type_ascription_generic | 32 | 32 | 0 dca/alias_unused | 32 | 32 | 0 dca/allow_dead_code | 32 | 32 | 0 dca/all_paths_return | 32 | 32 | 0 dca/constant_decl_expr | 40 | 40 | 0 dca/constant_struct | 40 | 40 | 0 dca/constant_while | 32 | 32 | 0 dca/contract/abi_fn_params | 112 | 112 | 0 dca/contract/superabi_contract_calls | 208 | 208 | 0 dca/contract/unused_struct_field | 72 | 72 | 0 dca/contract/unused_struct_field_array | 96 | 96 | 0 dca/contract/unused_struct_field_enum | 96 | 96 | 0 dca/contract/unused_struct_field_tuple | 72 | 72 | 0 dca/func_param | 32 | 32 | 0 dca/generic_fn_trait_constraint | 32 | 32 | 0 dca/impl_self | 32 | 32 | 0 dca/impl_self_alias2 | 32 | 32 | 0 dca/impl_self_alias | 32 | 32 | 0 dca/impl_trait_multiple | 32 | 32 | 0 dca/impl_trait_single | 32 | 32 | 0 dca/impl_unused_fn | 48 | 48 | 0 dca/library/fn_params_free | 24 | 24 | 0 dca/library/fn_params_impl | 24 | 24 | 0 dca/library/fn_params_trait | 24 | 24 | 0 dca/library/unused_priv_free_fn | 24 | 24 | 0 dca/library/unused_pub_free_fn | 24 | 24 | 0 dca/log_intrinsic | 64 | 64 | 0 dca/log_stdlib | 64 | 64 | 0 dca/multiple_enums_same_name | 32 | 32 | 0 dca/multiple_fns_same_name | 32 | 32 | 0 dca/reassignment_lhs | 64 | 64 | 0 dca/revert | 32 | 32 | 0 dca/struct_field_no_warning | 40 | 40 | 0 dca/trait_method | 32 | 32 | 0 dca/trait_method_lib | 24 | 24 | 0 dca/trait_method_neq | 120 | 120 | 0 dca/unused_enum | 32 | 32 | 0 dca/unused_fields | 32 | 32 | 0 dca/unused_free_fn | 32 | 32 | 0 dca/unused_struct | 32 | 32 | 0 dca/unused_trait | 32 | 32 | 0 dca/unused_variable | 32 | 32 | 0 dca/unused_variable_in_free_fn | 32 | 32 | 0 empty_fields_in_storage_struct | 13800 | 13960 | 1.16 evm/evm_basic | 32 | 32 | 0 forc/contract_dependencies/contract_a | 312 | 312 | 0 forc/contract_dependencies/contract_b | 80 | 80 | 0 forc/contract_dependencies/contract_c | 80 | 80 | 0 forc/dependency_package_field | 32 | 32 | 0 forc/dependency_patching | 32 | 32 | 0 forc/workspace_building | 24 | 24 | 0 language/abort_control_flow_good | 40 | 40 | 0 language/aliased_imports | 72 | 72 | 0 language/arg_demotion_inline | 272 | 272 | 0 language/args_on_stack | 1304 | 1304 | 0 language/array_basics | 504 | 504 | 0 language/array_generics | 120 | 120 | 0 language/asm_expr_basic | 144 | 144 | 0 language/asm_without_return | 32 | 32 | 0 language/associated_const_abi | 32 | 32 | 0 language/associated_const_abi_default | 32 | 32 | 0 language/associated_const_abi_multiple | 32 | 32 | 0 language/associated_const_impl | 32 | 32 | 0 language/associated_const_impl_local_same_name | 32 | 32 | 0 language/associated_const_impl_multiple | 32 | 32 | 0 language/associated_const_impl_self | 32 | 32 | 0 language/associated_const_impl_self_order | 32 | 32 | 0 language/associated_const_trait | 32 | 32 | 0 language/associated_const_trait_const | 48 | 48 | 0 language/associated_const_trait_default | 40 | 40 | 0 language/associated_const_trait_impl_method | 32 | 32 | 0 language/associated_const_trait_method | 32 | 32 | 0 language/associated_type_and_associated_const | 32 | 32 | 0 language/associated_type_ascription | 32 | 32 | 0 language/associated_type_container | 1088 | 1088 | 0 language/associated_type_container_in_library | 1088 | 1088 | 0 language/associated_type_fully_qualified | 32 | 32 | 0 language/associated_type_iterator | 1176 | 1176 | 0 language/associated_type_method | 32 | 32 | 0 language/associated_type_parameter | 32 | 32 | 0 language/attributes_warnings | 32 | 32 | 0 language/b256_bad_jumps | 32 | 32 | 0 language/b256_bitwise_ops | 6536 | 6536 | 0 language/b256_ops | 3496 | 3496 | 0 language/basic_func_decl | 48 | 48 | 0 language/basic_predicate | 48 | 48 | 0 language/binary_and_hex_literals | 48 | 48 | 0 language/binop_intrinsics | 40 | 40 | 0 language/bitwise_not | 48 | 48 | 0 language/blanket_trait | 48 | 48 | 0 language/bool_and_or | 64 | 64 | 0 language/break_and_continue | 616 | 616 | 0 language/break_and_continue_block_ret | 40 | 40 | 0 language/builtin_type_method_call | 40 | 40 | 0 language/callpath_local_shadowing | 32 | 32 | 0 language/chained_if_let | 136 | 136 | 0 language/complex_cfg | 384 | 432 | 12.50 language/configurable_consts | 3712 | 3712 | 0 language/const_decl_and_use_in_library | 40 | 40 | 0 language/const_decl_in_library | 64 | 64 | 0 language/const_decl_literal | 40 | 40 | 0 language/const_decl_with_call_path | 240 | 240 | 0 language/const_inits | 1560 | 1560 | 0 language/contract_caller_as_ret | 80 | 80 | 0 language/contract_caller_dynamic_address | 128 | 128 | 0 language/deprecated | 24 | 24 | 0 language/deprecated_attribute | 40 | 40 | 0 language/diagnose_unknown_annotations | 112 | 112 | 0 language/diverging_exprs | 856 | 856 | 0 language/doc_comments | 72 | 72 | 0 language/dummy_method_issue | 152 | 176 | 15.79 language/duplicated_storage_keys | 40 | 40 | 0 language/empty_method_initializer | 712 | 712 | 0 language/enum_destructuring | 96 | 96 | 0 language/enum_if_let | 440 | 440 | 0 language/enum_if_let_large_type | 392 | 392 | 0 language/enum_in_fn_decl | 120 | 120 | 0 language/enum_init_fn_call | 280 | 280 | 0 language/enum_instantiation | 3464 | 3464 | 0 language/enum_padding | 96 | 96 | 0 language/enum_type_inference | 40 | 40 | 0 language/enum_variant_imports | 144 | 144 | 0 language/eq_and_neq | 1784 | 1784 | 0 language/eq_intrinsic | 40 | 40 | 0 language/fallback_only | 816 | 832 | 1.96 language/far_jumps/many_blobs | 11640232 | 11640232 | 0 language/far_jumps/single_blob | 1048640 | 1048640 | 0 language/fix_opcode_bug | 40 | 40 | 0 language/for_loops | 4200 | 4200 | 0 language/fqp_in_lib | 144 | 144 | 0 language/funcs_with_generic_types | 48 | 48 | 0 language/generic_functions | 48 | 48 | 0 language/generic_impl_self | 2312 | 2312 | 0 language/generic_impl_self_where | 2128 | 2072 | -2.63 language/generic_inside_generic | 128 | 128 | 0 language/generic_result_method | 424 | 408 | -3.77 language/generics_in_contract | 2784 | 2784 | 0 language/generic_struct | 56 | 56 | 0 language/generic_struct_instantiation | 32 | 32 | 0 language/generic_structs | 328 | 328 | 0 language/generic_trait_constraints | 320 | 320 | 0 language/generic_traits | 1032 | 1032 | 0 language/generic_transpose | 632 | 632 | 0 language/generic_tuple_trait | 552 | 552 | 0 language/generic_type_inference | 3152 | 3152 | 0 language/generic_where_in_impl_self2 | 224 | 224 | 0 language/generic_where_in_impl_self | 224 | 224 | 0 language/gtf_intrinsic | 352 | 352 | 0 language/if_elseif_enum | 440 | 440 | 0 language/if_implicit_unit | 32 | 32 | 0 language/if_let_no_side_effects | 128 | 128 | 0 language/implicit_casting | 40 | 40 | 0 language/implicit_return | 40 | 40 | 0 language/impl_self_method | 40 | 40 | 0 language/impl_self_method_order | 40 | 40 | 0 language/import_method_from_other_file | 400 | 400 | 0 language/import_star_name_clash | 2096 | 2096 | 0 language/import_trailing_comma | 40 | 40 | 0 language/import_with_different_callpaths | 2536 | 2560 | 0.95 language/impure_ifs | 816 | 816 | 0 language/inline_if_expr_const | 32 | 32 | 0 language/insert_element_reg_reuse | 2208 | 2200 | -0.36 language/integer_type_inference | 1344 | 1344 | 0 language/is_prime | 864 | 864 | 0 language/is_reference_type | 48 | 48 | 0 language/largeint_sroa | 584 | 584 | 0 language/left_to_right_func_args_evaluation | 64 | 64 | 0 language/local_impl_for_ord | 48 | 48 | 0 language/logging | 648 | 648 | 0 language/main_args/main_args_empty | 40 | 40 | 0 language/main_args/main_args_generics | 136 | 136 | 0 language/main_args/main_args_one_u64 | 48 | 48 | 0 language/main_args/main_args_ref | 48 | 48 | 0 language/main_args/main_args_ref_copy | 56 | 56 | 0 language/main_args/main_args_ref_ref | 56 | 56 | 0 language/main_args/main_args_two_u64 | 48 | 48 | 0 language/main_args/main_args_various_types | 560 | 560 | 0 language/main_returns_unit | 32 | 32 | 0 language/many_stack_variables | 656 | 656 | 0 language/match_expressions | 592 | 592 | 0 language/match_expressions_constants | 168 | 168 | 0 language/match_expressions_empty_enums | 40 | 40 | 0 language/match_expressions_enums | 3048 | 3048 | 0 language/match_expressions_explicit_rets | 48 | 48 | 0 language/match_expressions_inside_generic_functions | 232 | 232 | 0 language/match_expressions_mismatched | 88 | 88 | 0 language/match_expressions_nested | 1384 | 1384 | 0 language/match_expressions_or | 8896 | 8896 | 0 language/match_expressions_rest | 1432 | 1432 | 0 language/match_expressions_simple | 128 | 128 | 0 language/match_expressions_structs | 128 | 128 | 0 language/match_expressions_unreachable_catch_all_last_arm | 2016 | 2104 | 4.37 language/match_expressions_unreachable_catch_all_middle_arm | 1664 | 1896 | 13.94 language/match_expressions_unreachable_last_arm | 2808 | 2840 | 1.14 language/match_expressions_unreachable_middle_arm | 3216 | 3248 | 1.00 language/match_expressions_with_self | 176 | 176 | 0 language/mega_example | 2416 | 2416 | 0 language/memcpy | 176 | 176 | 0 language/method_indirect_inference | 304 | 304 | 0 language/method_on_empty_struct | 32 | 32 | 0 language/method_type_args | 32 | 32 | 0 language/method_unambiguous | 264 | 264 | 0 language/module_dep | 24 | 24 | 0 language/module_dep_multiple | 24 | 24 | 0 language/module_dep_self | 24 | 24 | 0 language/modulo_uint_test | 48 | 48 | 0 language/multi_impl_self | 40 | 40 | 0 language/multi_item_import | 32 | 32 | 0 language/mutable_and_initd | 152 | 152 | 0 language/mutable_arrays | 40 | 40 | 0 language/mutable_arrays_enum | 96 | 96 | 0 language/mutable_arrays_multiple_nested | 32 | 32 | 0 language/mutable_arrays_nested | 32 | 32 | 0 language/mutable_arrays_struct | 40 | 40 | 0 language/mutable_arrays_swap | 40 | 40 | 0 language/mut_ref_empty_type | 464 | 464 | 0 language/name_resolution_after_monomorphization | 56 | 56 | 0 language/nested_struct_destructuring | 32 | 32 | 0 language/nested_structs | 824 | 824 | 0 language/nested_while_and_if | 136 | 136 | 0 language/new_allocator_test | 504 | 504 | 0 language/non_literal_const_decl | 40 | 40 | 0 language/numeric_constants | 48 | 48 | 0 language/op_precedence | 32 | 32 | 0 language/ops | 144 | 144 | 0 language/out_of_order_decl | 56 | 56 | 0 language/predicate_while | 72 | 72 | 0 language/predicate_while_dep | 72 | 72 | 0 language/prelude_access2 | 32 | 32 | 0 language/prelude_access | 32 | 32 | 0 language/primitive_type_argument | 40 | 40 | 0 language/raw_identifiers | 160 | 160 | 0 language/raw_ptr/raw_ptr_ret | 48 | 48 | 0 language/raw_ptr/vec_ret | 352 | 352 | 0 language/reassignment_operators | 32 | 32 | 0 language/reassignment_rhs_lhs_evaluation_order | 416 | 416 | 0 language/redundant_return | 32 | 32 | 0 language/references/dereferencing_control_flow_expressions | 712 | 712 | 0 language/references/dereferencing_operator_dot_on_structs | 124712 | 124760 | 0.04 language/references/dereferencing_operator_dot_on_tuples | 124712 | 124760 | 0.04 language/references/dereferencing_operator_index | 92088 | 92088 | 0 language/references/dereferencing_operator_star | 150744 | 150768 | 0.02 language/references/impl_reference_types | 7328 | 7328 | 0 language/references/mutability_of_references | 648 | 648 | 0 language/references/passing_and_returning_references_to_and_from_functions | 15648 | 15648 | 0 language/references/reassigning_via_references_to_values | 13696 | 13696 | 0 language/references/references_and_generics | 3304 | 3304 | 0 language/references/references_in_aggregates | 3616 | 3616 | 0 language/references/references_in_asm_blocks | 1904 | 1904 | 0 language/references/referencing_control_flow_expressions | 536 | 536 | 0 language/references/referencing_function_parameters | 3656 | 3648 | -0.22 language/references/referencing_local_vars_and_values | 36144 | 36144 | 0 language/references/referencing_parts_of_aggregates | 6552 | 6336 | -3.30 language/references/referencing_references | 848 | 848 | 0 language/references/type_unification_of_references | 3168 | 3168 | 0 language/ref_mutable_arrays | 40 | 40 | 0 language/ref_mutable_arrays_inline | 40 | 40 | 0 language/ref_mutable_fn_args_bool | 48 | 48 | 0 language/ref_mutable_fn_args_call | 40 | 40 | 0 language/ref_mutable_fn_args_struct | 40 | 40 | 0 language/ref_mutable_fn_args_struct_assign | 40 | 40 | 0 language/ref_mutable_fn_args_u32 | 40 | 40 | 0 language/retd_b256 | 128 | 128 | 0 language/retd_small_array | 56 | 56 | 0 language/retd_struct | 152 | 152 | 0 language/retd_zero_len_array | 48 | 48 | 0 language/ret_small_string | 64 | 64 | 0 language/ret_string_in_struct | 80 | 80 | 0 language/revert_in_first_if_branch | 40 | 40 | 0 language/same_const_name | 104 | 104 | 0 language/same_const_name_lib | 24 | 24 | 0 language/self_impl_reassignment | 656 | 656 | 0 language/shadowing/shadowed_glob_imports | 32 | 32 | 0 language/size_of | 32 | 32 | 0 language/smo | 880 | 880 | 0 language/smo_opcode | 128 | 128 | 0 language/struct_destructuring | 152 | 152 | 0 language/struct_field_access | 40 | 40 | 0 language/struct_field_reassignment | 32 | 32 | 0 language/struct_init_reorder | 136 | 128 | -5.88 language/struct_instantiation | 2008 | 2008 | 0 language/supertraits | 6936 | 5776 | -16.72 language/supertraits_with_trait_methods | 120 | 120 | 0 language/test_attribute | 24 | 24 | 0 language/test_multiple_attributes | 24 | 24 | 0 language/trait_import_with_star | 32 | 32 | 0 language/trait_method_ascription_disambiguate | 160 | 160 | 0 language/trait_method_generic_qualified | 160 | 160 | 0 language/trait_method_qualified | 48 | 48 | 0 language/trait_nested | 160 | 160 | 0 language/tuple_access | 168 | 168 | 0 language/tuple_desugaring | 64 | 64 | 0 language/tuple_field_reassignment | 144 | 144 | 0 language/tuple_indexing | 32 | 32 | 0 language/tuple_in_struct | 376 | 376 | 0 language/tuple_trait | 120 | 120 | 0 language/tuple_types | 40 | 40 | 0 language/type_alias | 3624 | 3680 | 1.55 language/typeinfo_custom_callpath2 | 80 | 80 | 0 language/typeinfo_custom_callpath | 80 | 80 | 0 language/typeinfo_custom_callpath_with_import | 96 | 96 | 0 language/u256/u256_abi | 152 | 152 | 0 language/u256/u256_operators | 5152 | 5192 | 0.78 language/unary_not_basic_2 | 48 | 48 | 0 language/unary_not_basic | 48 | 48 | 0 language/unit_type_variants | 48 | 48 | 0 language/use_absolute_path | 32 | 32 | 0 language/use_full_path_names | 32 | 32 | 0 language/valid_impurity | 80 | 80 | 0 language/where_clause_enums | 456 | 456 | 0 language/where_clause_functions | 1696 | 1696 | 0 language/where_clause_generic_traits | 200 | 200 | 0 language/where_clause_generic_tuple | 40 | 40 | 0 language/where_clause_impls | 280 | 280 | 0 language/where_clause_methods | 1728 | 1728 | 0 language/where_clause_structs | 304 | 304 | 0 language/where_clause_traits | 32 | 32 | 0 language/while_loops | 304 | 304 | 0 language/zero_field_types | 40 | 40 | 0 multiple_supertraits_for_abis | 96 | 96 | 0 non_payable_implicit_zero_coins | 224 | 224 | 0 non_payable_zero_coins_let_binding | 224 | 224 | 0 resolve_local_items_that_shadow_imports | 176 | 176 | 0 return_in_strange_positions | 40 | 40 | 0 return_into | 640 | 640 | 0 static_analysis/cei_pattern_violation | 568 | 568 | 0 static_analysis/cei_pattern_violation_in_asm_block | 232 | 232 | 0 static_analysis/cei_pattern_violation_in_asm_block_bal | 192 | 192 | 0 static_analysis/cei_pattern_violation_in_asm_block_mint_burn | 360 | 360 | 0 static_analysis/cei_pattern_violation_in_asm_block_read | 224 | 224 | 0 static_analysis/cei_pattern_violation_in_asm_block_smo | 216 | 216 | 0 static_analysis/cei_pattern_violation_in_asm_block_tr | 1328 | 1344 | 1.20 static_analysis/cei_pattern_violation_in_asm_block_tro | 1328 | 1344 | 1.20 static_analysis/cei_pattern_violation_in_codeblocks_other_than_in_functions | 568 | 568 | 0 static_analysis/cei_pattern_violation_in_func_app-1 | 568 | 568 | 0 static_analysis/cei_pattern_violation_in_func_app-2 | 568 | 568 | 0 static_analysis/cei_pattern_violation_in_func_app-3 | 568 | 568 | 0 static_analysis/cei_pattern_violation_in_if_statement-1 | 584 | 584 | 0 static_analysis/cei_pattern_violation_in_if_statement-2 | 568 | 568 | 0 static_analysis/cei_pattern_violation_in_intrinsic_call | 568 | 568 | 0 static_analysis/cei_pattern_violation_in_match_statement-1 | 672 | 672 | 0 static_analysis/cei_pattern_violation_in_standalone_function | 568 | 568 | 0 static_analysis/cei_pattern_violation_in_struct | 568 | 568 | 0 static_analysis/cei_pattern_violation_in_tuple | 568 | 568 | 0 static_analysis/cei_pattern_violation_in_while_loop-1 | 568 | 568 | 0 static_analysis/cei_pattern_violation_in_while_loop-2 | 568 | 568 | 0 static_analysis/cei_pattern_violation_in_while_loop-3 | 568 | 568 | 0 static_analysis/cei_pattern_violation_in_while_loop-4 | 568 | 568 | 0 static_analysis/cei_pattern_violation_more_complex_logic | 11000 | 11144 | 1.31 static_analysis/cei_pattern_violation_smo_intrinsic | 280 | 280 | 0 static_analysis/cei_pattern_violation_storage_map_and_vec | 5640 | 5944 | 5.39 static_analysis/cei_pattern_violation_storage_struct_read | 776 | 792 | 2.06 static_analysis/cei_pattern_violation_storage_var_read | 760 | 760 | 0 static_analysis/cei_pattern_violation_storage_var_update | 688 | 688 | 0 static_analysis/storage_annotations_unused_read | 64 | 64 | 0 static_analysis/storage_annotations_unused_read_and_write | 64 | 64 | 0 static_analysis/storage_annotations_unused_write | 64 | 64 | 0 stdlib/address_test | 3912 | 3912 | 0 stdlib/alloc_test | 576 | 576 | 0 stdlib/assert_eq | 3128 | 3128 | 0 stdlib/assert_eq_revert | 72 | 72 | 0 stdlib/assert_ne | 3072 | 3072 | 0 stdlib/assert_ne_revert | 72 | 72 | 0 stdlib/assert_test | 48 | 48 | 0 stdlib/b512_struct_alignment | 504 | 504 | 0 stdlib/b512_test | 3096 | 3096 | 0 stdlib/block_height | 88 | 88 | 0 stdlib/chess | 1320 | 1320 | 0 stdlib/contract_id_test | 368 | 368 | 0 stdlib/contract_id_type | 368 | 368 | 0 stdlib/eq_custom_type | 448 | 448 | 0 stdlib/eq_generic | 32 | 32 | 0 stdlib/generic_empty_struct_with_constraint | 32 | 32 | 0 stdlib/ge_test | 312 | 312 | 0 stdlib/identity_eq | 2200 | 2200 | 0 stdlib/if_type_revert | 32 | 32 | 0 stdlib/intrinsics | 48 | 48 | 0 stdlib/iterator | 1552 | 1480 | -4.64 stdlib/option | 22456 | 22584 | 0.57 stdlib/option_eq | 11928 | 11952 | 0.20 stdlib/raw_ptr | 4232 | 4232 | 0 stdlib/raw_slice | 688 | 688 | 0 stdlib/require | 288 | 288 | 0 stdlib/result | 8640 | 8664 | 0.28 stdlib/sha256 | 1920 | 1920 | 0 stdlib/storage_vec_insert | 5128 | 5256 | 2.50 stdlib/u128_div_test | 2456 | 2472 | 0.65 stdlib/u128_log_test | 4248 | 4272 | 0.56 stdlib/u128_mul_test | 1208 | 1208 | 0 stdlib/u128_root_test | 4072 | 4072 | 0 stdlib/u128_test | 6208 | 6208 | 0 stdlib/vec | 106224 | 106856 | 0.59 stdlib/vec_swap | 23352 | 23536 | 0.79 storage_into | 616 | 616 | 0 superabi | 96 | 96 | 0 superabi_diamond | 152 | 152 | 0 superabi_diamond_impl | 152 | 152 | 0 superabi_supertrait_same_methods | 432 | 432 | 0 supertraits_for_abis | 96 | 96 | 0 supertraits_for_abis_diamond | 64 | 64 | 0 supertraits_for_abis_ownable | 3200 | 3296 | 3.00 test_abis/abi_impl_methods_in_json_abi | 96 | 96 | 0 test_contracts/abi_with_generic_types | 152 | 152 | 0 test_contracts/abi_with_same_name_types | 96 | 96 | 0 test_contracts/abi_with_tuples_contract | 152 | 152 | 0 test_contracts/array_of_structs_contract | 192 | 192 | 0 test_contracts/auth_testing_contract | 72 | 72 | 0 test_contracts/balance_test_contract | 72 | 72 | 0 test_contracts/basic_storage | 28272 | 28464 | 0.68 test_contracts/context_testing_contract | 800 | 800 | 0 test_contracts/contract_with_type_aliases | 168 | 168 | 0 test_contracts/increment_contract | 1824 | 1824 | 0 test_contracts/issue_1512_repro | 1160 | 1160 | 0 test_contracts/multiple_impl | 80 | 80 | 0 test_contracts/nested_struct_args_contract | 96 | 96 | 0 test_contracts/return_struct | 2168 | 2168 | 0 test_contracts/storage_access_contract | 13768 | 13792 | 0.17 test_contracts/storage_enum_contract | 16768 | 16848 | 0.48 test_contracts/storage_namespace | 26904 | 27096 | 0.71 test_contracts/test_fuel_coin_contract | 1128 | 1136 | 0.71 unit_tests/aggr_indexing | 896 | 896 | 0 unit_tests/contract-multi-contract-calls | 64 | 64 | 0 unit_tests/contract_with_nested_libs | 384 | 384 | 0 unit_tests/lib_multi_test | 352 | 352 | 0 unit_tests/lib_single_test | 88 | 88 | 0 unit_tests/nested_libs | 344 | 344 | 0 unit_tests/predicate_multi_test | 248 | 248 | 0 unit_tests/predicate_with_nested_libs | 296 | 296 | 0 unit_tests/regalloc_spill | 408 | 408 | 0 unit_tests/script-contract-calls | 64 | 64 | 0 unit_tests/script_multi_test | 264 | 264 | 0 unit_tests/script_with_nested_libs | 352 | 352 | 0 unit_tests/should_revert | 160 | 160 | 0 unit_tests/stack_indexing_overflow | 3816 | 3816 | 0 </details> ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [x] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
compiler: ir
IRgen and sway-ir including optimization passes
compiler
General compiler. Should eventually become more specific as the issue is triaged
team:compiler
Compiler Team
#5924 will remove collecting raw pointer and reference locals when collecting referred symbols. They are just intermediates and should not be collected as referred symbols.
This means, once #5924 is closed, we will not follow
Load
s anymore and will immediately bail out returning anReferredSymbols::Incomplete
result. This approach has the consequence of restricting/forbidding some optimizations even if they would be perfectly safe.E.g., let's consider this example:
The addresses are passed as arguments and we have no
PtrToInt
s in the function. The*ref_local = 2;
goes over typicalIntToPtr -> Load
chain that leads toref_local
. If we bail out here, we indicate to the rest of the analysis that we have anIncomplete
information which will forbid further optimizations.Incomplete
affects optimizations in a particular function and can fully restrict some likememcpyopt
. The consequence in this example will be that thex = 0
does not get optimized away although it clearly can.On the other hand, if we give best effort in detecting sources of
ref_local
, we will reachref_a
andref_b
in this case and come to aReferredSymbols::Complete
result. This will justify the safe removal ofx = 0
.To conclude, giving best effort in following
loaded_from
inmemory_utils::get_symbols()
will remove non-existing constraints in optimizations.Blocked by #5924.
The text was updated successfully, but these errors were encountered: