Skip to content
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

Don't force inliner in case of ref type function args #4823

Merged
merged 12 commits into from
Jul 21, 2023

Conversation

vaivaswatha
Copy link
Contributor

@vaivaswatha vaivaswatha commented Jul 19, 2023

This was required previously, but after the IR refactoring (#4336), this is no longer required, and actually worsens things.

Fixes #4747. For the two tests mentioned there, (both based on https://github.com/hashcloak/fuel-crypto/) the compile time now comes down from

  1. 30m -> 16s
  2. 180m -> 31s

Also fixes two bugs uncovered:

  1. Bug in DCE - Fixes DCE eliminating ref mut storage. #4763. (1b512b8)
  2. Bug in interaction b/w asm gen and reg alloc spiller (7a40496).

This was required previously, but after the IR refactoring (#4336),
this is no longer required, and actually worsens things.

Fixes #4747. For the two tests mentioned there,
(both based on https://github.com/hashcloak/fuel-crypto/)
the compile time now comes down from 30m -> 16s and 180m -> 31s.
@vaivaswatha vaivaswatha requested a review from a team July 19, 2023 08:10
@vaivaswatha vaivaswatha self-assigned this Jul 19, 2023
vaivaswatha and others added 9 commits July 19, 2023 13:40
Locals alloc must happen before other initializations
(such as saving the frame pointer for args). Otherwise,
if those other registers are spilled, then LocalsBase
reg will end up being initialized *after* the spill.
That can't happen because spill offsets are based on
LocalsBase reg.
@vaivaswatha vaivaswatha marked this pull request as ready for review July 20, 2023 11:42
@vaivaswatha
Copy link
Contributor Author

vaivaswatha commented Jul 20, 2023

Here are some stats from our testsuite.

There is code increase in some small tests, where due to not inlining, the overheads of a function call result in overall increase. There are a few exceptions to this that need to be investigated though.

But irrespective of the stats, this change is necessary, because the inliner heuristic I'm removing here is not based on any inliner "logic" but as a workaround against some other bug that has since been fixed.

Stats
Test master inliner_fix % reduction (+ is better)
Testing should_pass/non_payable_implicit_zero_coins 240 240 0
Testing should_pass/forc/contract_dependencies/contract_b 68 68 0
Testing should_pass/forc/contract_dependencies/contract_c 68 68 0
Testing should_pass/forc/contract_dependencies/contract_a 68 324 -376.470588235294
Testing should_pass/forc/dependency_package_field 36 36 0
Testing should_pass/forc/dependency_patching 36 36 0
Testing should_pass/forc/parent_pkg_manifest/contract_a 68 68 0
Testing should_pass/evm/evm_basic 36 36 0
Testing should_pass/language/basic_func_decl 36 36 0
Testing should_pass/language/integer_type_inference 36 36 0
Testing should_pass/language/const_decl_in_library 76 76 0
Testing should_pass/language/mutable_arrays_struct 156 156 0
Testing should_pass/language/unary_not_basic 36 36 0
Testing should_pass/language/associated_const_trait_method 36 36 0
Testing should_pass/language/import_trailing_comma 84 84 0
Testing should_pass/language/struct_field_access 92 92 0
Testing should_pass/language/type_alias 5760 4328 24.8611111111111
Testing should_pass/language/mutable_arrays 116 116 0
Testing should_pass/language/prelude_access 36 36 0
Testing should_pass/language/trait_method_generic_qualified 36 36 0
Testing should_pass/language/generic_where_in_impl_self2 460 460 0
Testing should_pass/language/array_generics 84 84 0
Testing should_pass/language/is_prime 1116 1116 0
Testing should_pass/language/out_of_order_decl 52 52 0
Testing should_pass/language/associated_const_impl_self 36 36 0
Testing should_pass/language/binary_and_hex_literals 36 36 0
Testing should_pass/language/chained_if_let 172 172 0
Testing should_pass/language/builtin_type_method_call 52 52 0
Testing should_pass/language/match_expressions_nested 164 164 0
Testing should_pass/language/raw_identifiers 140 140 0
Testing should_pass/language/struct_init_reorder 116 116 0
Testing should_pass/language/ref_mutable_fn_args_struct_assign 92 92 0
Testing should_pass/language/generic_enum 36 36 0
Testing should_pass/language/op_precedence 36 36 0
Testing should_pass/language/retd_struct 120 120 0
Testing should_pass/language/attributes_warnings 36 36 0
Testing should_pass/language/break_and_continue_block_ret 44 44 0
Testing should_pass/language/typeinfo_custom_callpath 100 100 0
Testing should_pass/language/retd_small_array 60 60 0
Testing should_pass/language/many_stack_variables 780 780 0
Testing should_pass/language/multi_item_import 36 36 0
Testing should_pass/language/ref_mutable_fn_args_struct 84 84 0
Testing should_pass/language/inline_if_expr_const 36 36 0
Testing should_pass/language/contract_caller_as_ret 68 68 0
Testing should_pass/language/mutable_arrays_enum 156 156 0
Testing should_pass/language/ref_mutable_arrays 116 116 0
Testing should_pass/language/tuple_in_struct 916 916 0
Testing should_pass/language/doc_comments 84 84 0
Testing should_pass/language/unary_not_basic_2 36 36 0
Testing should_pass/language/match_expressions_simple 340 340 0
Testing should_pass/language/gtf_intrinsic 92 92 0
Testing should_pass/language/modulo_uint_test 300 300 0
Testing should_pass/language/ret_string_in_struct 80 80 0
Testing should_pass/language/smo_opcode 112 112 0
Testing should_pass/language/arg_demotion_inline 68 68 0
Testing should_pass/language/ret_small_string 64 64 0
Testing should_pass/language/match_expressions_rest 156 156 0
Testing should_pass/language/b256_bad_jumps 36 36 0
Testing should_pass/language/tuple_single_element 108 108 0
Testing should_pass/language/match_expressions_mismatched 116 116 0
Testing should_pass/language/basic_predicate 36 36 0
Testing should_pass/language/if_elseif_enum 756 676 10.5820105820106
Testing should_pass/language/associated_const_impl 36 36 0
Testing should_pass/language/associated_const_trait_const 36 36 0
Testing should_pass/language/implicit_return 52 52 0
Testing should_pass/language/generic_transpose 868 868 0
Testing should_pass/language/insert_element_reg_reuse 5044 4748 5.86835844567803
Testing should_pass/language/where_clause_structs 380 380 0
Testing should_pass/language/enum_variant_imports 844 844 0
Testing should_pass/language/configurable_consts 4476 4444 0.714924039320822
Testing should_pass/language/match_expressions_with_self 396 396 0
Testing should_pass/language/where_clause_impls 524 524 0
Testing should_pass/language/enum_type_inference 52 52 0
Testing should_pass/language/implicit_casting 52 52 0
Testing should_pass/language/binop_intrinsics 948 948 0
Testing should_pass/language/abort_control_flow_good 52 52 0
Testing should_pass/language/match_expressions_structs 212 212 0
Testing should_pass/language/funcs_with_generic_types 36 36 0
Testing should_pass/language/typeinfo_custom_callpath2 100 100 0
Testing should_pass/language/bool_and_or 84 84 0
Testing should_pass/language/eq_and_neq 1332 2188 -64.2642642642643
Testing should_pass/language/const_decl_with_call_path 364 364 0
Testing should_pass/language/unit_type_variants 60 60 0
Testing should_pass/language/ops 5212 5212 0
Testing should_pass/language/far_jumps/many_blobs 11640280 11640280 0
Testing should_pass/language/far_jumps/single_blob 1048656 1048656 0
Testing should_pass/language/ref_mutable_fn_args_call 60 60 0
Testing should_pass/language/size_of 260 260 0
Testing should_pass/language/zero_field_types 52 52 0
Testing should_pass/language/asm_without_return 60 60 0
Testing should_pass/language/where_clause_functions 1932 1932 0
Testing should_pass/language/associated_const_impl_local_same_name 36 36 0
Testing should_pass/language/struct_destructuring 204 204 0
Testing should_pass/language/is_reference_type 516 516 0
Testing should_pass/language/reassignment_operators 260 260 0
Testing should_pass/language/enum_if_let_large_type 436 436 0
Testing should_pass/language/match_expressions_enums 148 148 0
Testing should_pass/language/asm_expr_basic 284 284 0
Testing should_pass/language/same_const_name_lib 28 28 0
Testing should_pass/language/associated_const_abi 36 36 0
Testing should_pass/language/nested_structs 1940 1940 0
Testing should_pass/language/retd_b256 128 128 0
Testing should_pass/language/same_const_name 1036 1036 0
Testing should_pass/language/tuple_types 52 52 0
Testing should_pass/language/tuple_trait 140 140 0
Testing should_pass/language/associated_const_trait 36 36 0
Testing should_pass/language/predicate_while_dep 68 68 0
Testing should_pass/language/generic_impl_self_where 2260 2532 -12.0353982300885
Testing should_pass/language/enum_if_let 640 640 0
Testing should_pass/language/main_returns_unit 36 36 0
Testing should_pass/language/tuple_indexing 68 68 0
Testing should_pass/language/mutable_arrays_nested 196 196 0
Testing should_pass/language/match_expressions_empty_enums 52 52 0
Testing should_pass/language/associated_const_abi_default 36 36 0
Testing should_pass/language/shadowing/shadowed_glob_imports 36 36 0
Testing should_pass/language/eq_intrinsic 588 588 0
Testing should_pass/language/struct_field_reassignment 36 36 0
Testing should_pass/language/generic_structs 52 52 0
Testing should_pass/language/ref_mutable_arrays_inline 116 116 0
Testing should_pass/language/import_with_different_callpaths 2492 3180 -27.6083467094703
Testing should_pass/language/main_args/main_args_ref_copy 60 60 0
Testing should_pass/language/main_args/main_args_copy 52 52 0
Testing should_pass/language/main_args/main_args_ref_ref 60 60 0
Testing should_pass/language/main_args/main_args_various_types 452 452 0
Testing should_pass/language/main_args/main_args_empty 52 52 0
Testing should_pass/language/main_args/main_args_ref 52 52 0
Testing should_pass/language/main_args/main_args_copy_copy 52 52 0
Testing should_pass/language/prelude_access2 36 36 0
Testing should_pass/language/use_full_path_names 36 36 0
Testing should_pass/language/typeinfo_custom_callpath_with_import 164 164 0
Testing should_pass/language/retd_zero_len_array 44 44 0
Testing should_pass/language/where_clause_enums 612 612 0
Testing should_pass/language/generic_functions 36 36 0
Testing should_pass/language/b256_bitwise_ops 25288 14292 43.4830749762733
Testing should_pass/language/mutable_and_initd 164 164 0
Testing should_pass/language/enum_in_fn_decl 116 116 0
Testing should_pass/language/associated_const_abi_multiple 36 36 0
Testing should_pass/language/valid_impurity 68 68 0
Testing should_pass/language/nested_while_and_if 164 164 0
Testing should_pass/language/mutable_arrays_multiple_nested 172 172 0
Testing should_pass/language/where_clause_traits 36 36 0
Testing should_pass/language/supertraits 4204 4204 0
Testing should_pass/language/match_expressions_constants 92 92 0
Testing should_pass/language/tuple_field_reassignment 1188 1188 0
Testing should_pass/language/enum_destructuring 124 124 0
Testing should_pass/language/revert_in_first_if_branch 52 52 0
Testing should_pass/language/logging 472 472 0
Testing should_pass/language/where_clause_methods 1924 1924 0
Testing should_pass/language/ref_mutable_fn_args_bool 52 52 0
Testing should_pass/language/diagnose_unknown_annotations 100 100 0
Testing should_pass/language/bitwise_not 220 220 0
Testing should_pass/language/generic_struct 44 44 0
Testing should_pass/language/primitive_type_argument 52 52 0
Testing should_pass/language/fix_opcode_bug 52 52 0
Testing should_pass/language/trait_method_ascription_disambiguate 36 36 0
Testing should_pass/language/smo 892 892 0
Testing should_pass/language/import_method_from_other_file 508 508 0
Testing should_pass/language/aliased_imports 60 60 0
Testing should_pass/language/left_to_right_func_args_evaluation 188 188 0
Testing should_pass/language/mutable_arrays_swap 116 116 0
Testing should_pass/language/break_and_continue 780 780 0
Testing should_pass/language/generic_type_inference 3916 4236 -8.17160367722165
Testing should_pass/language/empty_method_initializer 416 416 0
Testing should_pass/language/const_inits 3172 3292 -3.78310214375788
Testing should_pass/language/if_implicit_unit 36 36 0
Testing should_pass/language/enum_init_fn_call 812 812 0
Testing should_pass/language/complex_cfg 340 524 -54.1176470588235
Testing should_pass/language/use_absolute_path 36 36 0
Testing should_pass/language/enum_padding 116 116 0
Testing should_pass/language/method_type_args 36 36 0
Testing should_pass/language/method_on_empty_struct 36 36 0
Testing should_pass/language/const_decl 52 52 0
Testing should_pass/language/tuple_access 144 144 0
Testing should_pass/language/impure_ifs 804 1252 -55.7213930348259
Testing should_pass/language/ref_mutable_fn_args_u32 60 60 0
Testing should_pass/language/match_expressions_or 724 724 0
Testing should_pass/language/trait_import_with_star 60 60 0
Testing should_pass/language/generic_where_in_impl_self 460 460 0
Testing should_pass/language/match_expressions_explicit_rets 36 36 0
Testing should_pass/language/while_loops 420 420 0
Testing should_pass/language/generics_in_contract 472 608 -28.8135593220339
Testing should_pass/language/associated_const_trait_impl_method 36 36 0
Testing should_pass/language/contract_caller_dynamic_address 144 144 0
Testing should_pass/language/generic_result_method 652 652 0
Testing should_pass/language/local_impl_for_ord 36 36 0
Testing should_pass/language/match_expressions_inside_generic_functions 540 540 0
Testing should_pass/language/raw_ptr/vec_ret 804 764 4.97512437810945
Testing should_pass/language/raw_ptr/raw_ptr_ret 348 348 0
Testing should_pass/language/const_decl_and_use_in_library 52 52 0
Testing should_pass/language/predicate_while 68 68 0
Testing should_pass/language/test_attribute 28 28 0
Testing should_pass/language/numeric_constants 380 380 0
Testing should_pass/language/generic_impl_self 2796 3012 -7.72532188841202
Testing should_pass/language/generic_inside_generic 196 196 0
Testing should_pass/language/match_expressions 52 52 0
Testing should_pass/language/associated_const_trait_default 52 52 0
Testing should_pass/language/generic_traits 1028 1028 0
Testing should_pass/language/self_impl_reassignment 1204 1140 5.3156146179402
Testing should_pass/language/b256_ops 1064 1064 0
Testing should_pass/language/associated_const_impl_multiple 36 36 0
Testing should_pass/language/multi_impl_self 52 52 0
Testing should_pass/language/array_basics 964 964 0
Testing should_pass/language/tuple_desugaring 228 228 0
Testing should_pass/language/non_literal_const_decl 52 52 0
Testing should_pass/language/supertraits_with_trait_methods 148 148 0
Testing should_pass/language/redundant_return 36 36 0
Testing should_pass/language/nested_struct_destructuring 52 52 0
Testing should_pass/language/test_multiple_attributes 28 28 0
Testing should_pass/language/diverging_exprs 1932 1932 0
Testing should_pass/language/trait_method_qualified 260 260 0
Testing should_pass/language/new_allocator_test 820 820 0
Testing should_pass/stdlib/sha256 556 556 0
Testing should_pass/stdlib/u256_div_test 36228 14956 58.7170144639505
Testing should_pass/stdlib/result 6912 6912 0
Testing should_pass/stdlib/u128_mul_test 1380 1308 5.21739130434783
Testing should_pass/stdlib/require 36 36 0
Testing should_pass/stdlib/address_test 2184 3192 -46.1538461538462
Testing should_pass/stdlib/storage_vec_insert 1736 1944 -11.9815668202765
Testing should_pass/stdlib/eq_custom_type 804 812 -0.99502487562189
Testing should_pass/stdlib/alloc 780 780 0
Testing should_pass/stdlib/u256_ops_test 31084 14244 54.1757817526702
Testing should_pass/stdlib/if_type_revert 36 36 0
Testing should_pass/stdlib/u256_test 4892 5108 -4.41537203597711
Testing should_pass/stdlib/b512_test 2864 3432 -19.8324022346369
Testing should_pass/stdlib/assert_eq_revert 68 68 0
Testing should_pass/stdlib/option 22816 25356 -11.132538569425
Testing should_pass/stdlib/exponentiation_test 3028 3028 0
Testing should_pass/stdlib/vec 143056 121192 15.2835253327368
Testing should_pass/stdlib/vec_swap 27748 28940 -4.29580510307049
Testing should_pass/stdlib/assert_test 276 276 0
Testing should_pass/stdlib/raw_slice 572 572 0
Testing should_pass/stdlib/intrinsics 596 596 0
Testing should_pass/stdlib/ge_test 388 388 0
Testing should_pass/stdlib/u128_test 7428 6708 9.69305331179321
Testing should_pass/stdlib/contract_id_test 304 304 0
Testing should_pass/stdlib/contract_id_type 388 732 -88.659793814433
Testing should_pass/stdlib/chess 2084 2084 0
Testing should_pass/stdlib/raw_ptr 1764 1764 0
Testing should_pass/stdlib/u128_root_test 34652 6372 81.6114509984994
Testing should_pass/stdlib/logarithmic_test 1644 1644 0
Testing should_pass/stdlib/assert_eq 2188 2340 -6.94698354661792
Testing should_pass/stdlib/block_height 76 76 0
Testing should_pass/stdlib/u256_mul_test 36124 7692 78.7066770014395
Testing should_pass/stdlib/eq_generic 36 36 0
Testing should_pass/stdlib/u128_div_test 4460 3388 24.0358744394619
Testing should_pass/stdlib/u128_log_test 33908 5924 82.5291966497582
Testing should_pass/stdlib/identity_eq 6628 2332 64.8159324079662
Testing should_pass/stdlib/b512_struct_alignment 328 328 0
Testing should_pass/dca/impl_trait_single 36 36 0
Testing should_pass/dca/multiple_fns_same_name 36 36 0
Testing should_pass/dca/trait_method 36 36 0
Testing should_pass/dca/unused_trait 36 36 0
Testing should_pass/dca/trait_method_neq 116 116 0
Testing should_pass/dca/alias_lib 84 84 0
Testing should_pass/dca/trait_method_lib 28 28 0
Testing should_pass/dca/multiple_enums_same_name 36 36 0
Testing should_pass/dca/contract/unused_struct_field_array 100 100 0
Testing should_pass/dca/contract/unused_struct_field_enum 92 92 0
Testing should_pass/dca/contract/unused_struct_field 76 76 0
Testing should_pass/dca/contract/abi_fn_params 116 116 0
Testing should_pass/dca/contract/unused_struct_field_tuple 76 76 0
Testing should_pass/dca/unused_struct 36 36 0
Testing should_pass/dca/unused_free_fn 36 36 0
Testing should_pass/dca/impl_self 36 36 0
Testing should_pass/dca/unused_variable 36 36 0
Testing should_pass/dca/all_paths_return 36 36 0
Testing should_pass/dca/allow_dead_code 36 36 0
Testing should_pass/dca/log_stdlib 52 52 0
Testing should_pass/dca/impl_self_alias2 36 36 0
Testing should_pass/dca/struct_field_no_warning 44 44 0
Testing should_pass/dca/log_intrinsic 52 52 0
Testing should_pass/dca/unused_enum 36 36 0
Testing should_pass/dca/constant_struct 64 64 0
Testing should_pass/dca/impl_unused_fn 60 60 0
Testing should_pass/dca/library/fn_params_free 28 28 0
Testing should_pass/dca/library/fn_params_impl 28 28 0
Testing should_pass/dca/library/unused_priv_free_fn 28 28 0
Testing should_pass/dca/library/unused_pub_free_fn 28 28 0
Testing should_pass/dca/library/fn_params_trait 28 28 0
Testing should_pass/dca/unused_variable_in_free_fn 36 36 0
Testing should_pass/dca/generic_fn_trait_contraint 36 36 0
Testing should_pass/dca/func_param 36 36 0
Testing should_pass/dca/alias_type_ascription_generic 36 36 0
Testing should_pass/dca/alias_unused 36 36 0
Testing should_pass/dca/impl_trait_multiple 36 36 0
Testing should_pass/dca/impl_self_alias 36 36 0
Testing should_pass/dca/alias_type_ascription 36 36 0
Testing should_pass/dca/constant_decl_expr 52 52 0
Testing should_pass/dca/constant_while 36 36 0
Testing should_pass/dca/unused_fields 36 36 0
Testing should_pass/static_analysis/cei_pattern_violation_storage_var_read 524 524 0
Testing should_pass/static_analysis/cei_pattern_violation_in_intrinsic_call 260 260 0
Testing should_pass/static_analysis/cei_pattern_violation_in_tuple 260 260 0
Testing should_pass/static_analysis/cei_pattern_violation_in_asm_block 240 240 0
Testing should_pass/static_analysis/cei_pattern_violation_in_while_loop-4 260 260 0
Testing should_pass/static_analysis/cei_pattern_violation_in_asm_block_tr 332 500 -50.6024096385542
Testing should_pass/static_analysis/cei_pattern_violation_smo_intrinsic 296 296 0
Testing should_pass/static_analysis/cei_pattern_violation_more_complex_logic 8232 8276 -0.534499514091351
Testing should_pass/static_analysis/cei_pattern_violation_in_struct 260 260 0
Testing should_pass/static_analysis/cei_pattern_violation_in_asm_block_read 224 224 0
Testing should_pass/static_analysis/cei_pattern_violation_in_while_loop-2 260 260 0
Testing should_pass/static_analysis/cei_pattern_violation_in_while_loop-1 260 260 0
Testing should_pass/static_analysis/cei_pattern_violation_in_while_loop-3 260 260 0
Testing should_pass/static_analysis/cei_pattern_violation_in_func_app-1 260 260 0
Testing should_pass/static_analysis/cei_pattern_violation_in_func_app-2 260 260 0
Testing should_pass/static_analysis/cei_pattern_violation 260 260 0
Testing should_pass/static_analysis/cei_pattern_violation_in_asm_block_tro 1244 1244 0
Testing should_pass/static_analysis/cei_pattern_violation_in_func_app-3 260 260 0
Testing should_pass/static_analysis/cei_pattern_violation_in_if_statement-2 260 260 0
Testing should_pass/static_analysis/cei_pattern_violation_in_asm_block_bal 212 212 0
Testing should_pass/static_analysis/storage_annotations_unused_read 68 68 0
Testing should_pass/static_analysis/cei_pattern_violation_in_codeblocks_other_than_in_functions 260 260 0
Testing should_pass/static_analysis/cei_pattern_violation_in_asm_block_smo 220 220 0
Testing should_pass/static_analysis/cei_pattern_violation_storage_struct_read 516 516 0
Testing should_pass/static_analysis/cei_pattern_violation_storage_var_update 452 452 0
Testing should_pass/static_analysis/cei_pattern_violation_in_standalone_function 260 260 0
Testing should_pass/static_analysis/storage_annotations_unused_read_and_write 68 68 0
Testing should_pass/static_analysis/storage_annotations_unused_write 68 68 0
Testing should_pass/static_analysis/cei_pattern_violation_in_if_statement-1 284 284 0
Testing should_pass/static_analysis/cei_pattern_violation_storage_map_and_vec 2180 2300 -5.5045871559633
Testing should_pass/static_analysis/cei_pattern_violation_in_match_statement-1 452 652 -44.2477876106195
Testing should_pass/supertraits_for_abis_diamond 68 68 0
Testing should_pass/non_payable_zero_coins_let_binding 240 240 0
Testing should_pass/multiple_supertraits_for_abis 100 100 0
Testing should_pass/unit_tests/contract_with_nested_libs 164 164 0
Testing should_pass/unit_tests/script_with_nested_libs 132 132 0
Testing should_pass/unit_tests/should_revert 68 68 0
Testing should_pass/unit_tests/predicate_multi_test 204 204 0
Testing should_pass/unit_tests/lib_single_test 36 36 0
Testing should_pass/unit_tests/regalloc_spill 412 412 0
Testing should_pass/unit_tests/contract_multi_test 372 372 0
Testing should_pass/unit_tests/script_multi_test 96 96 0
Testing should_pass/unit_tests/nested_libs 124 124 0
Testing should_pass/unit_tests/stack_indexing_overflow 4140 4012 3.09178743961353
Testing should_pass/unit_tests/predicate_with_nested_libs 76 76 0
Testing should_pass/unit_tests/lib_multi_test 116 116 0
Testing should_pass/supertraits_via_self 36 36 0
Testing should_pass/test_contracts/storage_configurable 68 68 0
Testing should_pass/test_contracts/context_testing_contract 396 396 0
Testing should_pass/test_contracts/contract_with_type_aliases 172 172 0
Testing should_pass/test_contracts/basic_storage 11628 11820 -1.65118679050568
Testing should_pass/test_contracts/storage_access_contract 10916 10916 0
Testing should_pass/test_contracts/auth_testing_contract 76 76 0
Testing should_pass/test_contracts/nested_struct_args_contract 100 100 0
Testing should_pass/test_contracts/abi_with_tuples_contract 108 108 0
Testing should_pass/test_contracts/test_fuel_coin_contract 196 196 0
Testing should_pass/test_contracts/array_of_structs_contract 196 196 0
Testing should_pass/test_contracts/return_struct 304 304 0
Testing should_pass/test_contracts/abi_with_generic_types 192 192 0
Testing should_pass/test_contracts/balance_test_contract 84 84 0
Testing should_pass/test_contracts/multiple_impl 92 92 0
Testing should_pass/test_contracts/abi_with_same_name_types 112 112 0
Testing should_pass/test_contracts/issue_1512_repro 596 596 0
Testing should_pass/test_contracts/increment_contract 828 828 0
Testing should_pass/conditional_compilation/run 52 52 0
Testing should_pass/empty_fields_in_storage_struct 9872 10088 -2.18800648298217
Testing should_pass/payable_non_zero_coins 196 196 0
Testing should_pass/supertraits_for_abis 100 100 0
Testing should_pass/blanket_impl 52 52 0

@vaivaswatha
Copy link
Contributor Author

This was required previously, but after the IR refactoring (#4336), this is no longer required, and actually worsens things.

Fixes #4747. For the two tests mentioned there, (both based on https://github.com/hashcloak/fuel-crypto/) the compile time now comes down from

  1. 30m -> 16s
  2. 180m -> 31s

Also fixes two bugs uncovered:

  1. Bug in DCE - Fixes DCE eliminating ref mut storage. #4763. (1b512b8)
  2. Bug in interaction b/w asm gen and reg alloc spiller (7a40496).

The two tests here don't compile successfully on master anymore. So I compiled them with the compiler at the time of #4722 to compare the bytecode sizes then and now with this inliner fix.

  1. 2174240 bytes -> 347348 bytes
  2. 3590472 bytes -> 653096 bytes

@IGI-111 IGI-111 requested a review from a team July 21, 2023 02:39
@IGI-111 IGI-111 added the compiler: codegen Everything to do with IR->ASM, register allocation, etc. label Jul 21, 2023
@vaivaswatha vaivaswatha merged commit 5318edd into master Jul 21, 2023
@vaivaswatha vaivaswatha deleted the vaivaswatha/inliner_fix branch July 21, 2023 04:22
IGI-111 added a commit that referenced this pull request Aug 2, 2023
This reverts the inliner change that was done in #4823.

Without this, when sharing stack data across contract boundaries, we end
up with an illegal access.

---------

Co-authored-by: IGI-111 <igi-111@protonmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler: codegen Everything to do with IR->ASM, register allocation, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DCE eliminating ref mut storage. The inliner may be creating very huge functions
3 participants