From f80d685f453fa3dbbd1f2bc8f314c7172bb04101 Mon Sep 17 00:00:00 2001 From: Michael Haselberger Date: Wed, 9 Apr 2025 10:09:30 +0200 Subject: [PATCH 1/9] add fb_init calls to init fns --- src/lowering/initializers.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/lowering/initializers.rs b/src/lowering/initializers.rs index 6b30794814..98410dc79d 100644 --- a/src/lowering/initializers.rs +++ b/src/lowering/initializers.rs @@ -195,6 +195,22 @@ fn create_init_unit( }) .collect::>(); + if let Some(fbinit) = lowerer + .index + .find_method(container_name, "fb_init") + .and_then(|it| it.find_implementation(&lowerer.index)) + { + let base = create_member_reference("self", id_provider.clone(), None); + let op = create_member_reference( + &fbinit.get_call_name().rsplit_once('.').map(|(_, name)| name).unwrap(), + id_provider.clone(), + Some(base), + ); + let call_statement = + AstFactory::create_call_statement(op, None, id_provider.next_id(), location.clone()); + statements.push(call_statement); + } + let member_init_calls = lowerer .index .get_container_members(container_name) From 4617d1a0a3ba9a89719fd365be916397749a95ae Mon Sep 17 00:00:00 2001 From: Michael Haselberger Date: Wed, 9 Apr 2025 17:01:47 +0200 Subject: [PATCH 2/9] i hate this a lot --- ...n_different_locations_with_debug_info.snap | 11 + ...files__multiple_files_with_debug_info.snap | 11 + ...iles__multiple_source_files_generated.snap | 11 + compiler/plc_lowering/src/inheritance.rs | 24 +- src/codegen/tests/address_tests.rs | 20 + src/codegen/tests/code_gen_tests.rs | 67 +++ src/codegen/tests/debug_tests.rs | 19 +- ...l_is_not_added_as_external_subroutine.snap | 27 ++ ...g__implementation_added_as_subroutine.snap | 18 + ...on_function_pous_have_struct_as_param.snap | 18 + ...temp_variables_in_pous_added_as_local.snap | 18 + src/codegen/tests/directaccess_test.rs | 56 ++- src/codegen/tests/expression_tests.rs | 10 + .../complex_initializers.rs | 391 ++++++++++++++++++ .../global_initializers.rs | 30 +- ...lues_in_global_variables_out_of_order.snap | 24 ++ ..._class_struct_initialized_in_function.snap | 11 + ..._block_struct_initialized_in_function.snap | 24 ++ ..._is_initialized_with_type_initializer.snap | 11 + ...tial_constant_values_in_pou_variables.snap | 11 + ..._initial_values_in_function_block_pou.snap | 21 + ...lizers__initial_values_in_program_pou.snap | 11 + ..._for_struct_initialization_in_program.snap | 11 + ...izers__array_of_struct_initialization.snap | 11 + ...lizers__initial_values_in_fb_variable.snap | 24 ++ ...array_of_structs_are_zero_initialized.snap | 11 + src/codegen/tests/online_change_tests.rs | 42 +- src/codegen/tests/oop_tests.rs | 136 +++++- src/codegen/tests/oop_tests/debug_tests.rs | 171 +++++++- src/codegen/tests/parameters_tests.rs | 38 +- ...enerates_in_separate_global_variables.snap | 11 + ...sts__accessing_nested_array_in_struct.snap | 11 + ...e_gen_tests__accessing_nested_structs.snap | 11 + ...e_gen_tests__action_called_in_program.snap | 11 + ...sts__array_of_cast_int_type_generated.snap | 11 + ..._int_non_zero_negative_type_generated.snap | 11 + ..._array_of_int_non_zero_type_generated.snap | 11 + ...en_tests__array_of_int_type_generated.snap | 11 + ...ode_gen_tests__array_of_int_type_used.snap | 11 + ...ype_with_non_zero_negative_start_used.snap | 11 + ..._of_int_type_with_non_zero_start_used.snap | 11 + ...d_variable_declaration_is_initialized.snap | 11 + ...mber_of_another_struct_is_initialized.snap | 11 + ...__case_with_multiple_labels_statement.snap | 11 + ...gen_tests__case_with_ranges_statement.snap | 11 + ...s__casted_literals_bool_code_gen_test.snap | 11 + ..._tests__casted_literals_code_gen_test.snap | 11 + ...ts__casted_literals_hex_code_gen_test.snap | 11 + ...asted_literals_hex_ints_code_gen_test.snap | 11 + ...__casted_literals_lreal_code_gen_test.snap | 11 + ...s__casted_literals_real_code_gen_test.snap | 11 + ...__code_gen_tests__class_method_in_pou.snap | 11 + ...sts__code_gen_tests__complex_pointers.snap | 11 + ...ion_in_function_blocks_are_propagated.snap | 8 + ...anged_type_declaration_are_propagated.snap | 11 + ..._contants_in_case_statements_resolved.snap | 11 + ..._and_time_global_constants_initialize.snap | 11 + ...sts__code_gen_tests__date_comparisons.snap | 11 + ..._gen_tests__different_case_references.snap | 11 + ...lobal_variable_list_generates_nothing.snap | 11 + ...ram_with_name_generates_void_function.snap | 11 + ...pty_statements_dont_generate_anything.snap | 11 + ...num_members_can_be_used_in_asignments.snap | 11 + ...ests__enums_custom_type_are_generated.snap | 11 + ...__external_function_called_in_program.snap | 11 + ...global_variable_generates_as_external.snap | 11 + ...ternal_program_global_var_is_external.snap | 16 + ...n_tests__fb_method_called_as_function.snap | 8 + ...sts__code_gen_tests__fb_method_in_pou.snap | 21 + ..._gen_tests__fb_method_with_var_in_out.snap | 21 + ...ts__fb_method_with_var_input_defaults.snap | 21 + ...ode_gen_tests__for_statement_continue.snap | 11 + ...ts__code_gen_tests__for_statement_int.snap | 11 + ...s__code_gen_tests__for_statement_lint.snap | 11 + ...s__code_gen_tests__for_statement_sint.snap | 11 + ...en_tests__for_statement_with_continue.snap | 11 + ...de_gen_tests__for_statement_with_exit.snap | 11 + ..._statement_with_references_steps_test.snap | 11 + ..._tests__for_statement_with_steps_test.snap | 11 + ...sts__for_statement_without_steps_test.snap | 11 + ...n_tests__function_block_instance_call.snap | 21 + ...unction_block_qualified_instance_call.snap | 31 ++ ...on_call_with_same_name_as_return_type.snap | 11 + ...gen_tests__function_called_in_program.snap | 11 + ..._tests__function_called_when_shadowed.snap | 11 + ...on_with_local_temp_var_initialization.snap | 11 + ...ith_local_var_initialization_and_call.snap | 11 + ...ion_with_parameters_called_in_program.snap | 11 + ...with_two_parameters_called_in_program.snap | 11 + ...lobal_variable_reference_is_generated.snap | 11 + ...n_tests__if_elsif_else_generator_test.snap | 11 + ...ts__code_gen_tests__if_generator_test.snap | 11 + ...ts__if_with_expression_generator_test.snap | 11 + ...rray_size_from_local_scoped_constants.snap | 11 + ...method_codegen_with_initialized_input.snap | 8 + ...s__method_codegen_with_multiple_input.snap | 8 + ...ts__method_with_aggregate_return_type.snap | 8 + ...s__code_gen_tests__methods_var_output.snap | 11 + ...do_not_result_in_an_under_or_overflow.snap | 11 + ...code_gen_tests__multidim_array_access.snap | 11 + ...gen_tests__multidim_array_declaration.snap | 11 + ...__code_gen_tests__nested_array_access.snap | 11 + ...e_gen_tests__nested_array_cube_writes.snap | 11 + ...sted_array_cube_writes_negative_start.snap | 11 + ...e_gen_tests__nested_array_declaration.snap | 11 + ...ts__nested_function_called_in_program.snap | 11 + ...n_tests__order_var_and_var_temp_block.snap | 11 + ...__code_gen_tests__pass_inout_to_inout.snap | 31 ++ ...s__code_gen_tests__pointers_generated.snap | 11 + ..._gen_tests__program_called_in_program.snap | 21 + ...gen_tests__program_with_and_statement.snap | 11 + ...tes_void_function_and_struct_and_body.snap | 11 + ...tes_void_function_and_struct_and_body.snap | 11 + ..._program_with_casted_chars_assignment.snap | 11 + ...s__code_gen_tests__program_with_chars.snap | 11 + ...n_tests__program_with_date_assignment.snap | 11 + ..._assignment_whit_short_datatype_names.snap | 11 + ...arison_assignment_generates_correctly.snap | 11 + ...am_with_local_temp_var_initialization.snap | 21 + ...ts__program_with_long_date_assignment.snap | 11 + ...tes_void_function_and_struct_and_body.snap | 11 + ...tes_void_function_and_struct_and_body.snap | 11 + ..._gen_tests__program_with_or_statement.snap | 11 + ...en_tests__program_with_real_additions.snap | 11 + ...n_tests__program_with_real_assignment.snap | 11 + ...ts__program_with_real_cast_assignment.snap | 11 + ...gram_with_signed_combined_expressions.snap | 11 + ..._program_with_special_chars_in_string.snap | 11 + ...tests__program_with_string_assignment.snap | 11 + ...n_tests__program_with_time_assignment.snap | 11 + ...__program_with_time_of_day_assignment.snap | 11 + ...explicit_parameters_called_in_program.snap | 21 + ...with_two_parameters_called_in_program.snap | 21 + ...gram_with_var_inout_called_in_program.snap | 21 + ...rogram_with_var_out_called_in_program.snap | 21 + ..._with_var_out_called_mixed_in_program.snap | 21 + ...tes_void_function_and_struct_and_body.snap | 11 + ...tes_void_function_and_struct_and_body.snap | 11 + ...tes_void_function_and_struct_and_body.snap | 11 + ...tes_void_function_and_struct_and_body.snap | 11 + ...tes_void_function_and_struct_and_body.snap | 11 + ...tes_void_function_and_struct_and_body.snap | 11 + ...es_generates_void_function_and_struct.snap | 11 + ...gen_tests__program_with_xor_statement.snap | 11 + ...fied_action_from_fb_called_in_program.snap | 21 + ...fied_foreign_action_called_in_program.snap | 21 + ...lified_local_action_called_in_program.snap | 11 + ...ests__real_function_called_in_program.snap | 11 + ...e_gen_tests__reference_qualified_name.snap | 31 ++ ...nce_assignments_in_function_arguments.snap | 21 + ...sts__code_gen_tests__repeat_statement.snap | 11 + ...ts__returning_early_in_function_block.snap | 8 + ...e_gen_tests__simple_case_i8_statement.snap | 11 + ...code_gen_tests__simple_case_statement.snap | 11 + ...ts__structs_members_can_be_referenced.snap | 11 + ..._gen_tests__sub_range_check_functions.snap | 11 + ...nge_type_calls_check_function_missing.snap | 11 + ...ype_calls_check_function_on_assigment.snap | 11 + ...ariables_have_nano_seconds_resolution.snap | 11 + ...enerates_in_separate_global_variables.snap | 11 + ..._tests__typed_enums_are_used_properly.snap | 11 + ...ng_cast_statement_as_const_expression.snap | 11 + ..._using_const_expression_in_range_type.snap | 11 + ...s__using_global_consts_in_expressions.snap | 11 + ..._variable_with_same_name_as_data_type.snap | 11 + ...de_gen_tests__while_loop_with_if_exit.snap | 11 + ...ests__code_gen_tests__while_statement.snap | 11 + ...ests__while_with_expression_statement.snap | 11 + ...uctions_tests__compare_datetime_types.snap | 11 + ...uction_functions_with_different_types.snap | 11 + ...are_instructions_with_different_types.snap | 11 + ...s_tests__pointer_compare_instructions.snap | 11 + ...er_function_call_compare_instructions.snap | 11 + ...tests__assigning_const_array_variable.snap | 11 + ...ests__assigning_const_string_variable.snap | 11 + ...ests__assigning_const_struct_variable.snap | 11 + ...n_tests__access_string_via_byte_array.snap | 11 + ...ssion_tests__allowed_assignable_types.snap | 11 + ...sion_tests__builtin_function_call_adr.snap | 11 + ...ts__builtin_function_call_lower_bound.snap | 11 + ...ion_tests__builtin_function_call_move.snap | 11 + ...sion_tests__builtin_function_call_mux.snap | 11 + ...function_call_mux_with_aggregate_type.snap | 11 + ...sion_tests__builtin_function_call_ref.snap | 11 + ...sion_tests__builtin_function_call_sel.snap | 11 + ...iltin_function_call_sel_as_expression.snap | 11 + ...n_tests__builtin_function_call_sizeof.snap | 11 + ...ts__builtin_function_call_upper_bound.snap | 11 + ...uiltin_function_call_upper_bound_expr.snap | 11 + ...s__calling_strings_in_function_return.snap | 11 + ...ion_tests__cast_between_pointer_types.snap | 11 + ...ion_tests__compare_date_time_literals.snap | 11 + ...ression_tests__nested_call_statements.snap | 11 + ...expression_tests__pointer_arithmetics.snap | 11 + ...ts__pointer_arithmetics_function_call.snap | 11 + ..._tests__unary_expressions_can_be_real.snap | 11 + ...necessary_casts_between_pointer_types.snap | 11 + ...t_argument_literals_for_function_call.snap | 11 + ...argument_references_for_function_call.snap | 11 + ...ized_string_varargs_called_in_program.snap | 11 + ..._with_sized_varargs_called_in_program.snap | 11 + ...nction_with_varargs_called_in_program.snap | 11 + ...literal_string_argument_passed_by_ref.snap | 11 + ...tests__passing_a_string_to_a_function.snap | 11 + ...g_a_string_to_a_function_as_reference.snap | 11 + ...arguments_to_functions_by_ref_and_val.snap | 11 + ...n__tests__function_tests__simple_call.snap | 11 + ...on_tests__var_output_in_function_call.snap | 11 + ...t__any_real_function_called_with_ints.snap | 11 + ...unction_call_generates_real_type_call.snap | 11 + ...nerics_test__generic_output_parameter.snap | 11 + ...ccepts_empty_statement_as_input_param.snap | 21 + ...cepts_empty_statement_as_output_param.snap | 21 + ...ccepts_empty_statement_as_input_param.snap | 11 + ...cepts_empty_statement_as_output_param.snap | 11 + ...sts__function_all_parameters_assigned.snap | 11 + ...function_default_value_parameter_type.snap | 11 + ...ests__function_empty_inout_assignment.snap | 11 + ...ests__function_empty_input_assignment.snap | 11 + ...sts__function_empty_output_assignment.snap | 11 + ...empty_output_default_value_assignment.snap | 11 + ...ts__function_missing_inout_assignment.snap | 11 + ...ts__function_missing_input_assignment.snap | 11 + ...issing_input_default_value_assignment.snap | 11 + ...s__function_missing_output_assignment.snap | 11 + ...ssing_output_default_value_assignment.snap | 11 + ...unction_block_pointer_are_assigned_to.snap | 21 + ...ccepts_empty_statement_as_input_param.snap | 21 + ...cepts_empty_statement_as_output_param.snap | 21 + ...gram_all_parameters_assigned_explicit.snap | 21 + ...gram_all_parameters_assigned_implicit.snap | 21 + ...tests__program_empty_inout_assignment.snap | 21 + ...sts__program_missing_input_assignment.snap | 21 + ...ts__program_missing_output_assignment.snap | 21 + ...var_in_out_params_can_be_out_of_order.snap | 21 + ...taccess_generated_as_rsh_and_trunc_i1.snap | 11 + ...eaccess_generated_as_rsh_and_trunc_i8.snap | 11 + ...access_generated_as_rsh_and_trunc_i32.snap | 11 + ...t_codegen_test__nested_bitwise_access.snap | 11 + ...n_test__variable_based_bitwise_access.snap | 11 + ...access_generated_as_rsh_and_trunc_i16.snap | 11 + ..._casted_string_assignment_uses_memcpy.snap | 11 + ...g_generic_string_should_return_by_ref.snap | 11 + ...ts__function_returns_a_literal_string.snap | 11 + ...es_string_paramter_and_returns_string.snap | 11 + ...__string_tests__program_string_output.snap | 21 + ...program_with_casted_string_assignment.snap | 11 + ...__program_with_string_type_assignment.snap | 11 + ...ing_tests__string_function_parameters.snap | 11 + ...ariable_length_strings_can_be_created.snap | 11 + ...trings_using_constants_can_be_created.snap | 11 + ...ests__variable_string_assignment_test.snap | 11 + ...string_tests__vartmp_string_init_test.snap | 11 + ...ed_datatypes_respect_conversion_rules.snap | 11 + ...r_than_int_promote_the_second_operand.snap | 11 + ...es_smaller_than_dint_promoted_to_dint.snap | 11 + ...all_sint_expressions_fallback_to_dint.snap | 11 + ...at_and_double_mix_converted_to_double.snap | 11 + ...m_test__float_assigned_to_int_is_cast.snap | 11 + ...t__float_assinged_to_double_to_double.snap | 11 + ...m_test__int_assigned_to_float_is_cast.snap | 11 + ...an_byte_promoted_on_compare_statement.snap | 11 + ...bigger_than_float_converted_to_double.snap | 11 + ..._or_equal_to_float_converted_to_float.snap | 11 + ...ariadic_functions_without_declaration.snap | 11 + ...es_smaller_than_dint_promoted_to_dint.snap | 11 + src/lowering.rs | 44 +- src/lowering/initializers.rs | 138 ++++++- .../tests/resolve_and_lower_init_functions.rs | 28 +- src/tests/adr/arrays_adr.rs | 20 + src/tests/adr/enum_adr.rs | 14 +- src/tests/adr/initializer_functions_adr.rs | 75 +++- src/tests/adr/pou_adr.rs | 119 +++++- src/tests/adr/strings_adr.rs | 28 +- src/tests/adr/structs_adr.rs | 42 +- ...__integration__cfc__ir__actions_debug.snap | 9 + ...egration__cfc__ir__conditional_return.snap | 8 + ...r__conditional_return_evaluating_true.snap | 8 + ...tional_return_evaluating_true_negated.snap | 8 + ...sts__integration__cfc__ir__jump_debug.snap | 9 + ...tegration__cfc__ir__sink_source_debug.snap | 9 + 281 files changed, 4637 insertions(+), 113 deletions(-) diff --git a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_in_different_locations_with_debug_info.snap b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_in_different_locations_with_debug_info.snap index 002a509454..869c5fe769 100644 --- a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_in_different_locations_with_debug_info.snap +++ b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_in_different_locations_with_debug_info.snap @@ -1,6 +1,7 @@ --- source: compiler/plc_driver/./src/tests/multi_files.rs expression: "results.join(\"\\n\")" +snapshot_kind: text --- ; ModuleID = 'app/file1.st' source_filename = "app/file1.st" @@ -105,6 +106,13 @@ entry: declare void @mainProg(%mainProg*) +define void @__user_init_mainProg(%mainProg* %0) { +entry: + %self = alloca %mainProg*, align 8 + store %mainProg* %0, %mainProg** %self, align 8 + ret void +} + ; ModuleID = '__init___TestProject' source_filename = "__init___TestProject" @@ -116,9 +124,12 @@ source_filename = "__init___TestProject" define void @__init___TestProject() { entry: call void @__init_mainprog(%mainProg* @mainProg_instance) + call void @__user_init_mainProg(%mainProg* @mainProg_instance) ret void } declare void @__init_mainprog(%mainProg*) declare void @mainProg(%mainProg*) + +declare void @__user_init_mainProg(%mainProg*) diff --git a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_with_debug_info.snap b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_with_debug_info.snap index ba91c211f7..7fb53f01be 100644 --- a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_with_debug_info.snap +++ b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_with_debug_info.snap @@ -1,6 +1,7 @@ --- source: compiler/plc_driver/./src/tests/multi_files.rs expression: "results.join(\"\\n\")" +snapshot_kind: text --- ; ModuleID = 'file1.st' source_filename = "file1.st" @@ -105,6 +106,13 @@ entry: declare void @mainProg(%mainProg*) +define void @__user_init_mainProg(%mainProg* %0) { +entry: + %self = alloca %mainProg*, align 8 + store %mainProg* %0, %mainProg** %self, align 8 + ret void +} + ; ModuleID = '__init___TestProject' source_filename = "__init___TestProject" @@ -116,9 +124,12 @@ source_filename = "__init___TestProject" define void @__init___TestProject() { entry: call void @__init_mainprog(%mainProg* @mainProg_instance) + call void @__user_init_mainProg(%mainProg* @mainProg_instance) ret void } declare void @__init_mainprog(%mainProg*) declare void @mainProg(%mainProg*) + +declare void @__user_init_mainProg(%mainProg*) diff --git a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_source_files_generated.snap b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_source_files_generated.snap index aca0e9ee64..ec0b04ae0a 100644 --- a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_source_files_generated.snap +++ b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_source_files_generated.snap @@ -1,6 +1,7 @@ --- source: compiler/plc_driver/./src/tests/multi_files.rs expression: "results.join(\"\\n\")" +snapshot_kind: text --- ; ModuleID = 'external_file1.st' source_filename = "external_file1.st" @@ -48,6 +49,13 @@ entry: declare void @mainProg(%mainProg*) +define void @__user_init_mainProg(%mainProg* %0) { +entry: + %self = alloca %mainProg*, align 8 + store %mainProg* %0, %mainProg** %self, align 8 + ret void +} + ; ModuleID = '__init___TestProject' source_filename = "__init___TestProject" @@ -59,9 +67,12 @@ source_filename = "__init___TestProject" define void @__init___TestProject() { entry: call void @__init_mainprog(%mainProg* @mainProg_instance) + call void @__user_init_mainProg(%mainProg* @mainProg_instance) ret void } declare void @__init_mainprog(%mainProg*) declare void @mainProg(%mainProg*) + +declare void @__user_init_mainProg(%mainProg*) diff --git a/compiler/plc_lowering/src/inheritance.rs b/compiler/plc_lowering/src/inheritance.rs index 424c071575..1821cc875e 100644 --- a/compiler/plc_lowering/src/inheritance.rs +++ b/compiler/plc_lowering/src/inheritance.rs @@ -1792,7 +1792,7 @@ mod units_tests { let (_, project) = parse_and_annotate("test", vec![src]).unwrap(); let unit = &project.units[0].get_unit().implementations[3]; - assert_debug_snapshot!(unit, @r###" + assert_debug_snapshot!(unit, @r#" Implementation { name: "main", type_name: "main", @@ -1819,6 +1819,26 @@ mod units_tests { }, ), }, + CallStatement { + operator: ReferenceExpr { + kind: Member( + Identifier { + name: "__user_init_child", + }, + ), + base: None, + }, + parameters: Some( + ReferenceExpr { + kind: Member( + Identifier { + name: "fb", + }, + ), + base: None, + }, + ), + }, Assignment { left: ReferenceExpr { kind: Deref, @@ -1980,7 +2000,7 @@ mod units_tests { generic: false, access: None, } - "###) + "#) } #[test] diff --git a/src/codegen/tests/address_tests.rs b/src/codegen/tests/address_tests.rs index 13ce8f84ac..214a293589 100644 --- a/src/codegen/tests/address_tests.rs +++ b/src/codegen/tests/address_tests.rs @@ -118,6 +118,13 @@ fn address_variable_used_with_symbolic_name() { } declare void @mainProg(%mainProg*) + + define void @__user_init_mainProg(%mainProg* %0) { + entry: + %self = alloca %mainProg*, align 8 + store %mainProg* %0, %mainProg** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -134,12 +141,15 @@ fn address_variable_used_with_symbolic_name() { store i8* @__PI_1_2_3_4, i8** @foo, align 8 store i8* @__PI_1_2_3_4, i8** @baz, align 8 call void @__init_mainprog(%mainProg* @mainProg_instance) + call void @__user_init_mainProg(%mainProg* @mainProg_instance) ret void } declare void @__init_mainprog(%mainProg*) declare void @mainProg(%mainProg*) + + declare void @__user_init_mainProg(%mainProg*) "#); } @@ -195,6 +205,13 @@ fn address_used_in_body() { } declare void @mainProg(%mainProg*) + + define void @__user_init_mainProg(%mainProg* %0) { + entry: + %self = alloca %mainProg*, align 8 + store %mainProg* %0, %mainProg** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -212,11 +229,14 @@ fn address_used_in_body() { store i8* @__PI_1_2_3_4, i8** @foo, align 8 store i8* @__PI_1_2_3_5, i8** @baz, align 8 call void @__init_mainprog(%mainProg* @mainProg_instance) + call void @__user_init_mainProg(%mainProg* @mainProg_instance) ret void } declare void @__init_mainprog(%mainProg*) declare void @mainProg(%mainProg*) + + declare void @__user_init_mainProg(%mainProg*) "#); } diff --git a/src/codegen/tests/code_gen_tests.rs b/src/codegen/tests/code_gen_tests.rs index 19d32096cd..ebaeb24686 100644 --- a/src/codegen/tests/code_gen_tests.rs +++ b/src/codegen/tests/code_gen_tests.rs @@ -1145,6 +1145,7 @@ fn fb_method_called_locally() { call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 bitcast (%foo* @__foo__init to i8*), i64 ptrtoint (%foo* getelementptr (%foo, %foo* null, i32 1) to i64), i1 false) store i32 0, i32* %x, align 4 call void @__init_foo(%foo* %fb) + call void @__user_init_foo(%foo* %fb) %call = call i32 @foo.addToBar(%foo* %fb, i16 3) store i32 %call, i32* %x, align 4 ret void @@ -1152,6 +1153,8 @@ fn fb_method_called_locally() { declare void @__init_foo(%foo*) + declare void @__user_init_foo(%foo*) + ; Function Attrs: argmemonly nofree nounwind willreturn declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0 @@ -1171,6 +1174,13 @@ fn fb_method_called_locally() { } declare void @foo(%foo*) + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -1257,6 +1267,7 @@ fn fb_local_method_var_shadows_parent_var() { call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 bitcast (%foo* @__foo__init to i8*), i64 ptrtoint (%foo* getelementptr (%foo, %foo* null, i32 1) to i64), i1 false) store i32 0, i32* %x, align 4 call void @__init_foo(%foo* %fb) + call void @__user_init_foo(%foo* %fb) %call = call i32 @foo.addToBar(%foo* %fb, i16 3) store i32 %call, i32* %x, align 4 ret void @@ -1264,6 +1275,8 @@ fn fb_local_method_var_shadows_parent_var() { declare void @__init_foo(%foo*) + declare void @__user_init_foo(%foo*) + ; Function Attrs: argmemonly nofree nounwind willreturn declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0 @@ -1283,6 +1296,13 @@ fn fb_local_method_var_shadows_parent_var() { } declare void @foo(%foo*) + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -1379,6 +1399,13 @@ fn prog_method_called_locally() { } declare void @foo(%foo*) + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -1390,12 +1417,15 @@ fn prog_method_called_locally() { define void @__init___testproject() { entry: call void @__init_foo(%foo* @foo_instance) + call void @__user_init_foo(%foo* @foo_instance) ret void } declare void @__init_foo(%foo*) declare void @foo(%foo*) + + declare void @__user_init_foo(%foo*) "#) } @@ -1487,6 +1517,13 @@ fn prog_local_method_var_shadows_parent_var() { } declare void @foo(%foo*) + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -1498,12 +1535,15 @@ fn prog_local_method_var_shadows_parent_var() { define void @__init___testproject() { entry: call void @__init_foo(%foo* @foo_instance) + call void @__user_init_foo(%foo* @foo_instance) ret void } declare void @__init_foo(%foo*) declare void @foo(%foo*) + + declare void @__user_init_foo(%foo*) "#) } @@ -1780,6 +1820,13 @@ fn for_statement_with_binary_expressions() { } declare void @prg(%prg*) + + define void @__user_init_prg(%prg* %0) { + entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -1791,12 +1838,15 @@ fn for_statement_with_binary_expressions() { define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + + declare void @__user_init_prg(%prg*) "#); } @@ -4177,6 +4227,20 @@ fn variables_in_var_external_block_are_not_generated() { } declare void @qux(%qux*) + + define void @__user_init_bar(%bar* %0) { + entry: + %self = alloca %bar*, align 8 + store %bar* %0, %bar** %self, align 8 + ret void + } + + define void @__user_init_baz(%baz* %0) { + entry: + %self = alloca %baz*, align 8 + store %baz* %0, %baz** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -4188,12 +4252,15 @@ fn variables_in_var_external_block_are_not_generated() { define void @__init___testproject() { entry: call void @__init_baz(%baz* @baz_instance) + call void @__user_init_baz(%baz* @baz_instance) ret void } declare void @__init_baz(%baz*) declare void @baz(%baz*) + + declare void @__user_init_baz(%baz*) "#); } diff --git a/src/codegen/tests/debug_tests.rs b/src/codegen/tests/debug_tests.rs index 0fa333924d..97d2fc701e 100644 --- a/src/codegen/tests/debug_tests.rs +++ b/src/codegen/tests/debug_tests.rs @@ -349,7 +349,7 @@ fn dbg_declare_has_valid_metadata_references_for_methods() { ", ); - assert_snapshot!(codegen, @r###" + assert_snapshot!(codegen, @r#" ; ModuleID = '' source_filename = "" @@ -380,6 +380,13 @@ fn dbg_declare_has_valid_metadata_references_for_methods() { ret void } + define void @__user_init_fb(%fb* %0) { + entry: + %self = alloca %fb*, align 8 + store %fb* %0, %fb** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void @@ -407,7 +414,7 @@ fn dbg_declare_has_valid_metadata_references_for_methods() { !14 = distinct !DISubprogram(name: "fb.foo", linkageName: "fb.foo", scope: !9, file: !2, line: 3, type: !10, scopeLine: 4, flags: DIFlagPublic, spFlags: DISPFlagDefinition, unit: !7, retainedNodes: !4) !15 = !DILocalVariable(name: "fb", scope: !14, file: !2, line: 4, type: !3) !16 = !DILocation(line: 4, column: 8, scope: !14) - "###); + "#); } #[test] @@ -487,9 +494,17 @@ fn action_with_var_temp() { ret void } + define void @__user_init_PLC_PRG(%PLC_PRG* %0) { + entry: + %self = alloca %PLC_PRG*, align 8 + store %PLC_PRG* %0, %PLC_PRG** %self, align 8 + ret void + } + define void @__init___Test() { entry: call void @__init_plc_prg(%PLC_PRG* @PLC_PRG_instance) + call void @__user_init_PLC_PRG(%PLC_PRG* @PLC_PRG_instance) ret void } diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__external_impl_is_not_added_as_external_subroutine.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__external_impl_is_not_added_as_external_subroutine.snap index 53a2ca6cf3..e8c21bbfb2 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__external_impl_is_not_added_as_external_subroutine.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__external_impl_is_not_added_as_external_subroutine.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/debug_tests/expression_debugging.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -33,3 +34,29 @@ declare void @myFb(%myFb*) !10 = distinct !DICompileUnit(language: DW_LANG_C, file: !11, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !12, splitDebugInlining: false) !11 = !DIFile(filename: "", directory: "src") !12 = !{!0, !5} +; ModuleID = '__initializers' +source_filename = "__initializers" + +%myFb = type {} +%myPrg = type {} + +@__myFb__init = external global %myFb +@myPrg_instance = external global %myPrg + +define void @__user_init_myFb(%myFb* %0) { +entry: + %self = alloca %myFb*, align 8 + store %myFb* %0, %myFb** %self, align 8 + ret void +} + +declare void @myFb(%myFb*) + +define void @__user_init_myPrg(%myPrg* %0) { +entry: + %self = alloca %myPrg*, align 8 + store %myPrg* %0, %myPrg** %self, align 8 + ret void +} + +declare void @myPrg(%myPrg*) diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__implementation_added_as_subroutine.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__implementation_added_as_subroutine.snap index fcd3a5885d..7d62adfa4c 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__implementation_added_as_subroutine.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__implementation_added_as_subroutine.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/debug_tests/expression_debugging.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -96,6 +97,20 @@ entry: } declare void @myFb(%myFb*) + +define void @__user_init_myFb(%myFb* %0) { +entry: + %self = alloca %myFb*, align 8 + store %myFb* %0, %myFb** %self, align 8 + ret void +} + +define void @__user_init_myPrg(%myPrg* %0) { +entry: + %self = alloca %myPrg*, align 8 + store %myPrg* %0, %myPrg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -107,9 +122,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_myprg(%myPrg* @myPrg_instance) + call void @__user_init_myPrg(%myPrg* @myPrg_instance) ret void } declare void @__init_myprg(%myPrg*) declare void @myPrg(%myPrg*) + +declare void @__user_init_myPrg(%myPrg*) diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__non_function_pous_have_struct_as_param.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__non_function_pous_have_struct_as_param.snap index c6a3c58345..07dee4a1b2 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__non_function_pous_have_struct_as_param.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__non_function_pous_have_struct_as_param.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/debug_tests/expression_debugging.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -95,6 +96,20 @@ entry: } declare void @fb(%fb*) + +define void @__user_init_fb(%fb* %0) { +entry: + %self = alloca %fb*, align 8 + store %fb* %0, %fb** %self, align 8 + ret void +} + +define void @__user_init_myProg(%myProg* %0) { +entry: + %self = alloca %myProg*, align 8 + store %myProg* %0, %myProg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -106,9 +121,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_myprog(%myProg* @myProg_instance) + call void @__user_init_myProg(%myProg* @myProg_instance) ret void } declare void @__init_myprog(%myProg*) declare void @myProg(%myProg*) + +declare void @__user_init_myProg(%myProg*) diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__var_and_vartemp_variables_in_pous_added_as_local.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__var_and_vartemp_variables_in_pous_added_as_local.snap index 81aaf49763..c597898d84 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__var_and_vartemp_variables_in_pous_added_as_local.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__var_and_vartemp_variables_in_pous_added_as_local.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/debug_tests/expression_debugging.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -141,6 +142,20 @@ entry: } declare void @myFb(%myFb*) + +define void @__user_init_myFb(%myFb* %0) { +entry: + %self = alloca %myFb*, align 8 + store %myFb* %0, %myFb** %self, align 8 + ret void +} + +define void @__user_init_myPrg(%myPrg* %0) { +entry: + %self = alloca %myPrg*, align 8 + store %myPrg* %0, %myPrg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -152,9 +167,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_myprg(%myPrg* @myPrg_instance) + call void @__user_init_myPrg(%myPrg* @myPrg_instance) ret void } declare void @__init_myprg(%myPrg*) declare void @myPrg(%myPrg*) + +declare void @__user_init_myPrg(%myPrg*) diff --git a/src/codegen/tests/directaccess_test.rs b/src/codegen/tests/directaccess_test.rs index 7e0bfb1bfa..9d8da8060f 100644 --- a/src/codegen/tests/directaccess_test.rs +++ b/src/codegen/tests/directaccess_test.rs @@ -141,7 +141,7 @@ fn direct_acess_in_output_assignment_implicit_explicit_and_mixed() { ", ); - assert_snapshot!(ir, @r###" + assert_snapshot!(ir, @r#" ; ModuleID = '' source_filename = "" @@ -166,6 +166,7 @@ fn direct_acess_in_output_assignment_implicit_explicit_and_mixed() { call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 getelementptr inbounds (%FOO, %FOO* @__FOO__init, i32 0, i32 0), i64 ptrtoint (%FOO* getelementptr (%FOO, %FOO* null, i32 1) to i64), i1 false) store i32 0, i32* %main, align 4 call void @__init_foo(%FOO* %f) + call void @__user_init_FOO(%FOO* %f) %1 = getelementptr inbounds %FOO, %FOO* %f, i32 0, i32 0 %load_error_bits = load i8, i8* %error_bits, align 1 %shift = lshr i8 %load_error_bits, 0 @@ -217,6 +218,8 @@ fn direct_acess_in_output_assignment_implicit_explicit_and_mixed() { declare void @__init_foo(%FOO*) + declare void @__user_init_FOO(%FOO*) + ; Function Attrs: argmemonly nofree nounwind willreturn declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0 @@ -236,6 +239,13 @@ fn direct_acess_in_output_assignment_implicit_explicit_and_mixed() { } declare void @FOO(%FOO*) + + define void @__user_init_FOO(%FOO* %0) { + entry: + %self = alloca %FOO*, align 8 + store %FOO* %0, %FOO** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -245,7 +255,7 @@ fn direct_acess_in_output_assignment_implicit_explicit_and_mixed() { entry: ret void } - "###); + "#); } #[test] @@ -269,7 +279,7 @@ fn direct_acess_in_output_assignment_with_simple_expression() { ", ); - assert_snapshot!(ir, @r###" + assert_snapshot!(ir, @r#" ; ModuleID = '' source_filename = "" @@ -293,6 +303,7 @@ fn direct_acess_in_output_assignment_with_simple_expression() { call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 getelementptr inbounds (%FOO, %FOO* @__FOO__init, i32 0, i32 0), i64 ptrtoint (%FOO* getelementptr (%FOO, %FOO* null, i32 1) to i64), i1 false) store i32 0, i32* %main, align 4 call void @__init_foo(%FOO* %f) + call void @__user_init_FOO(%FOO* %f) call void @FOO(%FOO* %f) %1 = getelementptr inbounds %FOO, %FOO* %f, i32 0, i32 0 %2 = load i8, i8* %error_bits, align 1 @@ -307,6 +318,8 @@ fn direct_acess_in_output_assignment_with_simple_expression() { declare void @__init_foo(%FOO*) + declare void @__user_init_FOO(%FOO*) + ; Function Attrs: argmemonly nofree nounwind willreturn declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0 @@ -326,6 +339,13 @@ fn direct_acess_in_output_assignment_with_simple_expression() { } declare void @FOO(%FOO*) + + define void @__user_init_FOO(%FOO* %0) { + entry: + %self = alloca %FOO*, align 8 + store %FOO* %0, %FOO** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -335,7 +355,7 @@ fn direct_acess_in_output_assignment_with_simple_expression() { entry: ret void } - "###); + "#); } #[test] @@ -359,7 +379,7 @@ fn direct_acess_in_output_assignment_with_simple_expression_implicit() { ", ); - assert_snapshot!(ir, @r###" + assert_snapshot!(ir, @r#" ; ModuleID = '' source_filename = "" @@ -383,6 +403,7 @@ fn direct_acess_in_output_assignment_with_simple_expression_implicit() { call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 getelementptr inbounds (%FOO, %FOO* @__FOO__init, i32 0, i32 0), i64 ptrtoint (%FOO* getelementptr (%FOO, %FOO* null, i32 1) to i64), i1 false) store i32 0, i32* %main, align 4 call void @__init_foo(%FOO* %f) + call void @__user_init_FOO(%FOO* %f) call void @FOO(%FOO* %f) %1 = getelementptr inbounds %FOO, %FOO* %f, i32 0, i32 0 %2 = load i8, i8* %error_bits, align 1 @@ -397,6 +418,8 @@ fn direct_acess_in_output_assignment_with_simple_expression_implicit() { declare void @__init_foo(%FOO*) + declare void @__user_init_FOO(%FOO*) + ; Function Attrs: argmemonly nofree nounwind willreturn declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0 @@ -416,6 +439,13 @@ fn direct_acess_in_output_assignment_with_simple_expression_implicit() { } declare void @FOO(%FOO*) + + define void @__user_init_FOO(%FOO* %0) { + entry: + %self = alloca %FOO*, align 8 + store %FOO* %0, %FOO** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -425,7 +455,7 @@ fn direct_acess_in_output_assignment_with_simple_expression_implicit() { entry: ret void } - "###); + "#); } #[test] @@ -458,7 +488,7 @@ fn direct_acess_in_output_assignment_with_complexe_expression() { ", ); - assert_snapshot!(ir, @r###" + assert_snapshot!(ir, @r#" ; ModuleID = '' source_filename = "" @@ -488,6 +518,7 @@ fn direct_acess_in_output_assignment_with_complexe_expression() { store i32 0, i32* %main, align 4 call void @__init_foo_struct(%foo_struct* %foo) call void @__init_quux(%QUUX* %f) + call void @__user_init_QUUX(%QUUX* %f) call void @QUUX(%QUUX* %f) %bar = getelementptr inbounds %foo_struct, %foo_struct* %foo, i32 0, i32 0 %baz = getelementptr inbounds %bar_struct, %bar_struct* %bar, i32 0, i32 0 @@ -518,6 +549,8 @@ fn direct_acess_in_output_assignment_with_complexe_expression() { declare void @__init_quux(%QUUX*) + declare void @__user_init_QUUX(%QUUX*) + ; Function Attrs: argmemonly nofree nounwind willreturn declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0 @@ -558,6 +591,13 @@ fn direct_acess_in_output_assignment_with_complexe_expression() { } declare void @QUUX(%QUUX*) + + define void @__user_init_QUUX(%QUUX* %0) { + entry: + %self = alloca %QUUX*, align 8 + store %QUUX* %0, %QUUX** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -567,5 +607,5 @@ fn direct_acess_in_output_assignment_with_complexe_expression() { entry: ret void } - "###); + "#); } diff --git a/src/codegen/tests/expression_tests.rs b/src/codegen/tests/expression_tests.rs index cba25e5c99..0fa5e0638a 100644 --- a/src/codegen/tests/expression_tests.rs +++ b/src/codegen/tests/expression_tests.rs @@ -812,6 +812,13 @@ fn global_namespace_operator() { } declare void @main(%main*) + + define void @__user_init_main(%main* %0) { + entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -823,11 +830,14 @@ fn global_namespace_operator() { define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + + declare void @__user_init_main(%main*) "#); } diff --git a/src/codegen/tests/initialization_test/complex_initializers.rs b/src/codegen/tests/initialization_test/complex_initializers.rs index b9b7d9f98e..205abba2da 100644 --- a/src/codegen/tests/initialization_test/complex_initializers.rs +++ b/src/codegen/tests/initialization_test/complex_initializers.rs @@ -147,6 +147,13 @@ fn init_functions_generated_for_programs() { } declare void @PLC_PRG(%PLC_PRG*) + + define void @__user_init_PLC_PRG(%PLC_PRG* %0) { + entry: + %self = alloca %PLC_PRG*, align 8 + store %PLC_PRG* %0, %PLC_PRG** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -158,12 +165,15 @@ fn init_functions_generated_for_programs() { define void @__init___testproject() { entry: call void @__init_plc_prg(%PLC_PRG* @PLC_PRG_instance) + call void @__user_init_PLC_PRG(%PLC_PRG* @PLC_PRG_instance) ret void } declare void @__init_plc_prg(%PLC_PRG*) declare void @PLC_PRG(%PLC_PRG*) + + declare void @__user_init_PLC_PRG(%PLC_PRG*) "#); } @@ -216,6 +226,13 @@ fn init_functions_work_with_adr() { } declare void @PLC_PRG(%PLC_PRG*) + + define void @__user_init_PLC_PRG(%PLC_PRG* %0) { + entry: + %self = alloca %PLC_PRG*, align 8 + store %PLC_PRG* %0, %PLC_PRG** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -227,12 +244,15 @@ fn init_functions_work_with_adr() { define void @__init___testproject() { entry: call void @__init_plc_prg(%PLC_PRG* @PLC_PRG_instance) + call void @__user_init_PLC_PRG(%PLC_PRG* @PLC_PRG_instance) ret void } declare void @__init_plc_prg(%PLC_PRG*) declare void @PLC_PRG(%PLC_PRG*) + + declare void @__user_init_PLC_PRG(%PLC_PRG*) "#); } @@ -285,6 +305,13 @@ fn init_functions_generated_for_function_blocks() { } declare void @foo(%foo*) + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -515,6 +542,53 @@ fn nested_initializer_pous() { } declare void @sideProg(%sideProg*) + + define void @__user_init_sideProg(%sideProg* %0) { + entry: + %self = alloca %sideProg*, align 8 + store %sideProg* %0, %sideProg** %self, align 8 + %deref = load %sideProg*, %sideProg** %self, align 8 + %f = getelementptr inbounds %sideProg, %sideProg* %deref, i32 0, i32 1 + call void @__user_init_foo(%foo* %f) + ret void + } + + define void @__user_init_baz(%baz* %0) { + entry: + %self = alloca %baz*, align 8 + store %baz* %0, %baz** %self, align 8 + ret void + } + + define void @__user_init_bar(%bar* %0) { + entry: + %self = alloca %bar*, align 8 + store %bar* %0, %bar** %self, align 8 + %deref = load %bar*, %bar** %self, align 8 + %b = getelementptr inbounds %bar, %bar* %deref, i32 0, i32 0 + call void @__user_init_baz(%baz* %b) + ret void + } + + define void @__user_init_mainProg(%mainProg* %0) { + entry: + %self = alloca %mainProg*, align 8 + store %mainProg* %0, %mainProg** %self, align 8 + %deref = load %mainProg*, %mainProg** %self, align 8 + %f = getelementptr inbounds %mainProg, %mainProg* %deref, i32 0, i32 1 + call void @__user_init_foo(%foo* %f) + ret void + } + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + %deref = load %foo*, %foo** %self, align 8 + %b = getelementptr inbounds %foo, %foo* %deref, i32 0, i32 1 + call void @__user_init_bar(%bar* %b) + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -535,6 +609,8 @@ fn nested_initializer_pous() { entry: call void @__init_mainprog(%mainProg* @mainProg_instance) call void @__init_sideprog(%sideProg* @sideProg_instance) + call void @__user_init_mainProg(%mainProg* @mainProg_instance) + call void @__user_init_sideProg(%sideProg* @sideProg_instance) ret void } @@ -551,6 +627,10 @@ fn nested_initializer_pous() { declare void @__init_sideprog(%sideProg*) declare void @sideProg(%sideProg*) + + declare void @__user_init_mainProg(%mainProg*) + + declare void @__user_init_sideProg(%sideProg*) "#); } @@ -731,6 +811,13 @@ fn struct_types() { } declare void @prog(%prog*) + + define void @__user_init_prog(%prog* %0) { + entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -744,12 +831,15 @@ fn struct_types() { define void @__init___testproject() { entry: call void @__init_prog(%prog* @prog_instance) + call void @__user_init_prog(%prog* @prog_instance) ret void } declare void @__init_prog(%prog*) declare void @prog(%prog*) + + declare void @__user_init_prog(%prog*) "#); } @@ -871,6 +961,20 @@ fn stateful_pous_methods_and_structs_get_init_functions() { } declare void @cl(%cl*) + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } + + define void @__user_init_prog(%prog* %0) { + entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -882,12 +986,15 @@ fn stateful_pous_methods_and_structs_get_init_functions() { define void @__init___testproject() { entry: call void @__init_prog(%prog* @prog_instance) + call void @__user_init_prog(%prog* @prog_instance) ret void } declare void @__init_prog(%prog*) declare void @prog(%prog*) + + declare void @__user_init_prog(%prog*) "#); } @@ -965,6 +1072,20 @@ fn global_instance() { } declare void @prog(%prog*) + + define void @__user_init_prog(%prog* %0) { + entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + ret void + } + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -980,6 +1101,8 @@ fn global_instance() { entry: call void @__init_prog(%prog* @prog_instance) call void @__init_foo(%foo* @fb) + call void @__user_init_prog(%prog* @prog_instance) + call void @__user_init_foo(%foo* @fb) ret void } @@ -990,6 +1113,10 @@ fn global_instance() { declare void @__init_foo(%foo*) declare void @foo(%foo*) + + declare void @__user_init_prog(%prog*) + + declare void @__user_init_foo(%foo*) "#); } @@ -1076,6 +1203,23 @@ fn aliased_types() { } declare void @prog(%prog*) + + define void @__user_init_prog(%prog* %0) { + entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + %deref = load %prog*, %prog** %self, align 8 + %fb = getelementptr inbounds %prog, %prog* %deref, i32 0, i32 0 + call void @__user_init_foo(%foo* %fb) + ret void + } + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -1091,6 +1235,8 @@ fn aliased_types() { entry: call void @__init_prog(%prog* @prog_instance) call void @__init_foo(%foo* @global_alias) + call void @__user_init_prog(%prog* @prog_instance) + call void @__user_init_foo(%foo* @global_alias) ret void } @@ -1101,6 +1247,10 @@ fn aliased_types() { declare void @foo(%foo*) declare void @__init_foo(%foo*) + + declare void @__user_init_prog(%prog*) + + declare void @__user_init_foo(%foo*) "#); } @@ -1243,6 +1393,26 @@ fn var_config_aliased_variables_initialized() { } declare void @prog(%prog*) + + define void @__user_init_FB(%FB* %0) { + entry: + %self = alloca %FB*, align 8 + store %FB* %0, %FB** %self, align 8 + ret void + } + + define void @__user_init_prog(%prog* %0) { + entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + %deref = load %prog*, %prog** %self, align 8 + %instance1 = getelementptr inbounds %prog, %prog* %deref, i32 0, i32 0 + call void @__user_init_FB(%FB* %instance1) + %deref1 = load %prog*, %prog** %self, align 8 + %instance2 = getelementptr inbounds %prog, %prog* %deref1, i32 0, i32 1 + call void @__user_init_FB(%FB* %instance2) + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -1259,6 +1429,7 @@ fn var_config_aliased_variables_initialized() { entry: call void @__init_prog(%prog* @prog_instance) call void @__init___var_config() + call void @__user_init_prog(%prog* @prog_instance) ret void } @@ -1274,6 +1445,8 @@ fn var_config_aliased_variables_initialized() { declare void @prog(%prog*) declare void @FB(%FB*) + + declare void @__user_init_prog(%prog*) "#); } @@ -1334,6 +1507,13 @@ fn var_external_blocks_are_ignored_in_init_functions() { } declare void @foo(%foo*) + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -1410,6 +1590,13 @@ fn ref_to_local_member() { } declare void @foo(%foo*) + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -1488,6 +1675,13 @@ fn ref_to_local_member_shadows_global() { } declare void @foo(%foo*) + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -1554,6 +1748,13 @@ fn temporary_variable_ref_to_local_member() { } declare void @foo(%foo*) + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -1671,6 +1872,13 @@ fn initializing_method_variables_with_refs() { } declare void @foo(%foo*) + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -1736,6 +1944,13 @@ fn initializing_method_variables_with_refs_referencing_parent_pou_variable() { } declare void @foo(%foo*) + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -1800,6 +2015,13 @@ fn initializing_method_variables_with_refs_referencing_global_variable() { } declare void @foo(%foo*) + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -1867,6 +2089,13 @@ fn initializing_method_variables_with_refs_shadowing() { } declare void @foo(%foo*) + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -1929,6 +2158,13 @@ fn initializing_method_variables_with_alias() { } declare void @foo(%foo*) + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -1991,6 +2227,13 @@ fn initializing_method_variables_with_reference_to() { } declare void @foo(%foo*) + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -2051,11 +2294,14 @@ fn methods_call_init_functions_for_their_members() { %1 = bitcast %foo* %fb to i8* call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %1, i8* align 1 bitcast (%foo* @__foo__init to i8*), i64 ptrtoint (%foo* getelementptr (%foo, %foo* null, i32 1) to i64), i1 false) call void @__init_foo(%foo* %fb) + call void @__user_init_foo(%foo* %fb) ret void } declare void @__init_foo(%foo*) + declare void @__user_init_foo(%foo*) + ; Function Attrs: argmemonly nofree nounwind willreturn declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0 @@ -2091,14 +2337,159 @@ fn methods_call_init_functions_for_their_members() { } declare void @bar(%bar*) + + define void @__user_init_bar(%bar* %0) { + entry: + %self = alloca %bar*, align 8 + store %bar* %0, %bar** %self, align 8 + ret void + } + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } + ; ModuleID = '__init___testproject' + source_filename = "__init___testproject" + + @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @__init___testproject, i8* null }] + + define void @__init___testproject() { + entry: + ret void + } + "#); +} + +#[test] +fn user_fb_init_is_added_and_called_if_it_exists() { + let src = r#" + FUNCTION_BLOCK foo + VAR + x : INT := 0; + y : INT := 0; + END_VAR + METHOD FB_INIT + x := 1; + y := 2; + END_METHOD + END_FUNCTION_BLOCK + + PROGRAM prog + VAR + f : foo; + END_VAR + f(); + END_PROGRAM + "#; + + assert_snapshot!(codegen(src), @r#" + ; ModuleID = '' + source_filename = "" + + %foo = type { i16, i16 } + %prog = type { %foo } + + @__foo__init = unnamed_addr constant %foo zeroinitializer + @prog_instance = global %prog zeroinitializer + + define void @foo(%foo* %0) { + entry: + %x = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 + %y = getelementptr inbounds %foo, %foo* %0, i32 0, i32 1 + ret void + } + + define void @foo.FB_INIT(%foo* %0) { + entry: + %x = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 + %y = getelementptr inbounds %foo, %foo* %0, i32 0, i32 1 + store i16 1, i16* %x, align 2 + store i16 2, i16* %y, align 2 + ret void + } + + define void @prog(%prog* %0) { + entry: + %f = getelementptr inbounds %prog, %prog* %0, i32 0, i32 0 + call void @foo(%foo* %f) + ret void + } + ; ModuleID = '__initializers' + source_filename = "__initializers" + + %foo = type { i16, i16 } + %prog = type { %foo } + + @__foo__init = external global %foo + @prog_instance = external global %prog + + define void @__init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } + + declare void @foo(%foo*) + + define void @__init_prog(%prog* %0) { + entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + %deref = load %prog*, %prog** %self, align 8 + %f = getelementptr inbounds %prog, %prog* %deref, i32 0, i32 0 + call void @__init_foo(%foo* %f) + ret void + } + + declare void @prog(%prog*) + + define void @__user_init_prog(%prog* %0) { + entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + %deref = load %prog*, %prog** %self, align 8 + %f = getelementptr inbounds %prog, %prog* %deref, i32 0, i32 0 + call void @__user_init_foo(%foo* %f) + ret void + } + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + %deref = load %foo*, %foo** %self, align 8 + call void @foo.FB_INIT(%foo* %deref) + ret void + } + + declare void @foo.FB_INIT(%foo*) ; ModuleID = '__init___testproject' source_filename = "__init___testproject" + %prog = type { %foo } + %foo = type { i16, i16 } + + @prog_instance = external global %prog + @__foo__init = external global %foo @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @__init___testproject, i8* null }] define void @__init___testproject() { entry: + call void @__init_prog(%prog* @prog_instance) + call void @__user_init_prog(%prog* @prog_instance) ret void } + + declare void @__init_prog(%prog*) + + declare void @prog(%prog*) + + declare void @foo(%foo*) + + declare void @__user_init_prog(%prog*) "#); } diff --git a/src/codegen/tests/initialization_test/global_initializers.rs b/src/codegen/tests/initialization_test/global_initializers.rs index ceaea82b99..c3087e130b 100644 --- a/src/codegen/tests/initialization_test/global_initializers.rs +++ b/src/codegen/tests/initialization_test/global_initializers.rs @@ -163,7 +163,7 @@ fn external_pous_get_external_initializers() { ", ); - insta::assert_snapshot!(result, @r###" + insta::assert_snapshot!(result, @r#" ; ModuleID = '' source_filename = "" @@ -176,7 +176,33 @@ fn external_pous_get_external_initializers() { declare void @ext_fb(%ext_fb*) declare void @ext_prog(%ext_prog*) - "###); + ; ModuleID = '__initializers' + source_filename = "__initializers" + + %ext_prog = type {} + %ext_fb = type {} + + @ext_prog_instance = external global %ext_prog + @__ext_fb__init = external global %ext_fb + + define void @__user_init_ext_prog(%ext_prog* %0) { + entry: + %self = alloca %ext_prog*, align 8 + store %ext_prog* %0, %ext_prog** %self, align 8 + ret void + } + + declare void @ext_prog(%ext_prog*) + + define void @__user_init_ext_fb(%ext_fb* %0) { + entry: + %self = alloca %ext_fb*, align 8 + store %ext_fb* %0, %ext_fb** %self, align 8 + ret void + } + + declare void @ext_fb(%ext_fb*) + "#); } #[test] diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__initial_values_in_global_variables_out_of_order.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__initial_values_in_global_variables_out_of_order.snap index ba3f625ffd..ea396b3937 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__initial_values_in_global_variables_out_of_order.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__initial_values_in_global_variables_out_of_order.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/initialization_test/global_initializers.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -52,6 +53,23 @@ entry: store %MyFB* %0, %MyFB** %self, align 8 ret void } + +define void @__user_init_MyFB(%MyFB* %0) { +entry: + %self = alloca %MyFB*, align 8 + store %MyFB* %0, %MyFB** %self, align 8 + ret void +} + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + %deref = load %prg*, %prg** %self, align 8 + %x = getelementptr inbounds %prg, %prg* %deref, i32 0, i32 0 + call void @__user_init_MyFB(%MyFB* %x) + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -67,6 +85,8 @@ define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) call void @__init_myfb(%MyFB* @x) + call void @__user_init_prg(%prg* @prg_instance) + call void @__user_init_MyFB(%MyFB* @x) ret void } @@ -77,3 +97,7 @@ declare void @prg(%prg*) declare void @MyFB(%MyFB*) declare void @__init_myfb(%MyFB*) + +declare void @__user_init_prg(%prg*) + +declare void @__user_init_MyFB(%MyFB*) diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__class_struct_initialized_in_function.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__class_struct_initialized_in_function.snap index 662b7cdd14..5bacd9bd56 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__class_struct_initialized_in_function.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__class_struct_initialized_in_function.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/initialization_test/pou_initializers.rs expression: function +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -75,6 +76,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -88,6 +96,7 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } @@ -96,3 +105,5 @@ declare void @__init_main(%main*) declare void @main(%main*) declare void @fb(%fb*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_block_struct_initialized_in_function.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_block_struct_initialized_in_function.snap index 0b0c6d7055..0081d0aa6b 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_block_struct_initialized_in_function.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_block_struct_initialized_in_function.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/initialization_test/pou_initializers.rs expression: function +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -28,6 +29,7 @@ entry: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %3, i8* align 1 bitcast (%fb* @__fb__init to i8*), i64 ptrtoint (%fb* getelementptr (%fb, %fb* null, i32 1) to i64), i1 false) store i32 0, i32* %func, align 4 call void @__init_fb(%fb* %x) + call void @__user_init_fb(%fb* %x) %func_ret = load i32, i32* %func, align 4 ret i32 %func_ret } @@ -41,6 +43,8 @@ entry: declare void @__init_fb(%fb*) +declare void @__user_init_fb(%fb*) + ; Function Attrs: argmemonly nofree nounwind willreturn declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0 @@ -74,6 +78,23 @@ entry: } declare void @main(%main*) + +define void @__user_init_fb(%fb* %0) { +entry: + %self = alloca %fb*, align 8 + store %fb* %0, %fb** %self, align 8 + ret void +} + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + %deref = load %main*, %main** %self, align 8 + %fb0 = getelementptr inbounds %main, %main* %deref, i32 0, i32 0 + call void @__user_init_fb(%fb* %fb0) + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -87,6 +108,7 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } @@ -95,3 +117,5 @@ declare void @__init_main(%main*) declare void @main(%main*) declare void @fb(%fb*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_return_value_is_initialized_with_type_initializer.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_return_value_is_initialized_with_type_initializer.snap index 3ada614ffd..4fc3e864ba 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_return_value_is_initialized_with_type_initializer.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_return_value_is_initialized_with_type_initializer.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/initialization_test/pou_initializers.rs expression: function +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -57,6 +58,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -68,9 +76,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_constant_values_in_pou_variables.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_constant_values_in_pou_variables.snap index da72f42f4d..f7be60bfee 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_constant_values_in_pou_variables.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_constant_values_in_pou_variables.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/initialization_test/pou_initializers.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -33,6 +34,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -44,9 +52,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_values_in_function_block_pou.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_values_in_function_block_pou.snap index ed28d9a08c..ef532bacad 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_values_in_function_block_pou.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_values_in_function_block_pou.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/initialization_test/pou_initializers.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -56,6 +57,23 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + %deref = load %main*, %main** %self, align 8 + %fb = getelementptr inbounds %main, %main* %deref, i32 0, i32 0 + call void @__user_init_FB(%FB* %fb) + ret void +} + +define void @__user_init_FB(%FB* %0) { +entry: + %self = alloca %FB*, align 8 + store %FB* %0, %FB** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -69,6 +87,7 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } @@ -77,3 +96,5 @@ declare void @__init_main(%main*) declare void @main(%main*) declare void @FB(%FB*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_values_in_program_pou.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_values_in_program_pou.snap index 2aadb6af53..c7f8e6c952 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_values_in_program_pou.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_values_in_program_pou.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/initialization_test/pou_initializers.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -34,6 +35,13 @@ entry: } declare void @Main(%Main*) + +define void @__user_init_Main(%Main* %0) { +entry: + %self = alloca %Main*, align 8 + store %Main* %0, %Main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -45,9 +53,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%Main* @Main_instance) + call void @__user_init_Main(%Main* @Main_instance) ret void } declare void @__init_main(%Main*) declare void @Main(%Main*) + +declare void @__user_init_Main(%Main*) diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__no_memcpy_for_struct_initialization_in_program.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__no_memcpy_for_struct_initialization_in_program.snap index 4df2c3cb57..3eaf4239a1 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__no_memcpy_for_struct_initialization_in_program.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__no_memcpy_for_struct_initialization_in_program.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/initialization_test/pou_initializers.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -43,6 +44,13 @@ entry: } declare void @prog(%prog*) + +define void @__user_init_prog(%prog* %0) { +entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -56,9 +64,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prog(%prog* @prog_instance) + call void @__user_init_prog(%prog* @prog_instance) ret void } declare void @__init_prog(%prog*) declare void @prog(%prog*) + +declare void @__user_init_prog(%prog*) diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__array_of_struct_initialization.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__array_of_struct_initialization.snap index 98729d65b9..fea1c5c037 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__array_of_struct_initialization.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__array_of_struct_initialization.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/initialization_test/type_initializers.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -46,6 +47,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -63,6 +71,7 @@ entry: call void @__init_main(%main* @main_instance) call void @__init_mystruct(%myStruct* @str) call void @__init_mystruct(%myStruct* @alias_str) + call void @__user_init_main(%main* @main_instance) ret void } @@ -71,3 +80,5 @@ declare void @__init_main(%main*) declare void @main(%main*) declare void @__init_mystruct(%myStruct*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_fb_variable.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_fb_variable.snap index c30bc1b892..a7ac8af2ee 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_fb_variable.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_fb_variable.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/initialization_test/type_initializers.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -59,6 +60,26 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + %deref = load %main*, %main** %self, align 8 + %struct1 = getelementptr inbounds %main, %main* %deref, i32 0, i32 1 + call void @__user_init_TON(%TON* %struct1) + %deref1 = load %main*, %main** %self, align 8 + %struct2 = getelementptr inbounds %main, %main* %deref1, i32 0, i32 2 + call void @__user_init_TON(%TON* %struct2) + ret void +} + +define void @__user_init_TON(%TON* %0) { +entry: + %self = alloca %TON*, align 8 + store %TON* %0, %TON** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -72,6 +93,7 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } @@ -80,3 +102,5 @@ declare void @__init_main(%main*) declare void @main(%main*) declare void @TON(%TON*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__skipped_field_members_for_array_of_structs_are_zero_initialized.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__skipped_field_members_for_array_of_structs_are_zero_initialized.snap index 54b867bc58..49967a03dc 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__skipped_field_members_for_array_of_structs_are_zero_initialized.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__skipped_field_members_for_array_of_structs_are_zero_initialized.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/initialization_test/type_initializers.rs expression: res +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -52,6 +53,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -67,9 +75,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/online_change_tests.rs b/src/codegen/tests/online_change_tests.rs index 6c0e3dad30..6a64f75b7d 100644 --- a/src/codegen/tests/online_change_tests.rs +++ b/src/codegen/tests/online_change_tests.rs @@ -54,14 +54,14 @@ fn generate_program_with_online_change() { END_PROGRAM ", ); - assert_snapshot!(src, @r###" + assert_snapshot!(src, @r#" ; ModuleID = '' source_filename = "" %prg = type { i32 } @prg_instance = global %prg zeroinitializer, section "$RUSTY$var-prg_instance:r1i32" - @__custom_got = weak_odr global [10 x i8*] zeroinitializer + @__custom_got = weak_odr global [12 x i8*] zeroinitializer define void @prg(%prg* %0) section "$RUSTY$fn-prg:v[]" { entry: @@ -74,7 +74,7 @@ fn generate_program_with_online_change() { %prg = type { i32 } @prg_instance = external global %prg, section "$RUSTY$var-prg_instance:r1i32" - @__custom_got = weak_odr global [10 x i8*] zeroinitializer + @__custom_got = weak_odr global [12 x i8*] zeroinitializer define void @__init_prg(%prg* %0) section "$RUSTY$fn-__init_prg:v[pr1i32]" { entry: @@ -84,26 +84,37 @@ fn generate_program_with_online_change() { } declare void @prg(%prg*) section "$RUSTY$fn-prg:v[]" + + define void @__user_init_prg(%prg* %0) section "$RUSTY$fn-__user_init_prg:v[pr1i32]" { + entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" %prg = type { i32 } @prg_instance = external global %prg, section "$RUSTY$var-prg_instance:r1i32" - @__custom_got = weak_odr global [10 x i8*] zeroinitializer + @__custom_got = weak_odr global [12 x i8*] zeroinitializer @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @__init___testproject, i8* null }] define void @__init___testproject() section "$RUSTY$fn-__init___testproject:v[]" { entry: %0 = load void (%prg*)*, void (%prg*)** getelementptr inbounds (void (%prg*)*, void (%prg*)** inttoptr (i64 -2401053092612145152 to void (%prg*)**), i32 7), align 8 call void %0(%prg* @prg_instance) + %1 = load void (%prg*)*, void (%prg*)** getelementptr inbounds (void (%prg*)*, void (%prg*)** inttoptr (i64 -2401053092612145152 to void (%prg*)**), i32 9), align 8 + call void %1(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) section "$RUSTY$fn-__init_prg:v[pr1i32]" declare void @prg(%prg*) section "$RUSTY$fn-prg:v[]" - "###) + + declare void @__user_init_prg(%prg*) section "$RUSTY$fn-__user_init_prg:v[pr1i32]" + "#) } #[test] @@ -122,7 +133,7 @@ fn generate_program_and_var_with_online_change() { END_VAR ", ); - assert_snapshot!(src, @r###" + assert_snapshot!(src, @r#" ; ModuleID = '' source_filename = "" @@ -130,7 +141,7 @@ fn generate_program_and_var_with_online_change() { @gV = global i32 0, section "$RUSTY$var-gv:i32" @prg_instance = global %prg zeroinitializer, section "$RUSTY$var-prg_instance:r1i32" - @__custom_got = weak_odr global [12 x i8*] zeroinitializer + @__custom_got = weak_odr global [14 x i8*] zeroinitializer define void @prg(%prg* %0) section "$RUSTY$fn-prg:v[]" { entry: @@ -146,7 +157,7 @@ fn generate_program_and_var_with_online_change() { %prg = type { i32 } @prg_instance = external global %prg, section "$RUSTY$var-prg_instance:r1i32" - @__custom_got = weak_odr global [12 x i8*] zeroinitializer + @__custom_got = weak_odr global [14 x i8*] zeroinitializer define void @__init_prg(%prg* %0) section "$RUSTY$fn-__init_prg:v[pr1i32]" { entry: @@ -156,26 +167,37 @@ fn generate_program_and_var_with_online_change() { } declare void @prg(%prg*) section "$RUSTY$fn-prg:v[]" + + define void @__user_init_prg(%prg* %0) section "$RUSTY$fn-__user_init_prg:v[pr1i32]" { + entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" %prg = type { i32 } @prg_instance = external global %prg, section "$RUSTY$var-prg_instance:r1i32" - @__custom_got = weak_odr global [12 x i8*] zeroinitializer + @__custom_got = weak_odr global [14 x i8*] zeroinitializer @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @__init___testproject, i8* null }] define void @__init___testproject() section "$RUSTY$fn-__init___testproject:v[]" { entry: %0 = load void (%prg*)*, void (%prg*)** getelementptr inbounds (void (%prg*)*, void (%prg*)** inttoptr (i64 -2401053092612145152 to void (%prg*)**), i32 9), align 8 call void %0(%prg* @prg_instance) + %1 = load void (%prg*)*, void (%prg*)** getelementptr inbounds (void (%prg*)*, void (%prg*)** inttoptr (i64 -2401053092612145152 to void (%prg*)**), i32 11), align 8 + call void %1(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) section "$RUSTY$fn-__init_prg:v[pr1i32]" declare void @prg(%prg*) section "$RUSTY$fn-prg:v[]" - "###) + + declare void @__user_init_prg(%prg*) section "$RUSTY$fn-__user_init_prg:v[pr1i32]" + "#) } #[test] diff --git a/src/codegen/tests/oop_tests.rs b/src/codegen/tests/oop_tests.rs index 6c86a77017..17754787b5 100644 --- a/src/codegen/tests/oop_tests.rs +++ b/src/codegen/tests/oop_tests.rs @@ -18,7 +18,7 @@ fn members_from_base_class_are_available_in_subclasses() { END_FUNCTION_BLOCK "#, ); - insta::assert_snapshot!(result, @r###" + insta::assert_snapshot!(result, @r#" ; ModuleID = '' source_filename = "" @@ -60,11 +60,28 @@ fn members_from_base_class_are_available_in_subclasses() { ret void } + define void @__user_init_bar(%bar* %0) { + entry: + %self = alloca %bar*, align 8 + store %bar* %0, %bar** %self, align 8 + %deref = load %bar*, %bar** %self, align 8 + %__foo = getelementptr inbounds %bar, %bar* %deref, i32 0, i32 0 + call void @__user_init_foo(%foo* %__foo) + ret void + } + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void } - "###); + "#); } #[test] @@ -90,7 +107,7 @@ fn write_to_parent_variable_qualified_access() { ", ); - insta::assert_snapshot!(res, @r###" + insta::assert_snapshot!(res, @r#" ; ModuleID = '' source_filename = "" @@ -152,11 +169,38 @@ fn write_to_parent_variable_qualified_access() { ret void } + define void @__user_init_fb(%fb* %0) { + entry: + %self = alloca %fb*, align 8 + store %fb* %0, %fb** %self, align 8 + ret void + } + + define void @__user_init_fb2(%fb2* %0) { + entry: + %self = alloca %fb2*, align 8 + store %fb2* %0, %fb2** %self, align 8 + %deref = load %fb2*, %fb2** %self, align 8 + %__fb = getelementptr inbounds %fb2, %fb2* %deref, i32 0, i32 0 + call void @__user_init_fb(%fb* %__fb) + ret void + } + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + %deref = load %foo*, %foo** %self, align 8 + %myFb = getelementptr inbounds %foo, %foo* %deref, i32 0, i32 0 + call void @__user_init_fb2(%fb2* %myFb) + ret void + } + define void @__init___Test() { entry: ret void } - "###); + "#); } #[test] @@ -186,7 +230,7 @@ fn write_to_parent_variable_in_instance() { END_FUNCTION "#, ); - insta::assert_snapshot!(result, @r###" + insta::assert_snapshot!(result, @r#" ; ModuleID = '' source_filename = "" @@ -231,6 +275,7 @@ fn write_to_parent_variable_in_instance() { %1 = bitcast %bar* %fb to i8* call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %1, i8* align 1 getelementptr inbounds (%bar, %bar* @__bar__init, i32 0, i32 0, i32 0, i32 0), i64 ptrtoint (%bar* getelementptr (%bar, %bar* null, i32 1) to i64), i1 false) call void @__init_bar(%bar* %fb) + call void @__user_init_bar(%bar* %fb) %__foo = getelementptr inbounds %bar, %bar* %fb, i32 0, i32 0 call void @foo.baz(%foo* %__foo) call void @bar(%bar* %fb) @@ -263,6 +308,23 @@ fn write_to_parent_variable_in_instance() { ret void } + define void @__user_init_bar(%bar* %0) { + entry: + %self = alloca %bar*, align 8 + store %bar* %0, %bar** %self, align 8 + %deref = load %bar*, %bar** %self, align 8 + %__foo = getelementptr inbounds %bar, %bar* %deref, i32 0, i32 0 + call void @__user_init_foo(%foo* %__foo) + ret void + } + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void @@ -270,7 +332,7 @@ fn write_to_parent_variable_in_instance() { attributes #0 = { argmemonly nofree nounwind willreturn } attributes #1 = { argmemonly nofree nounwind willreturn writeonly } - "###); + "#); } #[test] @@ -309,7 +371,7 @@ fn array_in_parent_generated() { END_FUNCTION "#, ); - insta::assert_snapshot!(result, @r###" + insta::assert_snapshot!(result, @r#" ; ModuleID = '' source_filename = "" @@ -406,13 +468,40 @@ fn array_in_parent_generated() { ret void } + define void @__user_init_grandparent(%grandparent* %0) { + entry: + %self = alloca %grandparent*, align 8 + store %grandparent* %0, %grandparent** %self, align 8 + ret void + } + + define void @__user_init_child(%child* %0) { + entry: + %self = alloca %child*, align 8 + store %child* %0, %child** %self, align 8 + %deref = load %child*, %child** %self, align 8 + %__parent = getelementptr inbounds %child, %child* %deref, i32 0, i32 0 + call void @__user_init_parent(%parent* %__parent) + ret void + } + + define void @__user_init_parent(%parent* %0) { + entry: + %self = alloca %parent*, align 8 + store %parent* %0, %parent** %self, align 8 + %deref = load %parent*, %parent** %self, align 8 + %__grandparent = getelementptr inbounds %parent, %parent* %deref, i32 0, i32 0 + call void @__user_init_grandparent(%grandparent* %__grandparent) + ret void + } + define void @__init___Test() { entry: ret void } attributes #0 = { argmemonly nofree nounwind willreturn writeonly } - "###); + "#); } #[test] @@ -442,7 +531,7 @@ fn complex_array_access_generated() { "#, ); - insta::assert_snapshot!(result, @r###" + insta::assert_snapshot!(result, @r#" ; ModuleID = '' source_filename = "" @@ -528,11 +617,38 @@ fn complex_array_access_generated() { ret void } + define void @__user_init_grandparent(%grandparent* %0) { + entry: + %self = alloca %grandparent*, align 8 + store %grandparent* %0, %grandparent** %self, align 8 + ret void + } + + define void @__user_init_child(%child* %0) { + entry: + %self = alloca %child*, align 8 + store %child* %0, %child** %self, align 8 + %deref = load %child*, %child** %self, align 8 + %__parent = getelementptr inbounds %child, %child* %deref, i32 0, i32 0 + call void @__user_init_parent(%parent* %__parent) + ret void + } + + define void @__user_init_parent(%parent* %0) { + entry: + %self = alloca %parent*, align 8 + store %parent* %0, %parent** %self, align 8 + %deref = load %parent*, %parent** %self, align 8 + %__grandparent = getelementptr inbounds %parent, %parent* %deref, i32 0, i32 0 + call void @__user_init_grandparent(%grandparent* %__grandparent) + ret void + } + define void @__init___Test() { entry: ret void } - "###); + "#); } #[test] diff --git a/src/codegen/tests/oop_tests/debug_tests.rs b/src/codegen/tests/oop_tests/debug_tests.rs index 7be988b277..ecde257f42 100644 --- a/src/codegen/tests/oop_tests/debug_tests.rs +++ b/src/codegen/tests/oop_tests/debug_tests.rs @@ -63,6 +63,23 @@ fn members_from_base_class_are_available_in_subclasses() { ret void } + define void @__user_init_bar(%bar* %0) { + entry: + %self = alloca %bar*, align 8 + store %bar* %0, %bar** %self, align 8 + %deref = load %bar*, %bar** %self, align 8 + %__foo = getelementptr inbounds %bar, %bar* %deref, i32 0, i32 0 + call void @__user_init_foo(%foo* %__foo) + ret void + } + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void @@ -203,6 +220,33 @@ fn write_to_parent_variable_qualified_access() { ret void } + define void @__user_init_fb(%fb* %0) { + entry: + %self = alloca %fb*, align 8 + store %fb* %0, %fb** %self, align 8 + ret void + } + + define void @__user_init_fb2(%fb2* %0) { + entry: + %self = alloca %fb2*, align 8 + store %fb2* %0, %fb2** %self, align 8 + %deref = load %fb2*, %fb2** %self, align 8 + %__fb = getelementptr inbounds %fb2, %fb2* %deref, i32 0, i32 0 + call void @__user_init_fb(%fb* %__fb) + ret void + } + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + %deref = load %foo*, %foo** %self, align 8 + %myFb = getelementptr inbounds %foo, %foo* %deref, i32 0, i32 0 + call void @__user_init_fb2(%fb2* %myFb) + ret void + } + define void @__init___Test() { entry: ret void @@ -332,6 +376,7 @@ fn write_to_parent_variable_in_instance() { %1 = bitcast %bar* %fb to i8* call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %1, i8* align 1 getelementptr inbounds (%bar, %bar* @__bar__init, i32 0, i32 0, i32 0, i32 0), i64 ptrtoint (%bar* getelementptr (%bar, %bar* null, i32 1) to i64), i1 false) call void @__init_bar(%bar* %fb), !dbg !42 + call void @__user_init_bar(%bar* %fb), !dbg !42 %__foo = getelementptr inbounds %bar, %bar* %fb, i32 0, i32 0, !dbg !42 call void @foo.baz(%foo* %__foo), !dbg !43 call void @bar(%bar* %fb), !dbg !44 @@ -367,6 +412,23 @@ fn write_to_parent_variable_in_instance() { ret void } + define void @__user_init_bar(%bar* %0) { + entry: + %self = alloca %bar*, align 8 + store %bar* %0, %bar** %self, align 8 + %deref = load %bar*, %bar** %self, align 8 + %__foo = getelementptr inbounds %bar, %bar* %deref, i32 0, i32 0 + call void @__user_init_foo(%foo* %__foo) + ret void + } + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void @@ -568,6 +630,33 @@ fn array_in_parent_generated() { ret void } + define void @__user_init_grandparent(%grandparent* %0) { + entry: + %self = alloca %grandparent*, align 8 + store %grandparent* %0, %grandparent** %self, align 8 + ret void + } + + define void @__user_init_child(%child* %0) { + entry: + %self = alloca %child*, align 8 + store %child* %0, %child** %self, align 8 + %deref = load %child*, %child** %self, align 8 + %__parent = getelementptr inbounds %child, %child* %deref, i32 0, i32 0 + call void @__user_init_parent(%parent* %__parent) + ret void + } + + define void @__user_init_parent(%parent* %0) { + entry: + %self = alloca %parent*, align 8 + store %parent* %0, %parent** %self, align 8 + %deref = load %parent*, %parent** %self, align 8 + %__grandparent = getelementptr inbounds %parent, %parent* %deref, i32 0, i32 0 + call void @__user_init_grandparent(%grandparent* %__grandparent) + ret void + } + define void @__init___Test() { entry: ret void @@ -760,6 +849,33 @@ fn complex_array_access_generated() { ret void } + define void @__user_init_grandparent(%grandparent* %0) { + entry: + %self = alloca %grandparent*, align 8 + store %grandparent* %0, %grandparent** %self, align 8 + ret void + } + + define void @__user_init_child(%child* %0) { + entry: + %self = alloca %child*, align 8 + store %child* %0, %child** %self, align 8 + %deref = load %child*, %child** %self, align 8 + %__parent = getelementptr inbounds %child, %child* %deref, i32 0, i32 0 + call void @__user_init_parent(%parent* %__parent) + ret void + } + + define void @__user_init_parent(%parent* %0) { + entry: + %self = alloca %parent*, align 8 + store %parent* %0, %parent** %self, align 8 + %deref = load %parent*, %parent** %self, align 8 + %__grandparent = getelementptr inbounds %parent, %parent* %deref, i32 0, i32 0 + call void @__user_init_grandparent(%grandparent* %__grandparent) + ret void + } + define void @__init___Test() { entry: ret void @@ -834,7 +950,7 @@ fn function_block_method_debug_info() { END_FUNCTION_BLOCK "#, ); - insta::assert_snapshot!(result, @r###" + insta::assert_snapshot!(result, @r#" ; ModuleID = '' source_filename = "" @@ -884,6 +1000,23 @@ fn function_block_method_debug_info() { ret void } + define void @__user_init_bar(%bar* %0) { + entry: + %self = alloca %bar*, align 8 + store %bar* %0, %bar** %self, align 8 + %deref = load %bar*, %bar** %self, align 8 + %__foo = getelementptr inbounds %bar, %bar* %deref, i32 0, i32 0 + call void @__user_init_foo(%foo* %__foo) + ret void + } + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void @@ -921,7 +1054,7 @@ fn function_block_method_debug_info() { !24 = !{null, !7} !25 = !DILocalVariable(name: "bar", scope: !22, file: !2, line: 8, type: !7) !26 = !DILocation(line: 8, column: 8, scope: !22) - "###); + "#); } #[test] @@ -986,7 +1119,7 @@ END_FUNCTION ", ); - insta::assert_snapshot!(result, @r###" + insta::assert_snapshot!(result, @r#" ; ModuleID = '' source_filename = "" @@ -1054,6 +1187,9 @@ END_FUNCTION call void @__init_parent(%parent* %parent1), !dbg !61 call void @__init_child(%child* %child1), !dbg !61 call void @__init_grandchild(%grandchild* %grandchild1), !dbg !61 + call void @__user_init_parent(%parent* %parent1), !dbg !61 + call void @__user_init_child(%child* %child1), !dbg !61 + call void @__user_init_grandchild(%grandchild* %grandchild1), !dbg !61 %a = getelementptr inbounds %parent, %parent* %parent1, i32 0, i32 0, !dbg !62 store i32 1, i32* %a, align 4, !dbg !62 %__parent = getelementptr inbounds %child, %child* %child1, i32 0, i32 0, !dbg !63 @@ -1176,6 +1312,33 @@ END_FUNCTION ret void } + define void @__user_init_grandchild(%grandchild* %0) { + entry: + %self = alloca %grandchild*, align 8 + store %grandchild* %0, %grandchild** %self, align 8 + %deref = load %grandchild*, %grandchild** %self, align 8 + %__child = getelementptr inbounds %grandchild, %grandchild* %deref, i32 0, i32 0 + call void @__user_init_child(%child* %__child) + ret void + } + + define void @__user_init_child(%child* %0) { + entry: + %self = alloca %child*, align 8 + store %child* %0, %child** %self, align 8 + %deref = load %child*, %child** %self, align 8 + %__parent = getelementptr inbounds %child, %child* %deref, i32 0, i32 0 + call void @__user_init_parent(%parent* %__parent) + ret void + } + + define void @__user_init_parent(%parent* %0) { + entry: + %self = alloca %parent*, align 8 + store %parent* %0, %parent** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void @@ -1275,5 +1438,5 @@ END_FUNCTION !84 = !DILocation(line: 53, column: 4, scope: !39) !85 = !DILocation(line: 54, column: 4, scope: !39) !86 = !DILocation(line: 56, scope: !39) - "###); + "#); } diff --git a/src/codegen/tests/parameters_tests.rs b/src/codegen/tests/parameters_tests.rs index 4e242816ca..a03c390404 100644 --- a/src/codegen/tests/parameters_tests.rs +++ b/src/codegen/tests/parameters_tests.rs @@ -1114,7 +1114,7 @@ fn by_value_fb_arg_aggregates_are_memcopied() { "#, ); - assert_snapshot!(result, @r###" + assert_snapshot!(result, @r#" ; ModuleID = '' source_filename = "" @@ -1136,6 +1136,7 @@ fn by_value_fb_arg_aggregates_are_memcopied() { call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %2, i8* align 1 getelementptr inbounds (%FOO, %FOO* @__FOO__init, i32 0, i32 0, i32 0), i64 ptrtoint (%FOO* getelementptr (%FOO, %FOO* null, i32 1) to i64), i1 false) store i32 0, i32* %main, align 4 call void @__init_foo(%FOO* %fb) + call void @__user_init_FOO(%FOO* %fb) %3 = getelementptr inbounds %FOO, %FOO* %fb, i32 0, i32 0 %4 = bitcast [65537 x i8]* %3 to i8* %5 = bitcast [65537 x i8]* %str to i8* @@ -1158,6 +1159,8 @@ fn by_value_fb_arg_aggregates_are_memcopied() { declare void @__init_foo(%FOO*) + declare void @__user_init_FOO(%FOO*) + ; Function Attrs: argmemonly nofree nounwind willreturn writeonly declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg) #0 @@ -1184,6 +1187,13 @@ fn by_value_fb_arg_aggregates_are_memcopied() { } declare void @FOO(%FOO*) + + define void @__user_init_FOO(%FOO* %0) { + entry: + %self = alloca %FOO*, align 8 + store %FOO* %0, %FOO** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -1193,7 +1203,7 @@ fn by_value_fb_arg_aggregates_are_memcopied() { entry: ret void } - "###); + "#); } #[test] @@ -1229,7 +1239,7 @@ fn var_output_aggregate_types_are_memcopied() { "#, ); - assert_snapshot!(result, @r###" + assert_snapshot!(result, @r#" ; ModuleID = '' source_filename = "" @@ -1334,6 +1344,23 @@ fn var_output_aggregate_types_are_memcopied() { } declare void @PRG(%PRG*) + + define void @__user_init_FB(%FB* %0) { + entry: + %self = alloca %FB*, align 8 + store %FB* %0, %FB** %self, align 8 + ret void + } + + define void @__user_init_PRG(%PRG* %0) { + entry: + %self = alloca %PRG*, align 8 + store %PRG* %0, %PRG** %self, align 8 + %deref = load %PRG*, %PRG** %self, align 8 + %station = getelementptr inbounds %PRG, %PRG* %deref, i32 0, i32 5 + call void @__user_init_FB(%FB* %station) + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -1349,6 +1376,7 @@ fn var_output_aggregate_types_are_memcopied() { define void @__init___testproject() { entry: call void @__init_prg(%PRG* @PRG_instance) + call void @__user_init_PRG(%PRG* @PRG_instance) ret void } @@ -1357,5 +1385,7 @@ fn var_output_aggregate_types_are_memcopied() { declare void @PRG(%PRG*) declare void @FB(%FB*) - "###); + + declare void @__user_init_PRG(%PRG*) + "#); } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__a_global_variables_generates_in_separate_global_variables.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__a_global_variables_generates_in_separate_global_variables.snap index 44991c1b54..3e5ac85244 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__a_global_variables_generates_in_separate_global_variables.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__a_global_variables_generates_in_separate_global_variables.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -30,6 +31,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -41,9 +49,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__accessing_nested_array_in_struct.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__accessing_nested_array_in_struct.snap index d6b3ecfb1d..bf2753f057 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__accessing_nested_array_in_struct.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__accessing_nested_array_in_struct.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -46,6 +47,13 @@ entry: } declare void @Main(%Main*) + +define void @__user_init_Main(%Main* %0) { +entry: + %self = alloca %Main*, align 8 + store %Main* %0, %Main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -59,9 +67,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%Main* @Main_instance) + call void @__user_init_Main(%Main* @Main_instance) ret void } declare void @__init_main(%Main*) declare void @Main(%Main*) + +declare void @__user_init_Main(%Main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__accessing_nested_structs.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__accessing_nested_structs.snap index 1e9b679fa5..764ce85b9c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__accessing_nested_structs.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__accessing_nested_structs.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -66,6 +67,13 @@ entry: } declare void @Main(%Main*) + +define void @__user_init_Main(%Main* %0) { +entry: + %self = alloca %Main*, align 8 + store %Main* %0, %Main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -81,9 +89,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%Main* @Main_instance) + call void @__user_init_Main(%Main* @Main_instance) ret void } declare void @__init_main(%Main*) declare void @Main(%Main*) + +declare void @__user_init_Main(%Main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__action_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__action_called_in_program.snap index 5f93d2a33c..ff48e55234 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__action_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__action_called_in_program.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -37,6 +38,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -48,9 +56,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_cast_int_type_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_cast_int_type_generated.snap index bccf7c72d2..3fcdcfb45a 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_cast_int_type_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_cast_int_type_generated.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -29,6 +30,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -40,9 +48,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_non_zero_negative_type_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_non_zero_negative_type_generated.snap index fe84dd0860..c3863a619f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_non_zero_negative_type_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_non_zero_negative_type_generated.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -29,6 +30,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -40,9 +48,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_non_zero_type_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_non_zero_type_generated.snap index bccf7c72d2..3fcdcfb45a 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_non_zero_type_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_non_zero_type_generated.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -29,6 +30,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -40,9 +48,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_generated.snap index bccf7c72d2..3fcdcfb45a 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_generated.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -29,6 +30,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -40,9 +48,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_used.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_used.snap index 9c3befd40b..b826825e11 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_used.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_used.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -36,6 +37,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -47,9 +55,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_with_non_zero_negative_start_used.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_with_non_zero_negative_start_used.snap index d1f76ddc10..6ebfcdbda1 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_with_non_zero_negative_start_used.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_with_non_zero_negative_start_used.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -36,6 +37,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -47,9 +55,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_with_non_zero_start_used.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_with_non_zero_start_used.snap index fac2221040..ae4b4e3da7 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_with_non_zero_start_used.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_with_non_zero_start_used.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -36,6 +37,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -47,9 +55,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_struct_as_member_of_another_struct_and_variable_declaration_is_initialized.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_struct_as_member_of_another_struct_and_variable_declaration_is_initialized.snap index 0b0680e2f2..b75807f0b3 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_struct_as_member_of_another_struct_and_variable_declaration_is_initialized.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_struct_as_member_of_another_struct_and_variable_declaration_is_initialized.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: res +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -52,6 +53,13 @@ entry: } declare void @mainProg(%mainProg*) + +define void @__user_init_mainProg(%mainProg* %0) { +entry: + %self = alloca %mainProg*, align 8 + store %mainProg* %0, %mainProg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -67,9 +75,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_mainprog(%mainProg* @mainProg_instance) + call void @__user_init_mainProg(%mainProg* @mainProg_instance) ret void } declare void @__init_mainprog(%mainProg*) declare void @mainProg(%mainProg*) + +declare void @__user_init_mainProg(%mainProg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_struct_as_member_of_another_struct_is_initialized.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_struct_as_member_of_another_struct_is_initialized.snap index 7ec2f34a03..7d914a18c2 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_struct_as_member_of_another_struct_is_initialized.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_struct_as_member_of_another_struct_is_initialized.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: res +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -55,6 +56,13 @@ entry: } declare void @mainProg(%mainProg*) + +define void @__user_init_mainProg(%mainProg* %0) { +entry: + %self = alloca %mainProg*, align 8 + store %mainProg* %0, %mainProg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -70,9 +78,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_mainprog(%mainProg* @mainProg_instance) + call void @__user_init_mainProg(%mainProg* @mainProg_instance) ret void } declare void @__init_mainprog(%mainProg*) declare void @mainProg(%mainProg*) + +declare void @__user_init_mainProg(%mainProg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_multiple_labels_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_multiple_labels_statement.snap index 40010bdf18..7d30092a19 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_multiple_labels_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_multiple_labels_statement.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -51,6 +52,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -62,9 +70,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_ranges_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_ranges_statement.snap index ca373a05a2..f3e9c28db4 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_ranges_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_ranges_statement.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -52,6 +53,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -63,9 +71,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_bool_code_gen_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_bool_code_gen_test.snap index 3b9f17d68d..92be7443de 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_bool_code_gen_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_bool_code_gen_test.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -33,6 +34,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -44,9 +52,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_code_gen_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_code_gen_test.snap index 33bf683047..2f69cbbc0c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_code_gen_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_code_gen_test.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -35,6 +36,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -46,9 +54,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_hex_code_gen_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_hex_code_gen_test.snap index 8a9833e220..a1ed6bfef9 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_hex_code_gen_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_hex_code_gen_test.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -35,6 +36,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -46,9 +54,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_hex_ints_code_gen_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_hex_ints_code_gen_test.snap index d790057080..aa0683bb0c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_hex_ints_code_gen_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_hex_ints_code_gen_test.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -31,6 +32,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -42,9 +50,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_lreal_code_gen_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_lreal_code_gen_test.snap index 25d965c5f0..703044fc24 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_lreal_code_gen_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_lreal_code_gen_test.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -35,6 +36,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -46,9 +54,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_real_code_gen_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_real_code_gen_test.snap index ddca79306b..2bbbca44e8 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_real_code_gen_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_real_code_gen_test.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -34,6 +35,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -45,9 +53,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__class_method_in_pou.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__class_method_in_pou.snap index f65f238e7a..fc32ec59e4 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__class_method_in_pou.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__class_method_in_pou.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -80,6 +81,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -93,6 +101,7 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } @@ -101,3 +110,5 @@ declare void @__init_prg(%prg*) declare void @prg(%prg*) declare void @MyClass(%MyClass*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__complex_pointers.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__complex_pointers.snap index 0754019c69..95226d335f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__complex_pointers.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__complex_pointers.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -57,6 +58,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -68,9 +76,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_expression_in_function_blocks_are_propagated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_expression_in_function_blocks_are_propagated.snap index 3dd782daeb..06e0a23372 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_expression_in_function_blocks_are_propagated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_expression_in_function_blocks_are_propagated.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -31,6 +32,13 @@ entry: } declare void @fbWithConstant(%fbWithConstant*) + +define void @__user_init_fbWithConstant(%fbWithConstant* %0) { +entry: + %self = alloca %fbWithConstant*, align 8 + store %fbWithConstant* %0, %fbWithConstant** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_expressions_in_ranged_type_declaration_are_propagated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_expressions_in_ranged_type_declaration_are_propagated.snap index 87faa6439a..035ea8d94d 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_expressions_in_ranged_type_declaration_are_propagated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_expressions_in_ranged_type_declaration_are_propagated.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -48,6 +49,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -59,9 +67,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__contants_in_case_statements_resolved.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__contants_in_case_statements_resolved.snap index 43b0524edd..a0494ae253 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__contants_in_case_statements_resolved.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__contants_in_case_statements_resolved.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -67,6 +68,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -78,9 +86,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__date_and_time_global_constants_initialize.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__date_and_time_global_constants_initialize.snap index 2069d4a1be..22332dcf9e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__date_and_time_global_constants_initialize.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__date_and_time_global_constants_initialize.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -92,6 +93,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -103,9 +111,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__date_comparisons.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__date_comparisons.snap index d26bc54b62..88852ac13b 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__date_comparisons.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__date_comparisons.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -40,6 +41,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -51,9 +59,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__different_case_references.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__different_case_references.snap index 329bdf1780..d89122d2d7 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__different_case_references.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__different_case_references.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -31,6 +32,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -42,9 +50,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_global_variable_list_generates_nothing.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_global_variable_list_generates_nothing.snap index e6069e8aa5..52c51df1cd 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_global_variable_list_generates_nothing.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_global_variable_list_generates_nothing.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -28,6 +29,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -39,9 +47,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_program_with_name_generates_void_function.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_program_with_name_generates_void_function.snap index d2dda847f8..e3be291a50 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_program_with_name_generates_void_function.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_program_with_name_generates_void_function.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -28,6 +29,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -39,9 +47,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_statements_dont_generate_anything.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_statements_dont_generate_anything.snap index 4ff968b283..403f3fca07 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_statements_dont_generate_anything.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_statements_dont_generate_anything.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -32,6 +33,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -43,9 +51,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__enum_members_can_be_used_in_asignments.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__enum_members_can_be_used_in_asignments.snap index b7d5af589d..c157c8625b 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__enum_members_can_be_used_in_asignments.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__enum_members_can_be_used_in_asignments.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -35,6 +36,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -46,9 +54,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__enums_custom_type_are_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__enums_custom_type_are_generated.snap index 771dbfa4cc..abbd719b58 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__enums_custom_type_are_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__enums_custom_type_are_generated.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -33,6 +34,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -44,9 +52,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_function_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_function_called_in_program.snap index b5d2e7b65c..c5107a140c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_function_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_function_called_in_program.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -31,6 +32,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -42,9 +50,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_global_variable_generates_as_external.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_global_variable_generates_as_external.snap index 7be0e89310..d128509246 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_global_variable_generates_as_external.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_global_variable_generates_as_external.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -30,6 +31,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -41,9 +49,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_program_global_var_is_external.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_program_global_var_is_external.snap index bff4e8363c..51583a12bf 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_program_global_var_is_external.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_program_global_var_is_external.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -10,3 +11,18 @@ source_filename = "" @prg_instance = external global %prg declare void @prg(%prg*) +; ModuleID = '__initializers' +source_filename = "__initializers" + +%prg = type { i32, i32 } + +@prg_instance = external global %prg + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} + +declare void @prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_called_as_function.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_called_as_function.snap index 9ef4849160..b35bfe5e38 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_called_as_function.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_called_as_function.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: prg +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -63,6 +64,13 @@ entry: } declare void @MyClass(%MyClass*) + +define void @__user_init_MyClass(%MyClass* %0) { +entry: + %self = alloca %MyClass*, align 8 + store %MyClass* %0, %MyClass** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_in_pou.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_in_pou.snap index f65f238e7a..6da63e71f3 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_in_pou.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_in_pou.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -80,6 +81,23 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_MyClass(%MyClass* %0) { +entry: + %self = alloca %MyClass*, align 8 + store %MyClass* %0, %MyClass** %self, align 8 + ret void +} + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + %deref = load %prg*, %prg** %self, align 8 + %cl = getelementptr inbounds %prg, %prg* %deref, i32 0, i32 0 + call void @__user_init_MyClass(%MyClass* %cl) + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -93,6 +111,7 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } @@ -101,3 +120,5 @@ declare void @__init_prg(%prg*) declare void @prg(%prg*) declare void @MyClass(%MyClass*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_with_var_in_out.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_with_var_in_out.snap index 45b2c23fd0..37cf1122d2 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_with_var_in_out.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_with_var_in_out.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: prg +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -66,6 +67,23 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_MyClass(%MyClass* %0) { +entry: + %self = alloca %MyClass*, align 8 + store %MyClass* %0, %MyClass** %self, align 8 + ret void +} + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + %deref = load %prg*, %prg** %self, align 8 + %cl = getelementptr inbounds %prg, %prg* %deref, i32 0, i32 0 + call void @__user_init_MyClass(%MyClass* %cl) + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -79,6 +97,7 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } @@ -87,3 +106,5 @@ declare void @__init_prg(%prg*) declare void @prg(%prg*) declare void @MyClass(%MyClass*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_with_var_input_defaults.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_with_var_input_defaults.snap index 37143801a4..4927036493 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_with_var_input_defaults.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_with_var_input_defaults.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: prg +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -64,6 +65,23 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_MyClass(%MyClass* %0) { +entry: + %self = alloca %MyClass*, align 8 + store %MyClass* %0, %MyClass** %self, align 8 + ret void +} + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + %deref = load %prg*, %prg** %self, align 8 + %cl = getelementptr inbounds %prg, %prg* %deref, i32 0, i32 0 + call void @__user_init_MyClass(%MyClass* %cl) + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -77,6 +95,7 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } @@ -85,3 +104,5 @@ declare void @__init_prg(%prg*) declare void @prg(%prg*) declare void @MyClass(%MyClass*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_continue.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_continue.snap index c3492cdf88..20a38edafa 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_continue.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_continue.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -53,6 +54,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -64,9 +72,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_int.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_int.snap index 35ee999116..88b2edcf8d 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_int.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_int.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -57,6 +58,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -68,9 +76,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_lint.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_lint.snap index 9e29ac3669..b6f358ff79 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_lint.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_lint.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -53,6 +54,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -64,9 +72,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_sint.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_sint.snap index 2d656e980c..ce781644ee 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_sint.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_sint.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -57,6 +58,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -68,9 +76,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_continue.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_continue.snap index e6f2f955c9..fac8c03c78 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_continue.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_continue.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -61,6 +62,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -72,9 +80,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_exit.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_exit.snap index 8ecbfd3d41..aac9fdf4c3 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_exit.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_exit.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -61,6 +62,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -72,9 +80,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_references_steps_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_references_steps_test.snap index c0707f51e1..5393c070ea 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_references_steps_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_references_steps_test.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -62,6 +63,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -73,9 +81,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_steps_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_steps_test.snap index d91707fe21..4137b8dca8 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_steps_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_steps_test.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -53,6 +54,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -64,9 +72,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_without_steps_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_without_steps_test.snap index 270ad3376b..39cc2a3576 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_without_steps_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_without_steps_test.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -53,6 +54,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -64,9 +72,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_block_instance_call.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_block_instance_call.snap index 841a833c56..b9f9650ad1 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_block_instance_call.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_block_instance_call.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -53,6 +54,23 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + %deref = load %prg*, %prg** %self, align 8 + %fb_inst = getelementptr inbounds %prg, %prg* %deref, i32 0, i32 0 + call void @__user_init_foo(%foo* %fb_inst) + ret void +} + +define void @__user_init_foo(%foo* %0) { +entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -66,6 +84,7 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } @@ -74,3 +93,5 @@ declare void @__init_prg(%prg*) declare void @prg(%prg*) declare void @foo(%foo*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_block_qualified_instance_call.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_block_qualified_instance_call.snap index dfaabf7fa1..2d48030447 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_block_qualified_instance_call.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_block_qualified_instance_call.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -74,6 +75,33 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + %deref = load %prg*, %prg** %self, align 8 + %foo_inst = getelementptr inbounds %prg, %prg* %deref, i32 0, i32 0 + call void @__user_init_foo(%foo* %foo_inst) + ret void +} + +define void @__user_init_bar(%bar* %0) { +entry: + %self = alloca %bar*, align 8 + store %bar* %0, %bar** %self, align 8 + ret void +} + +define void @__user_init_foo(%foo* %0) { +entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + %deref = load %foo*, %foo** %self, align 8 + %bar_inst = getelementptr inbounds %foo, %foo* %deref, i32 0, i32 0 + call void @__user_init_bar(%bar* %bar_inst) + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -89,6 +117,7 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } @@ -99,3 +128,5 @@ declare void @prg(%prg*) declare void @foo(%foo*) declare void @bar(%bar*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_call_with_same_name_as_return_type.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_call_with_same_name_as_return_type.snap index 40a7722e6b..44d7b0be91 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_call_with_same_name_as_return_type.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_call_with_same_name_as_return_type.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -37,6 +38,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -48,9 +56,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_called_in_program.snap index 4c57819176..ec34bcab0f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_called_in_program.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -40,6 +41,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -51,9 +59,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_called_when_shadowed.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_called_when_shadowed.snap index 0372c09e73..41070a2bce 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_called_when_shadowed.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_called_when_shadowed.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -40,6 +41,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -51,9 +59,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_local_temp_var_initialization.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_local_temp_var_initialization.snap index 0927531a4d..2bb97853bb 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_local_temp_var_initialization.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_local_temp_var_initialization.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -50,6 +51,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -61,9 +69,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_local_var_initialization_and_call.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_local_var_initialization_and_call.snap index 644d81885e..b1cc1489ff 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_local_var_initialization_and_call.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_local_var_initialization_and_call.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -46,6 +47,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -57,9 +65,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_parameters_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_parameters_called_in_program.snap index 25caa69751..3cd2ea84ef 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_parameters_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_parameters_called_in_program.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -42,6 +43,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -53,9 +61,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_two_parameters_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_two_parameters_called_in_program.snap index 5c95d36e23..96a157d6f7 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_two_parameters_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_two_parameters_called_in_program.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -44,6 +45,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -55,9 +63,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__global_variable_reference_is_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__global_variable_reference_is_generated.snap index 62601a1560..ae3a94d152 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__global_variable_reference_is_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__global_variable_reference_is_generated.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: function +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -33,6 +34,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -44,9 +52,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_elsif_else_generator_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_elsif_else_generator_test.snap index 73cc1c0012..8d108a8fab 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_elsif_else_generator_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_elsif_else_generator_test.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -66,6 +67,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -77,9 +85,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_generator_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_generator_test.snap index 40b084b3c3..486ea133ec 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_generator_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_generator_test.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -39,6 +40,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -50,9 +58,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_with_expression_generator_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_with_expression_generator_test.snap index 66a4922ecb..bd03d9e35c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_with_expression_generator_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_with_expression_generator_test.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -52,6 +53,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -63,9 +71,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__inlined_array_size_from_local_scoped_constants.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__inlined_array_size_from_local_scoped_constants.snap index b757ca1e24..9abf9f26c8 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__inlined_array_size_from_local_scoped_constants.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__inlined_array_size_from_local_scoped_constants.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -35,6 +36,13 @@ entry: } declare void @aaa(%aaa*) + +define void @__user_init_aaa(%aaa* %0) { +entry: + %self = alloca %aaa*, align 8 + store %aaa* %0, %aaa** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -46,9 +54,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_aaa(%aaa* @aaa_instance) + call void @__user_init_aaa(%aaa* @aaa_instance) ret void } declare void @__init_aaa(%aaa*) declare void @aaa(%aaa*) + +declare void @__user_init_aaa(%aaa*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_with_initialized_input.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_with_initialized_input.snap index 9f66db8be5..1dec2c3697 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_with_initialized_input.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_with_initialized_input.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: prg +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -48,6 +49,13 @@ entry: } declare void @fb(%fb*) + +define void @__user_init_fb(%fb* %0) { +entry: + %self = alloca %fb*, align 8 + store %fb* %0, %fb** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_with_multiple_input.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_with_multiple_input.snap index d688e238ce..740b3208aa 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_with_multiple_input.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_with_multiple_input.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: prg +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -46,6 +47,13 @@ entry: } declare void @fb(%fb*) + +define void @__user_init_fb(%fb* %0) { +entry: + %self = alloca %fb*, align 8 + store %fb* %0, %fb** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_with_aggregate_return_type.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_with_aggregate_return_type.snap index 5c1fc0fdf8..36d3c29116 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_with_aggregate_return_type.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_with_aggregate_return_type.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: res +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -67,6 +68,13 @@ entry: } declare void @fb_with_method(%fb_with_method*) + +define void @__user_init_fb_with_method(%fb_with_method* %0) { +entry: + %self = alloca %fb_with_method*, align 8 + store %fb_with_method* %0, %fb_with_method** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__methods_var_output.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__methods_var_output.snap index 5cf1b961bc..0ebf2e1e16 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__methods_var_output.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__methods_var_output.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: res +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -34,6 +35,7 @@ entry: %1 = bitcast %foo* %fb to i8* call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %1, i8* align 1 bitcast (%foo* @__foo__init to i8*), i64 ptrtoint (%foo* getelementptr (%foo, %foo* null, i32 1) to i64), i1 false) call void @__init_foo(%foo* %fb) + call void @__user_init_foo(%foo* %fb) %2 = bitcast [81 x i8]* %s to i8* call void @foo.baz(%foo* %fb, i8* %2) %3 = bitcast [81 x i8]* %s to i8* @@ -43,6 +45,8 @@ entry: declare void @__init_foo(%foo*) +declare void @__user_init_foo(%foo*) + ; Function Attrs: argmemonly nofree nounwind willreturn declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #0 @@ -69,6 +73,13 @@ entry: } declare void @foo(%foo*) + +define void @__user_init_foo(%foo* %0) { +entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__min_max_real_and_lreal_values_do_not_result_in_an_under_or_overflow.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__min_max_real_and_lreal_values_do_not_result_in_an_under_or_overflow.snap index e8abcc9bd4..e5dc0486e5 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__min_max_real_and_lreal_values_do_not_result_in_an_under_or_overflow.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__min_max_real_and_lreal_values_do_not_result_in_an_under_or_overflow.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -32,6 +33,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -43,9 +51,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__multidim_array_access.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__multidim_array_access.snap index e62c881bc5..7d89b72a40 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__multidim_array_access.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__multidim_array_access.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -36,6 +37,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -47,9 +55,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__multidim_array_declaration.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__multidim_array_declaration.snap index 7e344969e8..22af986c4a 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__multidim_array_declaration.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__multidim_array_declaration.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -29,6 +30,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -40,9 +48,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_access.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_access.snap index 4c5e33c302..73c3aa6a29 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_access.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_access.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -39,6 +40,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -50,9 +58,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_cube_writes.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_cube_writes.snap index 95c33ec5f5..f2431c6f9e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_cube_writes.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_cube_writes.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -54,6 +55,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -65,9 +73,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_cube_writes_negative_start.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_cube_writes_negative_start.snap index 73b4b45ecf..402e97652f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_cube_writes_negative_start.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_cube_writes_negative_start.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -57,6 +58,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -68,9 +76,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_declaration.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_declaration.snap index 272772c31a..6a785f4b0e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_declaration.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_declaration.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -29,6 +30,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -40,9 +48,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_function_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_function_called_in_program.snap index deb6a136ce..4f2ca35ec0 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_function_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_function_called_in_program.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -52,6 +53,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -63,9 +71,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__order_var_and_var_temp_block.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__order_var_and_var_temp_block.snap index 8af2e82023..3e1e40ed8d 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__order_var_and_var_temp_block.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__order_var_and_var_temp_block.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -31,6 +32,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -42,9 +50,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__pass_inout_to_inout.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__pass_inout_to_inout.snap index 9050977673..cb8d698f48 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__pass_inout_to_inout.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__pass_inout_to_inout.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -76,6 +77,27 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} + +define void @__user_init_foo2(%foo2* %0) { +entry: + %self = alloca %foo2*, align 8 + store %foo2* %0, %foo2** %self, align 8 + ret void +} + +define void @__user_init_foo(%foo* %0) { +entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -93,6 +115,9 @@ entry: call void @__init_foo(%foo* @foo_instance) call void @__init_foo2(%foo2* @foo2_instance) call void @__init_prg(%prg* @prg_instance) + call void @__user_init_foo(%foo* @foo_instance) + call void @__user_init_foo2(%foo2* @foo2_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } @@ -107,3 +132,9 @@ declare void @foo2(%foo2*) declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_foo(%foo*) + +declare void @__user_init_foo2(%foo2*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__pointers_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__pointers_generated.snap index cecdbdd192..b881d82d41 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__pointers_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__pointers_generated.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -47,6 +48,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -58,9 +66,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_called_in_program.snap index c24e79b34e..3e6f7142e0 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_called_in_program.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -47,6 +48,20 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} + +define void @__user_init_foo(%foo* %0) { +entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -61,6 +76,8 @@ define void @__init___testproject() { entry: call void @__init_foo(%foo* @foo_instance) call void @__init_prg(%prg* @prg_instance) + call void @__user_init_foo(%foo* @foo_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } @@ -71,3 +88,7 @@ declare void @foo(%foo*) declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_foo(%foo*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_and_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_and_statement.snap index 0d7bb7edf6..cf7a0af7cf 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_and_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_and_statement.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -41,6 +42,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -52,9 +60,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_bool_variables_and_references_generates_void_function_and_struct_and_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_bool_variables_and_references_generates_void_function_and_struct_and_body.snap index d59bfa4442..8396fad699 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_bool_variables_and_references_generates_void_function_and_struct_and_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_bool_variables_and_references_generates_void_function_and_struct_and_body.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -32,6 +33,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -43,9 +51,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_boolean_assignment_generates_void_function_and_struct_and_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_boolean_assignment_generates_void_function_and_struct_and_body.snap index 1b0a4d043f..375897ba01 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_boolean_assignment_generates_void_function_and_struct_and_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_boolean_assignment_generates_void_function_and_struct_and_body.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -31,6 +32,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -42,9 +50,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_casted_chars_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_casted_chars_assignment.snap index f8eb6b2156..ea9360b654 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_casted_chars_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_casted_chars_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -34,6 +35,13 @@ entry: } declare void @mainPROG(%mainPROG*) + +define void @__user_init_mainPROG(%mainPROG* %0) { +entry: + %self = alloca %mainPROG*, align 8 + store %mainPROG* %0, %mainPROG** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -45,9 +53,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_mainprog(%mainPROG* @mainPROG_instance) + call void @__user_init_mainPROG(%mainPROG* @mainPROG_instance) ret void } declare void @__init_mainprog(%mainPROG*) declare void @mainPROG(%mainPROG*) + +declare void @__user_init_mainPROG(%mainPROG*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_chars.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_chars.snap index 7ee6a379bc..00e69f37a5 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_chars.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_chars.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -42,6 +43,13 @@ entry: } declare void @mainPROG(%mainPROG*) + +define void @__user_init_mainPROG(%mainPROG* %0) { +entry: + %self = alloca %mainPROG*, align 8 + store %mainPROG* %0, %mainPROG** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -53,9 +61,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_mainprog(%mainPROG* @mainPROG_instance) + call void @__user_init_mainPROG(%mainPROG* @mainPROG_instance) ret void } declare void @__init_mainprog(%mainPROG*) declare void @mainPROG(%mainPROG*) + +declare void @__user_init_mainPROG(%mainPROG*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_date_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_date_assignment.snap index 78fd8eedec..689adec2eb 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_date_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_date_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -44,6 +45,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -55,9 +63,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_date_assignment_whit_short_datatype_names.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_date_assignment_whit_short_datatype_names.snap index 2dfff211da..918747cf66 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_date_assignment_whit_short_datatype_names.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_date_assignment_whit_short_datatype_names.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -41,6 +42,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -52,9 +60,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_floats_variable_and_comparison_assignment_generates_correctly.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_floats_variable_and_comparison_assignment_generates_correctly.snap index 5045d9b99a..a4627ffec5 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_floats_variable_and_comparison_assignment_generates_correctly.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_floats_variable_and_comparison_assignment_generates_correctly.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -54,6 +55,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -65,9 +73,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_local_temp_var_initialization.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_local_temp_var_initialization.snap index 64b2835d1b..fe2282f109 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_local_temp_var_initialization.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_local_temp_var_initialization.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -57,6 +58,20 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} + +define void @__user_init_foo(%foo* %0) { +entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -71,6 +86,8 @@ define void @__init___testproject() { entry: call void @__init_foo(%foo* @foo_instance) call void @__init_prg(%prg* @prg_instance) + call void @__user_init_foo(%foo* @foo_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } @@ -81,3 +98,7 @@ declare void @foo(%foo*) declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_foo(%foo*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_long_date_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_long_date_assignment.snap index 136055a64a..4e035a25cd 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_long_date_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_long_date_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -40,6 +41,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -51,9 +59,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_negated_combined_expressions_generates_void_function_and_struct_and_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_negated_combined_expressions_generates_void_function_and_struct_and_body.snap index 97cd368156..dcd58febc6 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_negated_combined_expressions_generates_void_function_and_struct_and_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_negated_combined_expressions_generates_void_function_and_struct_and_body.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -53,6 +54,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -64,9 +72,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_negated_expressions_generates_void_function_and_struct_and_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_negated_expressions_generates_void_function_and_struct_and_body.snap index 7b5f0c5a46..6256606de3 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_negated_expressions_generates_void_function_and_struct_and_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_negated_expressions_generates_void_function_and_struct_and_body.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -45,6 +46,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -56,9 +64,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_or_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_or_statement.snap index 0afd521fa4..2c3a842091 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_or_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_or_statement.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -41,6 +42,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -52,9 +60,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_additions.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_additions.snap index 189cb51e27..fe50184882 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_additions.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_additions.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -37,6 +38,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -48,9 +56,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_assignment.snap index f58a8a897b..8ebc7adc92 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -32,6 +33,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -43,9 +51,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_cast_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_cast_assignment.snap index ea343b4f19..d2db3c76b7 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_cast_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_cast_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -33,6 +34,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -44,9 +52,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_signed_combined_expressions.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_signed_combined_expressions.snap index 7e3a0379ff..9c8162e064 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_signed_combined_expressions.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_signed_combined_expressions.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -38,6 +39,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -49,9 +57,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_special_chars_in_string.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_special_chars_in_string.snap index 3f3fcd0e06..80f9cdc5eb 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_special_chars_in_string.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_special_chars_in_string.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -49,6 +50,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -60,9 +68,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_string_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_string_assignment.snap index 1eb04fc7cf..628377de15 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_string_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_string_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -41,6 +42,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -52,9 +60,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_time_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_time_assignment.snap index 4aeeffbcba..fa3b0dd897 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_time_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_time_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -38,6 +39,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -49,9 +57,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_time_of_day_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_time_of_day_assignment.snap index e2f273088b..ed1d821555 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_time_of_day_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_time_of_day_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -37,6 +38,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -48,9 +56,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_two_explicit_parameters_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_two_explicit_parameters_called_in_program.snap index 1d697f5da9..7d8dc8336d 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_two_explicit_parameters_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_two_explicit_parameters_called_in_program.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -51,6 +52,20 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} + +define void @__user_init_foo(%foo* %0) { +entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -65,6 +80,8 @@ define void @__init___testproject() { entry: call void @__init_foo(%foo* @foo_instance) call void @__init_prg(%prg* @prg_instance) + call void @__user_init_foo(%foo* @foo_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } @@ -75,3 +92,7 @@ declare void @foo(%foo*) declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_foo(%foo*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_two_parameters_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_two_parameters_called_in_program.snap index eacc8f2237..b29faaac51 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_two_parameters_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_two_parameters_called_in_program.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -51,6 +52,20 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} + +define void @__user_init_foo(%foo* %0) { +entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -65,6 +80,8 @@ define void @__init___testproject() { entry: call void @__init_foo(%foo* @foo_instance) call void @__init_prg(%prg* @prg_instance) + call void @__user_init_foo(%foo* @foo_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } @@ -75,3 +92,7 @@ declare void @foo(%foo*) declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_foo(%foo*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_inout_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_inout_called_in_program.snap index 0eaee4edc1..0afee40f87 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_inout_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_inout_called_in_program.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -56,6 +57,20 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} + +define void @__user_init_foo(%foo* %0) { +entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -70,6 +85,8 @@ define void @__init___testproject() { entry: call void @__init_foo(%foo* @foo_instance) call void @__init_prg(%prg* @prg_instance) + call void @__user_init_foo(%foo* @foo_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } @@ -80,3 +97,7 @@ declare void @foo(%foo*) declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_foo(%foo*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_out_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_out_called_in_program.snap index 5c9a7a09e3..0736f7c57c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_out_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_out_called_in_program.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -53,6 +54,20 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} + +define void @__user_init_foo(%foo* %0) { +entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -67,6 +82,8 @@ define void @__init___testproject() { entry: call void @__init_foo(%foo* @foo_instance) call void @__init_prg(%prg* @prg_instance) + call void @__user_init_foo(%foo* @foo_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } @@ -77,3 +94,7 @@ declare void @foo(%foo*) declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_foo(%foo*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_out_called_mixed_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_out_called_mixed_in_program.snap index 5c9a7a09e3..0736f7c57c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_out_called_mixed_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_out_called_mixed_in_program.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -53,6 +54,20 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} + +define void @__user_init_foo(%foo* %0) { +entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -67,6 +82,8 @@ define void @__init___testproject() { entry: call void @__init_foo(%foo* @foo_instance) call void @__init_prg(%prg* @prg_instance) + call void @__user_init_foo(%foo* @foo_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } @@ -77,3 +94,7 @@ declare void @foo(%foo*) declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_foo(%foo*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_addition_literal_generates_void_function_and_struct_and_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_addition_literal_generates_void_function_and_struct_and_body.snap index 45c96acc5b..c3ed35ed55 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_addition_literal_generates_void_function_and_struct_and_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_addition_literal_generates_void_function_and_struct_and_body.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -31,6 +32,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -42,9 +50,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_arithmatic_assignment_generates_void_function_and_struct_and_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_arithmatic_assignment_generates_void_function_and_struct_and_body.snap index f0cc216765..2171d1ad43 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_arithmatic_assignment_generates_void_function_and_struct_and_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_arithmatic_assignment_generates_void_function_and_struct_and_body.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -45,6 +46,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -56,9 +64,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_comparison_assignment_generates_void_function_and_struct_and_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_comparison_assignment_generates_void_function_and_struct_and_body.snap index 12d44faa14..9d13b1e5cd 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_comparison_assignment_generates_void_function_and_struct_and_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_comparison_assignment_generates_void_function_and_struct_and_body.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -54,6 +55,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -65,9 +73,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_assignment_generates_void_function_and_struct_and_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_assignment_generates_void_function_and_struct_and_body.snap index 9777abe7ad..c30526b4f3 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_assignment_generates_void_function_and_struct_and_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_assignment_generates_void_function_and_struct_and_body.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -30,6 +31,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -41,9 +49,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_and_additions_generates_void_function_and_struct_and_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_and_additions_generates_void_function_and_struct_and_body.snap index 18736c9ab9..4fd9a39e58 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_and_additions_generates_void_function_and_struct_and_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_and_additions_generates_void_function_and_struct_and_body.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -33,6 +34,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -44,9 +52,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_and_references_generates_void_function_and_struct_and_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_and_references_generates_void_function_and_struct_and_body.snap index 4ff968b283..403f3fca07 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_and_references_generates_void_function_and_struct_and_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_and_references_generates_void_function_and_struct_and_body.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -32,6 +33,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -43,9 +51,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_generates_void_function_and_struct.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_generates_void_function_and_struct.snap index 1d5ccb0992..65bb6a3f97 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_generates_void_function_and_struct.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_generates_void_function_and_struct.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -30,6 +31,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -41,9 +49,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_xor_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_xor_statement.snap index 43be1ce929..890ce133b5 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_xor_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_xor_statement.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -38,6 +39,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -49,9 +57,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_action_from_fb_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_action_from_fb_called_in_program.snap index 17ae0ca3e5..e96a6099fe 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_action_from_fb_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_action_from_fb_called_in_program.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -59,6 +60,23 @@ entry: store %fb* %0, %fb** %self, align 8 ret void } + +define void @__user_init_fb(%fb* %0) { +entry: + %self = alloca %fb*, align 8 + store %fb* %0, %fb** %self, align 8 + ret void +} + +define void @__user_init_bar(%bar* %0) { +entry: + %self = alloca %bar*, align 8 + store %bar* %0, %bar** %self, align 8 + %deref = load %bar*, %bar** %self, align 8 + %fb_inst = getelementptr inbounds %bar, %bar* %deref, i32 0, i32 0 + call void @__user_init_fb(%fb* %fb_inst) + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -72,6 +90,7 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_bar(%bar* @bar_instance) + call void @__user_init_bar(%bar* @bar_instance) ret void } @@ -80,3 +99,5 @@ declare void @__init_bar(%bar*) declare void @bar(%bar*) declare void @fb(%fb*) + +declare void @__user_init_bar(%bar*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_foreign_action_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_foreign_action_called_in_program.snap index 3a290a7ea8..e10189d8ad 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_foreign_action_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_foreign_action_called_in_program.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -55,6 +56,20 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_bar(%bar* %0) { +entry: + %self = alloca %bar*, align 8 + store %bar* %0, %bar** %self, align 8 + ret void +} + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -69,6 +84,8 @@ define void @__init___testproject() { entry: call void @__init_bar(%bar* @bar_instance) call void @__init_prg(%prg* @prg_instance) + call void @__user_init_bar(%bar* @bar_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } @@ -79,3 +96,7 @@ declare void @bar(%bar*) declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_bar(%bar*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_local_action_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_local_action_called_in_program.snap index abe2689e48..fde1fd48af 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_local_action_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_local_action_called_in_program.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -37,6 +38,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -48,9 +56,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__real_function_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__real_function_called_in_program.snap index f829a9c168..8610e1a92e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__real_function_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__real_function_called_in_program.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -41,6 +42,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -52,9 +60,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__reference_qualified_name.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__reference_qualified_name.snap index e0a5e333f8..71d9430800 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__reference_qualified_name.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__reference_qualified_name.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -78,6 +79,30 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_fb(%fb* %0) { +entry: + %self = alloca %fb*, align 8 + store %fb* %0, %fb** %self, align 8 + ret void +} + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} + +define void @__user_init_foo(%foo* %0) { +entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + %deref = load %foo*, %foo** %self, align 8 + %baz = getelementptr inbounds %foo, %foo* %deref, i32 0, i32 2 + call void @__user_init_fb(%fb* %baz) + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -94,6 +119,8 @@ define void @__init___testproject() { entry: call void @__init_foo(%foo* @foo_instance) call void @__init_prg(%prg* @prg_instance) + call void @__user_init_foo(%foo* @foo_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } @@ -106,3 +133,7 @@ declare void @fb(%fb*) declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_foo(%foo*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__reference_to_reference_assignments_in_function_arguments.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__reference_to_reference_assignments_in_function_arguments.snap index 3c678bb259..6276912ea3 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__reference_to_reference_assignments_in_function_arguments.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__reference_to_reference_assignments_in_function_arguments.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -71,6 +72,20 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} + +define void @__user_init_prog(%prog* %0) { +entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -93,6 +108,8 @@ entry: call void @__init_struct_params(%STRUCT_params* @global1) call void @__init_struct_params(%STRUCT_params* @global2) call void @__init_struct_params(%STRUCT_params* @global3) + call void @__user_init_prog(%prog* @prog_instance) + call void @__user_init_main(%main* @main_instance) ret void } @@ -105,3 +122,7 @@ declare void @__init_main(%main*) declare void @main(%main*) declare void @__init_struct_params(%STRUCT_params*) + +declare void @__user_init_prog(%prog*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__repeat_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__repeat_statement.snap index dbfe56f06b..6620662aa1 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__repeat_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__repeat_statement.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -50,6 +51,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -61,9 +69,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__returning_early_in_function_block.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__returning_early_in_function_block.snap index 55c3a36b3f..725b563e06 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__returning_early_in_function_block.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__returning_early_in_function_block.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -43,6 +44,13 @@ entry: } declare void @abcdef(%abcdef*) + +define void @__user_init_abcdef(%abcdef* %0) { +entry: + %self = alloca %abcdef*, align 8 + store %abcdef* %0, %abcdef** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__simple_case_i8_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__simple_case_i8_statement.snap index f6b96e6f98..d571880dbb 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__simple_case_i8_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__simple_case_i8_statement.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -54,6 +55,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -65,9 +73,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__simple_case_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__simple_case_statement.snap index 8847e78672..a861cbed57 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__simple_case_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__simple_case_statement.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -54,6 +55,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -65,9 +73,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__structs_members_can_be_referenced.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__structs_members_can_be_referenced.snap index d508516746..91c38553d2 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__structs_members_can_be_referenced.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__structs_members_can_be_referenced.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -45,6 +46,13 @@ entry: } declare void @MainProg(%MainProg*) + +define void @__user_init_MainProg(%MainProg* %0) { +entry: + %self = alloca %MainProg*, align 8 + store %MainProg* %0, %MainProg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -58,9 +66,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_mainprog(%MainProg* @MainProg_instance) + call void @__user_init_MainProg(%MainProg* @MainProg_instance) ret void } declare void @__init_mainprog(%MainProg*) declare void @MainProg(%MainProg*) + +declare void @__user_init_MainProg(%MainProg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_check_functions.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_check_functions.snap index 29204eb817..1481bc2b75 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_check_functions.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_check_functions.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -124,6 +125,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -135,9 +143,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_type_calls_check_function_missing.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_type_calls_check_function_missing.snap index a698d7f91d..8aaa44cb75 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_type_calls_check_function_missing.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_type_calls_check_function_missing.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -46,6 +47,13 @@ entry: } declare void @Main(%Main*) + +define void @__user_init_Main(%Main* %0) { +entry: + %self = alloca %Main*, align 8 + store %Main* %0, %Main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -57,9 +65,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%Main* @Main_instance) + call void @__user_init_Main(%Main* @Main_instance) ret void } declare void @__init_main(%Main*) declare void @Main(%Main*) + +declare void @__user_init_Main(%Main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_type_calls_check_function_on_assigment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_type_calls_check_function_on_assigment.snap index ffbf28da6b..b38231c906 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_type_calls_check_function_on_assigment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_type_calls_check_function_on_assigment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -47,6 +48,13 @@ entry: } declare void @Main(%Main*) + +define void @__user_init_Main(%Main* %0) { +entry: + %self = alloca %Main*, align 8 + store %Main* %0, %Main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -58,9 +66,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%Main* @Main_instance) + call void @__user_init_Main(%Main* @Main_instance) ret void } declare void @__init_main(%Main*) declare void @Main(%Main*) + +declare void @__user_init_Main(%Main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__time_variables_have_nano_seconds_resolution.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__time_variables_have_nano_seconds_resolution.snap index 0e2ae3e0ad..9230e743c1 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__time_variables_have_nano_seconds_resolution.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__time_variables_have_nano_seconds_resolution.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -33,6 +34,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -44,9 +52,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__two_global_variables_generates_in_separate_global_variables.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__two_global_variables_generates_in_separate_global_variables.snap index a3ced4bece..6166c62978 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__two_global_variables_generates_in_separate_global_variables.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__two_global_variables_generates_in_separate_global_variables.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -31,6 +32,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -42,9 +50,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__typed_enums_are_used_properly.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__typed_enums_are_used_properly.snap index 517f6d299d..6ba94a0ee4 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__typed_enums_are_used_properly.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__typed_enums_are_used_properly.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -43,6 +44,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -54,9 +62,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_cast_statement_as_const_expression.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_cast_statement_as_const_expression.snap index 29553d5349..1b8b14adb6 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_cast_statement_as_const_expression.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_cast_statement_as_const_expression.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -29,6 +30,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -40,9 +48,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_const_expression_in_range_type.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_const_expression_in_range_type.snap index a3d63b4c24..df6f3ac0e6 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_const_expression_in_range_type.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_const_expression_in_range_type.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -53,6 +54,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -64,9 +72,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_global_consts_in_expressions.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_global_consts_in_expressions.snap index 701504f3c7..6ba61539ee 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_global_consts_in_expressions.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_global_consts_in_expressions.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -33,6 +34,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -44,9 +52,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__variable_with_same_name_as_data_type.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__variable_with_same_name_as_data_type.snap index 7599213219..cc246c7ce0 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__variable_with_same_name_as_data_type.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__variable_with_same_name_as_data_type.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -39,6 +40,13 @@ entry: } declare void @prog(%prog*) + +define void @__user_init_prog(%prog* %0) { +entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -50,9 +58,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prog(%prog* @prog_instance) + call void @__user_init_prog(%prog* @prog_instance) ret void } declare void @__init_prog(%prog*) declare void @prog(%prog*) + +declare void @__user_init_prog(%prog*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_loop_with_if_exit.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_loop_with_if_exit.snap index 262889e107..8fad410879 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_loop_with_if_exit.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_loop_with_if_exit.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -68,6 +69,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -79,9 +87,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_statement.snap index e63b494d61..9f4bcc30eb 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_statement.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -51,6 +52,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -62,9 +70,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_with_expression_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_with_expression_statement.snap index 2ff52b115a..486da45e9e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_with_expression_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_with_expression_statement.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -54,6 +55,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -65,9 +73,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_datetime_types.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_datetime_types.snap index 038eb460c0..8789a68b5d 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_datetime_types.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_datetime_types.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/compare_instructions_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -56,6 +57,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -67,9 +75,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_instruction_functions_with_different_types.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_instruction_functions_with_different_types.snap index b6f60e83e2..d4d9a69611 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_instruction_functions_with_different_types.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_instruction_functions_with_different_types.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/compare_instructions_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -140,6 +141,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -151,9 +159,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_instructions_with_different_types.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_instructions_with_different_types.snap index 8f4a2234d4..ab053d3ec0 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_instructions_with_different_types.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_instructions_with_different_types.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/compare_instructions_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -113,6 +114,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -124,9 +132,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__pointer_compare_instructions.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__pointer_compare_instructions.snap index 7e862ef412..6cda5d31b2 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__pointer_compare_instructions.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__pointer_compare_instructions.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/compare_instructions_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -75,6 +76,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -86,9 +94,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__pointer_function_call_compare_instructions.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__pointer_function_call_compare_instructions.snap index 167ad36180..dca3eb9322 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__pointer_function_call_compare_instructions.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__pointer_function_call_compare_instructions.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/compare_instructions_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -76,6 +77,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -87,9 +95,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_array_variable.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_array_variable.snap index cea1c68713..1628950493 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_array_variable.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_array_variable.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/constants_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -37,6 +38,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -48,9 +56,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_string_variable.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_string_variable.snap index 20d72ce4ff..8f5852e782 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_string_variable.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_string_variable.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/constants_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -37,6 +38,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -48,9 +56,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_struct_variable.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_struct_variable.snap index a1e584b7ab..d2deffda12 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_struct_variable.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_struct_variable.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/constants_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -51,6 +52,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -66,6 +74,7 @@ define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) call void @__init_point(%Point* @const_strct) + call void @__user_init_main(%main* @main_instance) ret void } @@ -74,3 +83,5 @@ declare void @__init_main(%main*) declare void @main(%main*) declare void @__init_point(%Point*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__access_string_via_byte_array.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__access_string_via_byte_array.snap index a9ba5a7c94..b5b01023cc 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__access_string_via_byte_array.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__access_string_via_byte_array.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -35,6 +36,13 @@ entry: } declare void @baz(%baz*) + +define void @__user_init_baz(%baz* %0) { +entry: + %self = alloca %baz*, align 8 + store %baz* %0, %baz** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -46,9 +54,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_baz(%baz* @baz_instance) + call void @__user_init_baz(%baz* @baz_instance) ret void } declare void @__init_baz(%baz*) declare void @baz(%baz*) + +declare void @__user_init_baz(%baz*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__allowed_assignable_types.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__allowed_assignable_types.snap index 4fcbe1f8c8..4b4ba0237b 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__allowed_assignable_types.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__allowed_assignable_types.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -51,6 +52,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -62,9 +70,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_adr.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_adr.snap index a1048bc146..af5a2f50a6 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_adr.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_adr.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -31,6 +32,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -42,9 +50,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_lower_bound.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_lower_bound.snap index 835d8ceb58..4893817b21 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_lower_bound.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_lower_bound.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -59,6 +60,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -70,9 +78,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_move.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_move.snap index f6227f3a85..d91feb07e2 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_move.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_move.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -32,6 +33,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -43,9 +51,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_mux.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_mux.snap index 87304cbcf3..d43c7a31ef 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_mux.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_mux.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -64,6 +65,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -75,9 +83,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_mux_with_aggregate_type.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_mux_with_aggregate_type.snap index 6e0ddff6e0..ff916ed6b7 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_mux_with_aggregate_type.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_mux_with_aggregate_type.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -70,6 +71,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -81,9 +89,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_ref.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_ref.snap index a1048bc146..af5a2f50a6 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_ref.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_ref.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -31,6 +32,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -42,9 +50,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sel.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sel.snap index f479774957..96d88ff4fc 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sel.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sel.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -35,6 +36,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -46,9 +54,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sel_as_expression.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sel_as_expression.snap index 669afbbaa2..81cbc3d386 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sel_as_expression.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sel_as_expression.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -36,6 +37,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -47,9 +55,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sizeof.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sizeof.snap index e6f6c1540d..769949624b 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sizeof.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sizeof.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -31,6 +32,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -42,9 +50,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_upper_bound.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_upper_bound.snap index 166561e6ce..cb35f20822 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_upper_bound.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_upper_bound.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -59,6 +60,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -70,9 +78,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_upper_bound_expr.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_upper_bound_expr.snap index 5e57ceb0e9..e3bcc8f1c0 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_upper_bound_expr.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_upper_bound_expr.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -60,6 +61,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -71,9 +79,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__calling_strings_in_function_return.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__calling_strings_in_function_return.snap index 598a06db87..827ca595b9 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__calling_strings_in_function_return.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__calling_strings_in_function_return.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -56,6 +57,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -67,9 +75,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__cast_between_pointer_types.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__cast_between_pointer_types.snap index 9daa6a1df2..09da05303f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__cast_between_pointer_types.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__cast_between_pointer_types.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -32,6 +33,13 @@ entry: } declare void @baz(%baz*) + +define void @__user_init_baz(%baz* %0) { +entry: + %self = alloca %baz*, align 8 + store %baz* %0, %baz** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -43,9 +51,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_baz(%baz* @baz_instance) + call void @__user_init_baz(%baz* @baz_instance) ret void } declare void @__init_baz(%baz*) declare void @baz(%baz*) + +declare void @__user_init_baz(%baz*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__compare_date_time_literals.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__compare_date_time_literals.snap index 70890ecfed..6ee195c999 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__compare_date_time_literals.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__compare_date_time_literals.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -52,6 +53,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -63,9 +71,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__nested_call_statements.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__nested_call_statements.snap index 5537bf46b1..83fca4dd0d 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__nested_call_statements.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__nested_call_statements.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -40,6 +41,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -51,9 +59,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__pointer_arithmetics.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__pointer_arithmetics.snap index 2795a237c2..c03ecb1609 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__pointer_arithmetics.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__pointer_arithmetics.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -75,6 +76,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -86,9 +94,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__pointer_arithmetics_function_call.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__pointer_arithmetics_function_call.snap index 4020475e02..9f20918275 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__pointer_arithmetics_function_call.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__pointer_arithmetics_function_call.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -43,6 +44,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -54,9 +62,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__unary_expressions_can_be_real.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__unary_expressions_can_be_real.snap index 4824e1e8ed..7ca03785b5 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__unary_expressions_can_be_real.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__unary_expressions_can_be_real.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -34,6 +35,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -45,9 +53,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__unnecessary_casts_between_pointer_types.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__unnecessary_casts_between_pointer_types.snap index 9d05dc2163..e0bc2bfc03 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__unnecessary_casts_between_pointer_types.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__unnecessary_casts_between_pointer_types.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/expression_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -35,6 +36,13 @@ entry: } declare void @baz(%baz*) + +define void @__user_init_baz(%baz* %0) { +entry: + %self = alloca %baz*, align 8 + store %baz* %0, %baz** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -46,9 +54,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_baz(%baz* @baz_instance) + call void @__user_init_baz(%baz* @baz_instance) ret void } declare void @__init_baz(%baz*) declare void @baz(%baz*) + +declare void @__user_init_baz(%baz*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__autocast_argument_literals_for_function_call.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__autocast_argument_literals_for_function_call.snap index 1c8dce0b77..b14c7cd173 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__autocast_argument_literals_for_function_call.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__autocast_argument_literals_for_function_call.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/function_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -62,6 +63,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -73,9 +81,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__bitcast_argument_references_for_function_call.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__bitcast_argument_references_for_function_call.snap index 50ad7bbab5..0fe3d3655d 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__bitcast_argument_references_for_function_call.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__bitcast_argument_references_for_function_call.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/function_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -116,6 +117,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -127,9 +135,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_ref_sized_string_varargs_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_ref_sized_string_varargs_called_in_program.snap index 8f6bcb6981..165c5c2476 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_ref_sized_string_varargs_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_ref_sized_string_varargs_called_in_program.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/function_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -44,6 +45,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -55,9 +63,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_sized_varargs_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_sized_varargs_called_in_program.snap index 5f8a9d48e5..4ccbc835b5 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_sized_varargs_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_sized_varargs_called_in_program.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/function_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -43,6 +44,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -54,9 +62,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_varargs_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_varargs_called_in_program.snap index c3d9a51a8d..47c576efd0 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_varargs_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_varargs_called_in_program.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/function_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -35,6 +36,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -46,9 +54,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__literal_string_argument_passed_by_ref.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__literal_string_argument_passed_by_ref.snap index b9255433f1..4ec2795500 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__literal_string_argument_passed_by_ref.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__literal_string_argument_passed_by_ref.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/function_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -49,6 +50,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -60,9 +68,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_a_string_to_a_function.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_a_string_to_a_function.snap index ade06cd119..ff37ff7fd7 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_a_string_to_a_function.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_a_string_to_a_function.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/function_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -54,6 +55,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -65,9 +73,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_a_string_to_a_function_as_reference.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_a_string_to_a_function_as_reference.snap index 473969fb17..3267dbae47 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_a_string_to_a_function_as_reference.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_a_string_to_a_function_as_reference.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/function_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -43,6 +44,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -54,9 +62,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_arguments_to_functions_by_ref_and_val.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_arguments_to_functions_by_ref_and_val.snap index d01b1be95f..990478a5b4 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_arguments_to_functions_by_ref_and_val.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_arguments_to_functions_by_ref_and_val.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/function_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -62,6 +63,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -73,9 +81,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__simple_call.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__simple_call.snap index c244959e71..0a35f33545 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__simple_call.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__simple_call.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/function_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -45,6 +46,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -56,9 +64,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__var_output_in_function_call.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__var_output_in_function_call.snap index 42f6dc49e3..58f1e7806b 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__var_output_in_function_call.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__var_output_in_function_call.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/function_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -43,6 +44,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -54,9 +62,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__any_real_function_called_with_ints.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__any_real_function_called_with_ints.snap index 8629627452..7670dc6050 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__any_real_function_called_with_ints.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__any_real_function_called_with_ints.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/generics_test.rs expression: codegen(src) +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -72,6 +73,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -83,9 +91,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__generic_function_call_generates_real_type_call.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__generic_function_call_generates_real_type_call.snap index 8c8a6bae82..01d99fd685 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__generic_function_call_generates_real_type_call.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__generic_function_call_generates_real_type_call.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/generics_test.rs expression: prg +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -48,6 +49,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -59,9 +67,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__generic_output_parameter.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__generic_output_parameter.snap index 480da20fc3..c38e9fd547 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__generic_output_parameter.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__generic_output_parameter.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/generics_test.rs expression: codegen(src) +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -46,6 +47,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -57,9 +65,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__fb_accepts_empty_statement_as_input_param.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__fb_accepts_empty_statement_as_input_param.snap index 639f5888b0..256830ddc3 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__fb_accepts_empty_statement_as_input_param.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__fb_accepts_empty_statement_as_input_param.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -55,6 +56,23 @@ entry: } declare void @main(%main*) + +define void @__user_init_fb_t(%fb_t* %0) { +entry: + %self = alloca %fb_t*, align 8 + store %fb_t* %0, %fb_t** %self, align 8 + ret void +} + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + %deref = load %main*, %main** %self, align 8 + %fb = getelementptr inbounds %main, %main* %deref, i32 0, i32 0 + call void @__user_init_fb_t(%fb_t* %fb) + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -68,6 +86,7 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } @@ -76,3 +95,5 @@ declare void @__init_main(%main*) declare void @main(%main*) declare void @fb_t(%fb_t*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__fb_accepts_empty_statement_as_output_param.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__fb_accepts_empty_statement_as_output_param.snap index 3577d0e498..be1d364946 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__fb_accepts_empty_statement_as_output_param.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__fb_accepts_empty_statement_as_output_param.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -57,6 +58,23 @@ entry: } declare void @main(%main*) + +define void @__user_init_fb_t(%fb_t* %0) { +entry: + %self = alloca %fb_t*, align 8 + store %fb_t* %0, %fb_t** %self, align 8 + ret void +} + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + %deref = load %main*, %main** %self, align 8 + %fb = getelementptr inbounds %main, %main* %deref, i32 0, i32 0 + call void @__user_init_fb_t(%fb_t* %fb) + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -70,6 +88,7 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } @@ -78,3 +97,5 @@ declare void @__init_main(%main*) declare void @main(%main*) declare void @fb_t(%fb_t*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_accepts_empty_statement_as_input_param.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_accepts_empty_statement_as_input_param.snap index cdc830a805..0da53e4baa 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_accepts_empty_statement_as_input_param.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_accepts_empty_statement_as_input_param.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -40,6 +41,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -51,9 +59,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_accepts_empty_statement_as_output_param.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_accepts_empty_statement_as_output_param.snap index 139d425819..9ff6069f66 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_accepts_empty_statement_as_output_param.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_accepts_empty_statement_as_output_param.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -40,6 +41,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -51,9 +59,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_all_parameters_assigned.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_all_parameters_assigned.snap index 096a0ac698..5f02d24175 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_all_parameters_assigned.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_all_parameters_assigned.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -51,6 +52,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -62,9 +70,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_default_value_parameter_type.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_default_value_parameter_type.snap index 4ef65cd182..0dc6d26536 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_default_value_parameter_type.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_default_value_parameter_type.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -52,6 +53,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -63,9 +71,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_inout_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_inout_assignment.snap index 5cf23f7a47..40d33d38ec 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_inout_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_inout_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -48,6 +49,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -59,9 +67,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_input_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_input_assignment.snap index 2d0339b8fd..76be23e300 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_input_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_input_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -48,6 +49,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -59,9 +67,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_output_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_output_assignment.snap index 7be06e0bba..04e99fc1a4 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_output_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_output_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -48,6 +49,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -59,9 +67,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_output_default_value_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_output_default_value_assignment.snap index b06c2fce33..8c7ee11f2e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_output_default_value_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_output_default_value_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -49,6 +50,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -60,9 +68,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_inout_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_inout_assignment.snap index 5cf23f7a47..40d33d38ec 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_inout_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_inout_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -48,6 +49,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -59,9 +67,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_input_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_input_assignment.snap index 2d0339b8fd..76be23e300 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_input_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_input_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -48,6 +49,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -59,9 +67,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_input_default_value_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_input_default_value_assignment.snap index 727c78830f..618d2f612c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_input_default_value_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_input_default_value_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -46,6 +47,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -57,9 +65,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_output_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_output_assignment.snap index 7be06e0bba..04e99fc1a4 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_output_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_output_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -48,6 +49,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -59,9 +67,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_output_default_value_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_output_default_value_assignment.snap index b06c2fce33..8c7ee11f2e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_output_default_value_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_output_default_value_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -49,6 +50,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -60,9 +68,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__parameters_behind_function_block_pointer_are_assigned_to.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__parameters_behind_function_block_pointer_are_assigned_to.snap index 53f32c6a82..cd00ea83e5 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__parameters_behind_function_block_pointer_are_assigned_to.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__parameters_behind_function_block_pointer_are_assigned_to.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -58,6 +59,23 @@ entry: store %file_t* %0, %file_t** %self, align 8 ret void } + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + %deref = load %main*, %main** %self, align 8 + %file = getelementptr inbounds %main, %main* %deref, i32 0, i32 0 + call void @__user_init_file_t(%file_t* %file) + ret void +} + +define void @__user_init_file_t(%file_t* %0) { +entry: + %self = alloca %file_t*, align 8 + store %file_t* %0, %file_t** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -71,6 +89,7 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } @@ -79,3 +98,5 @@ declare void @__init_main(%main*) declare void @main(%main*) declare void @file_t(%file_t*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_accepts_empty_statement_as_input_param.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_accepts_empty_statement_as_input_param.snap index e20def74a4..2dd6488805 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_accepts_empty_statement_as_input_param.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_accepts_empty_statement_as_input_param.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -50,6 +51,20 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} + +define void @__user_init_prog(%prog* %0) { +entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -64,6 +79,8 @@ define void @__init___testproject() { entry: call void @__init_prog(%prog* @prog_instance) call void @__init_main(%main* @main_instance) + call void @__user_init_prog(%prog* @prog_instance) + call void @__user_init_main(%main* @main_instance) ret void } @@ -74,3 +91,7 @@ declare void @prog(%prog*) declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_prog(%prog*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_accepts_empty_statement_as_output_param.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_accepts_empty_statement_as_output_param.snap index a34dd55524..290dfd9398 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_accepts_empty_statement_as_output_param.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_accepts_empty_statement_as_output_param.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -54,6 +55,20 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} + +define void @__user_init_prog(%prog* %0) { +entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -68,6 +83,8 @@ define void @__init___testproject() { entry: call void @__init_prog(%prog* @prog_instance) call void @__init_main(%main* @main_instance) + call void @__user_init_prog(%prog* @prog_instance) + call void @__user_init_main(%main* @main_instance) ret void } @@ -78,3 +95,7 @@ declare void @prog(%prog*) declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_prog(%prog*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_all_parameters_assigned_explicit.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_all_parameters_assigned_explicit.snap index eb32d92c97..1111c5d2ae 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_all_parameters_assigned_explicit.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_all_parameters_assigned_explicit.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -64,6 +65,20 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} + +define void @__user_init_prog(%prog* %0) { +entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -78,6 +93,8 @@ define void @__init___testproject() { entry: call void @__init_prog(%prog* @prog_instance) call void @__init_main(%main* @main_instance) + call void @__user_init_prog(%prog* @prog_instance) + call void @__user_init_main(%main* @main_instance) ret void } @@ -88,3 +105,7 @@ declare void @prog(%prog*) declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_prog(%prog*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_all_parameters_assigned_implicit.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_all_parameters_assigned_implicit.snap index a432cd7e33..b1e94b021d 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_all_parameters_assigned_implicit.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_all_parameters_assigned_implicit.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -58,6 +59,20 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} + +define void @__user_init_prog(%prog* %0) { +entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -72,6 +87,8 @@ define void @__init___testproject() { entry: call void @__init_prog(%prog* @prog_instance) call void @__init_main(%main* @main_instance) + call void @__user_init_prog(%prog* @prog_instance) + call void @__user_init_main(%main* @main_instance) ret void } @@ -82,3 +99,7 @@ declare void @prog(%prog*) declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_prog(%prog*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_empty_inout_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_empty_inout_assignment.snap index 14091daaea..b5d8ed4203 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_empty_inout_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_empty_inout_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -59,6 +60,20 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} + +define void @__user_init_prog(%prog* %0) { +entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -73,6 +88,8 @@ define void @__init___testproject() { entry: call void @__init_prog(%prog* @prog_instance) call void @__init_main(%main* @main_instance) + call void @__user_init_prog(%prog* @prog_instance) + call void @__user_init_main(%main* @main_instance) ret void } @@ -83,3 +100,7 @@ declare void @prog(%prog*) declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_prog(%prog*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_missing_input_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_missing_input_assignment.snap index eb51ec2c19..e079281f09 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_missing_input_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_missing_input_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -56,6 +57,20 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} + +define void @__user_init_prog(%prog* %0) { +entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -70,6 +85,8 @@ define void @__init___testproject() { entry: call void @__init_prog(%prog* @prog_instance) call void @__init_main(%main* @main_instance) + call void @__user_init_prog(%prog* @prog_instance) + call void @__user_init_main(%main* @main_instance) ret void } @@ -80,3 +97,7 @@ declare void @prog(%prog*) declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_prog(%prog*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_missing_output_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_missing_output_assignment.snap index b5e56bf85a..382203d840 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_missing_output_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_missing_output_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -56,6 +57,20 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} + +define void @__user_init_prog(%prog* %0) { +entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -70,6 +85,8 @@ define void @__init___testproject() { entry: call void @__init_prog(%prog* @prog_instance) call void @__init_main(%main* @main_instance) + call void @__user_init_prog(%prog* @prog_instance) + call void @__user_init_main(%main* @main_instance) ret void } @@ -80,3 +97,7 @@ declare void @prog(%prog*) declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_prog(%prog*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__var_in_out_params_can_be_out_of_order.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__var_in_out_params_can_be_out_of_order.snap index 43bd8a7a32..23d75a7b73 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__var_in_out_params_can_be_out_of_order.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__var_in_out_params_can_be_out_of_order.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/parameters_tests.rs expression: res +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -87,6 +88,23 @@ entry: store %fb_t* %0, %fb_t** %self, align 8 ret void } + +define void @__user_init_fb_t(%fb_t* %0) { +entry: + %self = alloca %fb_t*, align 8 + store %fb_t* %0, %fb_t** %self, align 8 + ret void +} + +define void @__user_init_mainProg(%mainProg* %0) { +entry: + %self = alloca %mainProg*, align 8 + store %mainProg* %0, %mainProg** %self, align 8 + %deref = load %mainProg*, %mainProg** %self, align 8 + %fb = getelementptr inbounds %mainProg, %mainProg* %deref, i32 0, i32 0 + call void @__user_init_fb_t(%fb_t* %fb) + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -100,6 +118,7 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_mainprog(%mainProg* @mainProg_instance) + call void @__user_init_mainProg(%mainProg* @mainProg_instance) ret void } @@ -108,3 +127,5 @@ declare void @__init_mainprog(%mainProg*) declare void @mainProg(%mainProg*) declare void @fb_t(%fb_t*) + +declare void @__user_init_mainProg(%mainProg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__bitaccess_generated_as_rsh_and_trunc_i1.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__bitaccess_generated_as_rsh_and_trunc_i1.snap index 584e0c91fc..891ea521b1 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__bitaccess_generated_as_rsh_and_trunc_i1.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__bitaccess_generated_as_rsh_and_trunc_i1.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/statement_codegen_test.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -41,6 +42,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -52,9 +60,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__byteaccess_generated_as_rsh_and_trunc_i8.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__byteaccess_generated_as_rsh_and_trunc_i8.snap index 0ad5ad012c..c08d49a466 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__byteaccess_generated_as_rsh_and_trunc_i8.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__byteaccess_generated_as_rsh_and_trunc_i8.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/statement_codegen_test.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -43,6 +44,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -54,9 +62,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__dwordaccess_generated_as_rsh_and_trunc_i32.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__dwordaccess_generated_as_rsh_and_trunc_i32.snap index 8953b537f5..fa2ae2cbaf 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__dwordaccess_generated_as_rsh_and_trunc_i32.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__dwordaccess_generated_as_rsh_and_trunc_i32.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/statement_codegen_test.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -43,6 +44,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -54,9 +62,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__nested_bitwise_access.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__nested_bitwise_access.snap index c9f5448c79..c199f7c838 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__nested_bitwise_access.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__nested_bitwise_access.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/statement_codegen_test.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -40,6 +41,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -51,9 +59,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__variable_based_bitwise_access.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__variable_based_bitwise_access.snap index eea8a14643..74556c112b 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__variable_based_bitwise_access.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__variable_based_bitwise_access.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/statement_codegen_test.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -44,6 +45,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -55,9 +63,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__wordaccess_generated_as_rsh_and_trunc_i16.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__wordaccess_generated_as_rsh_and_trunc_i16.snap index 7a3798978a..724f257511 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__wordaccess_generated_as_rsh_and_trunc_i16.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__wordaccess_generated_as_rsh_and_trunc_i16.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/statement_codegen_test.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -43,6 +44,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -54,9 +62,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__casted_string_assignment_uses_memcpy.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__casted_string_assignment_uses_memcpy.snap index af6fd35b45..885dd09e5d 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__casted_string_assignment_uses_memcpy.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__casted_string_assignment_uses_memcpy.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/string_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -45,6 +46,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -56,9 +64,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_returning_generic_string_should_return_by_ref.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_returning_generic_string_should_return_by_ref.snap index c064df4504..635e499dc8 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_returning_generic_string_should_return_by_ref.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_returning_generic_string_should_return_by_ref.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/string_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -64,6 +65,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -75,9 +83,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_returns_a_literal_string.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_returns_a_literal_string.snap index c0edc8b03d..fb8652a487 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_returns_a_literal_string.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_returns_a_literal_string.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/string_tests.rs expression: program +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -56,6 +57,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -67,9 +75,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_takes_string_paramter_and_returns_string.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_takes_string_paramter_and_returns_string.snap index 08cb46914b..7c34766f55 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_takes_string_paramter_and_returns_string.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_takes_string_paramter_and_returns_string.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/string_tests.rs expression: program +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -64,6 +65,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -75,9 +83,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_string_output.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_string_output.snap index e8599e5e16..a815eef505 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_string_output.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_string_output.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/string_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -66,6 +67,20 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} + +define void @__user_init_prog(%prog* %0) { +entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -80,6 +95,8 @@ define void @__init___testproject() { entry: call void @__init_prog(%prog* @prog_instance) call void @__init_main(%main* @main_instance) + call void @__user_init_prog(%prog* @prog_instance) + call void @__user_init_main(%main* @main_instance) ret void } @@ -90,3 +107,7 @@ declare void @prog(%prog*) declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_prog(%prog*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_with_casted_string_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_with_casted_string_assignment.snap index 95c54d43f2..a3aff8bb1e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_with_casted_string_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_with_casted_string_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/string_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -43,6 +44,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -54,9 +62,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_with_string_type_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_with_string_type_assignment.snap index fc3a460f1b..afbe9b33ad 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_with_string_type_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_with_string_type_assignment.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/string_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -49,6 +50,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -62,9 +70,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__string_function_parameters.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__string_function_parameters.snap index 65b051e635..19d7fb55a7 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__string_function_parameters.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__string_function_parameters.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/string_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -68,6 +69,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -79,9 +87,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_length_strings_can_be_created.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_length_strings_can_be_created.snap index 680951a731..7f29f36f37 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_length_strings_can_be_created.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_length_strings_can_be_created.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/string_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -45,6 +46,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -56,9 +64,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_length_strings_using_constants_can_be_created.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_length_strings_using_constants_can_be_created.snap index 3f1ef99b4f..91dadd2f29 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_length_strings_using_constants_can_be_created.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_length_strings_using_constants_can_be_created.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/string_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -47,6 +48,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -58,9 +66,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_string_assignment_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_string_assignment_test.snap index fb91c310d4..484524ca3f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_string_assignment_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_string_assignment_test.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/string_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -42,6 +43,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -53,9 +61,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__vartmp_string_init_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__vartmp_string_init_test.snap index 1a54ad37a4..aea3b6cb93 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__vartmp_string_init_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__vartmp_string_init_test.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/string_tests.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -44,6 +45,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -55,9 +63,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__aliased_datatypes_respect_conversion_rules.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__aliased_datatypes_respect_conversion_rules.snap index e3ccbd97c6..30984edeea 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__aliased_datatypes_respect_conversion_rules.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__aliased_datatypes_respect_conversion_rules.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/typesystem_test.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -41,6 +42,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -52,9 +60,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__datatypes_larger_than_int_promote_the_second_operand.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__datatypes_larger_than_int_promote_the_second_operand.snap index a3e57d17d6..c56ddf1416 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__datatypes_larger_than_int_promote_the_second_operand.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__datatypes_larger_than_int_promote_the_second_operand.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/typesystem_test.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -36,6 +37,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -47,9 +55,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__datatypes_smaller_than_dint_promoted_to_dint.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__datatypes_smaller_than_dint_promoted_to_dint.snap index 77e3d58fad..34622c1a10 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__datatypes_smaller_than_dint_promoted_to_dint.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__datatypes_smaller_than_dint_promoted_to_dint.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/typesystem_test.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -36,6 +37,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -47,9 +55,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__even_all_sint_expressions_fallback_to_dint.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__even_all_sint_expressions_fallback_to_dint.snap index 50b6647616..752deac0c9 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__even_all_sint_expressions_fallback_to_dint.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__even_all_sint_expressions_fallback_to_dint.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/typesystem_test.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -38,6 +39,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -49,9 +57,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_and_double_mix_converted_to_double.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_and_double_mix_converted_to_double.snap index faf6c26e3e..2ff3806124 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_and_double_mix_converted_to_double.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_and_double_mix_converted_to_double.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/typesystem_test.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -36,6 +37,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -47,9 +55,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_assigned_to_int_is_cast.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_assigned_to_int_is_cast.snap index 9ea5503a2f..0b6715bcd4 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_assigned_to_int_is_cast.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_assigned_to_int_is_cast.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/typesystem_test.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -37,6 +38,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -48,9 +56,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_assinged_to_double_to_double.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_assinged_to_double_to_double.snap index d4fd023e43..7872cc2a09 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_assinged_to_double_to_double.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_assinged_to_double_to_double.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/typesystem_test.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -33,6 +34,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -44,9 +52,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_assigned_to_float_is_cast.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_assigned_to_float_is_cast.snap index a64a236985..174c5366df 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_assigned_to_float_is_cast.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_assigned_to_float_is_cast.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/typesystem_test.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -37,6 +38,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -48,9 +56,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_bigger_than_byte_promoted_on_compare_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_bigger_than_byte_promoted_on_compare_statement.snap index 3d3d123a5f..a7532fa0a7 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_bigger_than_byte_promoted_on_compare_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_bigger_than_byte_promoted_on_compare_statement.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/typesystem_test.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -34,6 +35,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -45,9 +53,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_bigger_than_float_converted_to_double.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_bigger_than_float_converted_to_double.snap index 12595076f1..957a48bdd0 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_bigger_than_float_converted_to_double.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_bigger_than_float_converted_to_double.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/typesystem_test.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -35,6 +36,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -46,9 +54,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_smaller_or_equal_to_float_converted_to_float.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_smaller_or_equal_to_float_converted_to_float.snap index e6e07046c3..3f0ce8278c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_smaller_or_equal_to_float_converted_to_float.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_smaller_or_equal_to_float_converted_to_float.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/typesystem_test.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -36,6 +37,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -47,9 +55,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__numerical_promotion_for_variadic_functions_without_declaration.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__numerical_promotion_for_variadic_functions_without_declaration.snap index db4be1252f..a689933fce 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__numerical_promotion_for_variadic_functions_without_declaration.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__numerical_promotion_for_variadic_functions_without_declaration.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/typesystem_test.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -52,6 +53,13 @@ entry: } declare void @main(%main*) + +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -63,9 +71,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) + +declare void @__user_init_main(%main*) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__unsingned_datatypes_smaller_than_dint_promoted_to_dint.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__unsingned_datatypes_smaller_than_dint_promoted_to_dint.snap index dd753c1566..c5754123b9 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__unsingned_datatypes_smaller_than_dint_promoted_to_dint.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__unsingned_datatypes_smaller_than_dint_promoted_to_dint.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/typesystem_test.rs expression: result +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -36,6 +37,13 @@ entry: } declare void @prg(%prg*) + +define void @__user_init_prg(%prg* %0) { +entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void +} ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -47,9 +55,12 @@ source_filename = "__init___testproject" define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + +declare void @__user_init_prg(%prg*) diff --git a/src/lowering.rs b/src/lowering.rs index 2ab68df24b..c53f09eaa5 100644 --- a/src/lowering.rs +++ b/src/lowering.rs @@ -2,7 +2,7 @@ use crate::{ index::{get_init_fn_name, Index, PouIndexEntry, VariableIndexEntry}, resolver::const_evaluator::UnresolvableConstant, }; -use initializers::{Init, InitAssignments, Initializers, GLOBAL_SCOPE}; +use initializers::{get_user_init_fn_name, Init, InitAssignments, Initializers, GLOBAL_SCOPE}; use plc_ast::{ ast::{ AstFactory, AstNode, AstStatement, CallStatement, CompilationUnit, ConfigVariable, DataType, @@ -12,6 +12,7 @@ use plc_ast::{ provider::IdProvider, }; use plc_source::source_location::SourceLocation; +use rustc_hash::FxHashMap; pub mod calls; mod initializers; @@ -21,6 +22,7 @@ pub struct InitVisitor { index: Index, unresolved_initializers: Initializers, var_config_initializers: Vec, + user_inits: FxHashMap, ctxt: Context, } @@ -50,6 +52,7 @@ impl InitVisitor { index, unresolved_initializers: Initializers::new(&unresolved_initializers), var_config_initializers: vec![], + user_inits: FxHashMap::default(), ctxt: Context::new(id_provider), } } @@ -213,30 +216,37 @@ impl InitVisitor { }) }); - // collect necessary call statements to init-functions - let delegated_calls = self - .index - .get_pou_members(&implementation.name) - .iter() - .filter(|var| predicate(var)) - .filter_map(|var| { + // collect necessary call statements to init-functions and user-defined init-functions + let mut implicit_calls = Vec::new(); + let mut user_init_calls = Vec::new(); + self.index.get_pou_members(&implementation.name).iter().filter(|var| predicate(var)).for_each( + |var| { let dti = self.index.get_effective_type_or_void_by_name(var.get_type_name()).get_type_information(); if dti.is_struct() { - Some(create_call_statement( + implicit_calls.push(create_call_statement( &get_init_fn_name(dti.get_name()), var.get_name(), None, self.ctxt.get_id_provider(), &implementation.name_location, - )) - } else { - None + )); + } + if self.user_inits.contains_key(dti.get_name()) { + user_init_calls.push(create_call_statement( + &get_user_init_fn_name(dti.get_name()), + var.get_name(), + None, + self.ctxt.get_id_provider(), + &implementation.name_location, + )); } - }); + }, + ); let stmts = assignments - .chain(delegated_calls) + .chain(implicit_calls) + .chain(user_init_calls) .chain(std::mem::take(&mut implementation.statements)) .collect::>(); implementation.statements = stmts; @@ -339,6 +349,12 @@ impl AstVisitorMut for InitVisitor { self.unresolved_initializers.maybe_insert_initializer(&pou.name, None, &None); } + if matches!(pou.kind, PouType::FunctionBlock | PouType::Program) { + // add the POU to potential `FB_INIT` candidates + self.user_inits + .insert(pou.name.to_owned(), self.index.find_method(&pou.name, "fb_init").is_some()); + } + self.walk_with_scope(pou, Some(&pou.name.to_owned())); } } diff --git a/src/lowering/initializers.rs b/src/lowering/initializers.rs index 98410dc79d..45e76eecb5 100644 --- a/src/lowering/initializers.rs +++ b/src/lowering/initializers.rs @@ -145,6 +145,7 @@ fn create_init_units(lowerer: &InitVisitor) -> Vec { create_init_unit(lowerer, container, init, &lookup) }) + .chain(create_user_init_units(lowerer)) .collect() } @@ -195,22 +196,6 @@ fn create_init_unit( }) .collect::>(); - if let Some(fbinit) = lowerer - .index - .find_method(container_name, "fb_init") - .and_then(|it| it.find_implementation(&lowerer.index)) - { - let base = create_member_reference("self", id_provider.clone(), None); - let op = create_member_reference( - &fbinit.get_call_name().rsplit_once('.').map(|(_, name)| name).unwrap(), - id_provider.clone(), - Some(base), - ); - let call_statement = - AstFactory::create_call_statement(op, None, id_provider.next_id(), location.clone()); - statements.push(call_statement); - } - let member_init_calls = lowerer .index .get_container_members(container_name) @@ -244,6 +229,69 @@ fn create_init_unit( Some(new_unit(init_pou, implementation, INIT_COMPILATION_UNIT)) } +fn create_user_init_units(lowerer: &InitVisitor) -> Vec { + lowerer + .user_inits + .iter() + .map(|(container_name, has_fb_init)| { + let location = SourceLocation::internal_in_unit(Some(INIT_COMPILATION_UNIT)); + let mut id_provider = lowerer.ctxt.get_id_provider(); + let param = vec![VariableBlock::default() + .with_block_type(VariableBlockType::InOut) + .with_variables(vec![Variable { + name: "self".into(), + data_type_declaration: DataTypeDeclaration::Reference { + referenced_type: container_name.to_string(), + location: location.clone(), + }, + initializer: None, + address: None, + location: location.clone(), + }])]; + + let fn_name = get_user_init_fn_name(container_name); + let init_pou = new_pou(&fn_name, id_provider.next_id(), param, PouType::Init, &location); + + let mut statements = lowerer + .index + .get_container_members(container_name) + .iter() + .filter_map(|member| { + let member_type_name = member.get_type_name(); + let type_name = lowerer + .index + .get_effective_type_by_name(member_type_name) + .map(|it| it.get_type_information().get_name()) + .unwrap_or(member_type_name); + let call_name = get_user_init_fn_name(type_name); + if !member.is_temp() && lowerer.user_inits.contains_key(type_name) { + Some(create_call_statement( + &call_name, + member.get_name(), + Some("self"), + id_provider.clone(), + &location, + )) + } else { + None + } + }) + .collect::>(); + + if *has_fb_init { + let base = create_member_reference("self", id_provider.clone(), None); + let op = create_member_reference("fb_init", id_provider.clone(), Some(base)); + let call_statement = + AstFactory::create_call_statement(op, None, id_provider.next_id(), location.clone()); + statements.push(call_statement); + } + let implementation = new_implementation(&fn_name, statements, PouType::Init, location); + + new_unit(init_pou, implementation, INIT_COMPILATION_UNIT) + }) + .collect() +} + fn create_init_wrapper_function( lowerer: &mut InitVisitor, init_symbol_name: &'static str, @@ -290,7 +338,7 @@ fn create_init_wrapper_function( } }); - let mut assignments = if let Some(stmts) = lowerer.unresolved_initializers.get(GLOBAL_SCOPE) { + let mut statements = if let Some(stmts) = lowerer.unresolved_initializers.get(GLOBAL_SCOPE) { stmts .iter() .filter_map(|(var_name, initializer)| { @@ -314,10 +362,10 @@ fn create_init_wrapper_function( }) .collect::>(); - assignments.extend(calls); + statements.extend(calls); if !skip_var_config { - assignments.push(AstFactory::create_call_statement( + statements.push(AstFactory::create_call_statement( create_member_reference(VAR_CONFIG_INIT, id_provider.clone(), None), None, id_provider.next_id(), @@ -325,8 +373,10 @@ fn create_init_wrapper_function( )); }; + let user_init_calls = get_global_user_init_statements(lowerer); + statements.extend(user_init_calls); let implementation = - new_implementation(init_symbol_name, assignments, PouType::ProjectInit, SourceLocation::internal()); + new_implementation(init_symbol_name, statements, PouType::ProjectInit, SourceLocation::internal()); let mut global_init = new_unit(init_pou, implementation, init_symbol_name); if skip_var_config { @@ -339,6 +389,50 @@ fn create_init_wrapper_function( Some(global_init) } +fn get_global_user_init_statements(lowerer: &InitVisitor) -> Vec { + let global_instances = if let Some(global_instances) = + lowerer.unresolved_initializers.get(GLOBAL_SCOPE).map(|it| { + it.keys().filter_map(|var_name| { + lowerer.index.find_variable(None, &[var_name]).and_then(|it| { + lowerer.index.find_effective_type_by_name(it.get_type_name()).and_then(|dt| { + let name = dt.get_type_information().get_name(); + if lowerer.user_inits.contains_key(name) { + Some((get_user_init_fn_name(name), var_name)) + } else { + None + } + }) + }) + }) + }) { + global_instances.collect::>() + } else { + vec![] + }; + + let programs = lowerer.unresolved_initializers.iter().filter_map(|(scope, _)| { + if lowerer.index.find_pou(scope).is_some_and(|pou| pou.is_program()) { + Some((get_user_init_fn_name(scope), scope)) + } else { + None + } + }); + let mut id_provider = lowerer.ctxt.id_provider.clone(); + programs + .chain(global_instances) + .map(|(fn_name, param)| { + let op = create_member_reference(&fn_name, lowerer.ctxt.id_provider.clone(), None); + let param = create_member_reference(param, lowerer.ctxt.id_provider.clone(), None); + AstFactory::create_call_statement( + op, + Some(param), + id_provider.next_id(), + SourceLocation::internal(), + ) + }) + .collect::>() +} + fn new_pou( name: &str, id: AstId, @@ -396,3 +490,7 @@ fn new_unit(pou: Pou, implementation: Implementation, file_name: &'static str) - file: FileMarker::Internal(file_name), } } + +pub(super) fn get_user_init_fn_name(type_name: &str) -> String { + format!("__user_init_{}", type_name) +} diff --git a/src/resolver/tests/resolve_and_lower_init_functions.rs b/src/resolver/tests/resolve_and_lower_init_functions.rs index 2183d5b246..e042085f41 100644 --- a/src/resolver/tests/resolve_and_lower_init_functions.rs +++ b/src/resolver/tests/resolve_and_lower_init_functions.rs @@ -229,9 +229,9 @@ fn init_wrapper_function_created() { // we expect this function to have no parameters assert!(init.pous[0].variable_blocks.is_empty()); - // we expect to the body to have 2 statements + // we expect to the body to have 3 statements let statements = &implementation.statements; - assert_eq!(statements.len(), 2); + assert_eq!(statements.len(), 3); // we expect the first statement in the function-body to assign `REF(s)` to `gs`, since // global variables are to be initialized first @@ -292,6 +292,30 @@ fn init_wrapper_function_created() { } "###); + // we expect the third statement to call `__user_init_foo`, which checks for user-defined init functions and calls them + assert_debug_snapshot!(statements[2], @r#" + CallStatement { + operator: ReferenceExpr { + kind: Member( + Identifier { + name: "__user_init_foo", + }, + ), + base: None, + }, + parameters: Some( + ReferenceExpr { + kind: Member( + Identifier { + name: "foo", + }, + ), + base: None, + }, + ), + } + "#); + // since `foo` has a member-instance of `bar`, we expect its initializer to call/propagate to `__init_bar` with its local member let init_foo = &units[1].implementations[1]; assert_debug_snapshot!(init_foo.statements[0], @r###" diff --git a/src/tests/adr/arrays_adr.rs b/src/tests/adr/arrays_adr.rs index 96e129564f..0f43fcb607 100644 --- a/src/tests/adr/arrays_adr.rs +++ b/src/tests/adr/arrays_adr.rs @@ -103,6 +103,13 @@ fn assigning_full_arrays() { } declare void @prg(%prg*) + + define void @__user_init_prg(%prg* %0) { + entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -115,12 +122,15 @@ fn assigning_full_arrays() { define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + + declare void @__user_init_prg(%prg*) "#); } @@ -186,6 +196,13 @@ fn accessing_array_elements() { } declare void @prg(%prg*) + + define void @__user_init_prg(%prg* %0) { + entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -198,11 +215,14 @@ fn accessing_array_elements() { define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) + + declare void @__user_init_prg(%prg*) "#); } diff --git a/src/tests/adr/enum_adr.rs b/src/tests/adr/enum_adr.rs index 6d9d7a0e6b..49263b450b 100644 --- a/src/tests/adr/enum_adr.rs +++ b/src/tests/adr/enum_adr.rs @@ -115,7 +115,7 @@ fn using_enums() { END_PROGRAM "#; - insta::assert_snapshot!(codegen(src), @r###" + insta::assert_snapshot!(codegen(src), @r#" ; ModuleID = '' source_filename = "" @@ -154,6 +154,13 @@ fn using_enums() { } declare void @prg(%prg*) + + define void @__user_init_prg(%prg* %0) { + entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -165,11 +172,14 @@ fn using_enums() { define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) - "###); + + declare void @__user_init_prg(%prg*) + "#); } diff --git a/src/tests/adr/initializer_functions_adr.rs b/src/tests/adr/initializer_functions_adr.rs index 4d90969373..dd31b5d5b9 100644 --- a/src/tests/adr/initializer_functions_adr.rs +++ b/src/tests/adr/initializer_functions_adr.rs @@ -349,7 +349,7 @@ fn global_initializers_are_wrapped_in_single_init_function() { let init_impl = &units[2].implementations[0]; assert_eq!(&init_impl.name, "__init___testproject"); - assert_eq!(init_impl.statements.len(), 4); + assert_eq!(init_impl.statements.len(), 7); // global variable blocks are initialized first, hence we expect the first statement in the `__init` body to be an // `Assignment`, assigning `REF(s)` to `gs`. This is followed by three `CallStatements`, one for each global `PROGRAM` // instance. @@ -553,7 +553,7 @@ fn generating_init_functions() { "; let res = codegen(src); - assert_snapshot!(res, @r###" + assert_snapshot!(res, @r#" ; ModuleID = '' source_filename = "" @@ -641,6 +641,33 @@ fn generating_init_functions() { } declare void @baz(%baz*) + + define void @__user_init_bar(%bar* %0) { + entry: + %self = alloca %bar*, align 8 + store %bar* %0, %bar** %self, align 8 + %deref = load %bar*, %bar** %self, align 8 + %fb = getelementptr inbounds %bar, %bar* %deref, i32 0, i32 0 + call void @__user_init_foo(%foo* %fb) + ret void + } + + define void @__user_init_baz(%baz* %0) { + entry: + %self = alloca %baz*, align 8 + store %baz* %0, %baz** %self, align 8 + %deref = load %baz*, %baz** %self, align 8 + %fb = getelementptr inbounds %baz, %baz* %deref, i32 0, i32 0 + call void @__user_init_bar(%bar* %fb) + ret void + } + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -660,6 +687,7 @@ fn generating_init_functions() { entry: call void @__init_baz(%baz* @baz_instance) call void @__init_mystruct(%myStruct* @s) + call void @__user_init_baz(%baz* @baz_instance) ret void } @@ -672,7 +700,9 @@ fn generating_init_functions() { declare void @foo(%foo*) declare void @__init_mystruct(%myStruct*) - "###); + + declare void @__user_init_baz(%baz*) + "#); } /// When dealing with local stack-allocated variables (`VAR_TEMP`-blocks (in addition to `VAR` for functions)), @@ -708,7 +738,7 @@ fn intializing_temporary_variables() { "; let res = codegen(src); - assert_snapshot!(res, @r###" + assert_snapshot!(res, @r#" ; ModuleID = '' source_filename = "" @@ -741,6 +771,7 @@ fn intializing_temporary_variables() { store [81 x i8]* @ps, [81 x i8]** %s, align 8 store [81 x i8]* @ps2, [81 x i8]** %s2, align 8 call void @__init_foo(%foo* %fb) + call void @__user_init_foo(%foo* %fb) call void @foo(%foo* %fb) %main_ret = load i32, i32* %main, align 4 ret i32 %main_ret @@ -748,6 +779,8 @@ fn intializing_temporary_variables() { declare void @__init_foo(%foo*) + declare void @__user_init_foo(%foo*) + ; Function Attrs: argmemonly nofree nounwind willreturn declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0 @@ -771,6 +804,13 @@ fn intializing_temporary_variables() { } declare void @foo(%foo*) + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -780,7 +820,7 @@ fn intializing_temporary_variables() { entry: ret void } - "###) + "#) } /// Initializing method variables behaves very similar to stack local variables from the previous example. @@ -802,7 +842,7 @@ fn initializing_method_variables() { END_FUNCTION_BLOCK "; - insta::assert_snapshot!(codegen(src), @r###" + insta::assert_snapshot!(codegen(src), @r#" ; ModuleID = '' source_filename = "" @@ -839,6 +879,13 @@ fn initializing_method_variables() { } declare void @foo(%foo*) + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -848,7 +895,7 @@ fn initializing_method_variables() { entry: ret void } - "###); + "#); // When no local reference is found, the parent variable is used if present. Otherwise we look for a // global variable. @@ -923,6 +970,13 @@ fn initializing_method_variables() { } declare void @foo(%foo*) + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -989,6 +1043,13 @@ fn initializing_method_variables() { } declare void @foo(%foo*) + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" diff --git a/src/tests/adr/pou_adr.rs b/src/tests/adr/pou_adr.rs index f1c790d2e9..543067006b 100644 --- a/src/tests/adr/pou_adr.rs +++ b/src/tests/adr/pou_adr.rs @@ -249,7 +249,7 @@ fn programs_state_is_stored_in_a_struct() { #[test] fn codegen_of_a_program_pou() { - insta::assert_snapshot!(codegen(DEFAULT_PRG),@r###" + insta::assert_snapshot!(codegen(DEFAULT_PRG),@r#" ; ModuleID = '' source_filename = "" @@ -282,6 +282,13 @@ fn codegen_of_a_program_pou() { } declare void @main_prg(%main_prg*) + + define void @__user_init_main_prg(%main_prg* %0) { + entry: + %self = alloca %main_prg*, align 8 + store %main_prg* %0, %main_prg** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -293,13 +300,16 @@ fn codegen_of_a_program_pou() { define void @__init___testproject() { entry: call void @__init_main_prg(%main_prg* @main_prg_instance) + call void @__user_init_main_prg(%main_prg* @main_prg_instance) ret void } declare void @__init_main_prg(%main_prg*) declare void @main_prg(%main_prg*) - "###); + + declare void @__user_init_main_prg(%main_prg*) + "#); } /// Calling a program works like this: @@ -319,7 +329,7 @@ fn calling_a_program() { {DEFAULT_PRG} "# ); - insta::assert_snapshot!(codegen(calling_prg.as_str()), @r###" + insta::assert_snapshot!(codegen(calling_prg.as_str()), @r#" ; ModuleID = '' source_filename = "" @@ -369,6 +379,13 @@ fn calling_a_program() { } declare void @main_prg(%main_prg*) + + define void @__user_init_main_prg(%main_prg* %0) { + entry: + %self = alloca %main_prg*, align 8 + store %main_prg* %0, %main_prg** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -380,13 +397,16 @@ fn calling_a_program() { define void @__init___testproject() { entry: call void @__init_main_prg(%main_prg* @main_prg_instance) + call void @__user_init_main_prg(%main_prg* @main_prg_instance) ret void } declare void @__init_main_prg(%main_prg*) declare void @main_prg(%main_prg*) - "###); + + declare void @__user_init_main_prg(%main_prg*) + "#); } /// # FUNCTION BLOCK @@ -414,7 +434,7 @@ const DEFAULT_FB: &str = r#" #[test] fn function_blocks_get_a_method_with_a_self_parameter() { - insta::assert_snapshot!(codegen(DEFAULT_FB), @r###" + insta::assert_snapshot!(codegen(DEFAULT_FB), @r#" ; ModuleID = '' source_filename = "" @@ -447,6 +467,13 @@ fn function_blocks_get_a_method_with_a_self_parameter() { } declare void @main_fb(%main_fb*) + + define void @__user_init_main_fb(%main_fb* %0) { + entry: + %self = alloca %main_fb*, align 8 + store %main_fb* %0, %main_fb** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -456,7 +483,7 @@ fn function_blocks_get_a_method_with_a_self_parameter() { entry: ret void } - "###); + "#); } /// Calling a function block works like this: @@ -477,7 +504,7 @@ fn calling_a_function_block() { {DEFAULT_FB} "# ); - insta::assert_snapshot!(codegen(calling_prg.as_str()), @r###" + insta::assert_snapshot!(codegen(calling_prg.as_str()), @r#" ; ModuleID = '' source_filename = "" @@ -542,6 +569,23 @@ fn calling_a_function_block() { store %main_fb* %0, %main_fb** %self, align 8 ret void } + + define void @__user_init_main_fb(%main_fb* %0) { + entry: + %self = alloca %main_fb*, align 8 + store %main_fb* %0, %main_fb** %self, align 8 + ret void + } + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + %deref = load %foo*, %foo** %self, align 8 + %fb = getelementptr inbounds %foo, %foo* %deref, i32 0, i32 2 + call void @__user_init_main_fb(%main_fb* %fb) + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -555,6 +599,7 @@ fn calling_a_function_block() { define void @__init___testproject() { entry: call void @__init_foo(%foo* @foo_instance) + call void @__user_init_foo(%foo* @foo_instance) ret void } @@ -563,7 +608,9 @@ fn calling_a_function_block() { declare void @foo(%foo*) declare void @main_fb(%main_fb*) - "###); + + declare void @__user_init_foo(%foo*) + "#); } /// # FUNCTION @@ -636,7 +683,7 @@ fn calling_a_function() { {DEFAULT_FUNC} "# ); - insta::assert_snapshot!(codegen(calling_prg.as_str()), @r###" + insta::assert_snapshot!(codegen(calling_prg.as_str()), @r#" ; ModuleID = '' source_filename = "" @@ -686,6 +733,13 @@ fn calling_a_function() { } declare void @prg(%prg*) + + define void @__user_init_prg(%prg* %0) { + entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -697,13 +751,16 @@ fn calling_a_function() { define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) - "###); + + declare void @__user_init_prg(%prg*) + "#); } /// Returning complex/aggregate types (string, array, struct) from a function cost a lot of compile-performance. complex types @@ -730,7 +787,7 @@ fn return_a_complex_type_from_function() { s := foo(); END_FUNCTION "#; - insta::assert_snapshot!(codegen(returning_string), @r###" + insta::assert_snapshot!(codegen(returning_string), @r#" ; ModuleID = '' source_filename = "" @@ -785,6 +842,13 @@ fn return_a_complex_type_from_function() { } declare void @prg(%prg*) + + define void @__user_init_prg(%prg* %0) { + entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -796,13 +860,16 @@ fn return_a_complex_type_from_function() { define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) - "###); + + declare void @__user_init_prg(%prg*) + "#); } /// Aggregate types which are passed to a function by-value will be passed as a reference by the compiler. @@ -843,7 +910,7 @@ fn passing_aggregate_types_to_functions_by_value() { "###; //internally we pass the two strings str1, and str2 as pointers to StrEqual because of the {ref} - insta::assert_snapshot!(codegen(src), @r###" + insta::assert_snapshot!(codegen(src), @r#" ; ModuleID = '' source_filename = "" @@ -926,6 +993,13 @@ fn passing_aggregate_types_to_functions_by_value() { } declare void @main(%main*) + + define void @__user_init_main(%main* %0) { + entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -939,13 +1013,16 @@ fn passing_aggregate_types_to_functions_by_value() { define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) - "###); + + declare void @__user_init_main(%main*) + "#); } /// Passing aggregate types to a function is an expensive operation, this is why the compiler offers @@ -975,7 +1052,7 @@ fn passing_by_ref_to_functions() { "###; //internally we pass the two strings str1, and str2 as pointers to StrEqual because of the {ref} - insta::assert_snapshot!(codegen(src), @r###" + insta::assert_snapshot!(codegen(src), @r#" ; ModuleID = '' source_filename = "" @@ -1019,6 +1096,13 @@ fn passing_by_ref_to_functions() { } declare void @main(%main*) + + define void @__user_init_main(%main* %0) { + entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -1030,11 +1114,14 @@ fn passing_by_ref_to_functions() { define void @__init___testproject() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } declare void @__init_main(%main*) declare void @main(%main*) - "###); + + declare void @__user_init_main(%main*) + "#); } diff --git a/src/tests/adr/strings_adr.rs b/src/tests/adr/strings_adr.rs index 0700dc659b..8915277d88 100644 --- a/src/tests/adr/strings_adr.rs +++ b/src/tests/adr/strings_adr.rs @@ -62,7 +62,7 @@ fn assigning_strings() { "#; // ... the assignments will be performed as a memcpy - insta::assert_snapshot!(codegen(src), @r###" + insta::assert_snapshot!(codegen(src), @r#" ; ModuleID = '' source_filename = "" @@ -99,6 +99,13 @@ fn assigning_strings() { } declare void @prg(%prg*) + + define void @__user_init_prg(%prg* %0) { + entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -110,13 +117,16 @@ fn assigning_strings() { define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) - "###); + + declare void @__user_init_prg(%prg*) + "#); } /// STRING literals will be generated as global constants, so they can be used as a source of a memcpy @@ -135,7 +145,7 @@ fn assigning_string_literals() { "#; // ... will be initialized directly in the variable's definition - insta::assert_snapshot!(codegen(src), @r###" + insta::assert_snapshot!(codegen(src), @r#" ; ModuleID = '' source_filename = "" @@ -175,6 +185,13 @@ fn assigning_string_literals() { } declare void @prg(%prg*) + + define void @__user_init_prg(%prg* %0) { + entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -186,11 +203,14 @@ fn assigning_string_literals() { define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) - "###); + + declare void @__user_init_prg(%prg*) + "#); } diff --git a/src/tests/adr/structs_adr.rs b/src/tests/adr/structs_adr.rs index 115653f656..49d1079df8 100644 --- a/src/tests/adr/structs_adr.rs +++ b/src/tests/adr/structs_adr.rs @@ -140,7 +140,7 @@ fn initializing_a_struct() { "#; // ... will be initialized directly in the variable's definition - insta::assert_snapshot!(codegen(src), @r###" + insta::assert_snapshot!(codegen(src), @r#" ; ModuleID = '' source_filename = "" @@ -205,6 +205,13 @@ fn initializing_a_struct() { } declare void @prg(%prg*) + + define void @__user_init_prg(%prg* %0) { + entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -220,13 +227,16 @@ fn initializing_a_struct() { define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) - "###); + + declare void @__user_init_prg(%prg*) + "#); } /// Structs are aggregate types. This means that passing them to functions and assigning them @@ -253,7 +263,7 @@ fn assigning_structs() { "#; // ... the assignment p1 := p2 will be performed as a memcpy - insta::assert_snapshot!(codegen(src), @r###" + insta::assert_snapshot!(codegen(src), @r#" ; ModuleID = '' source_filename = "" @@ -307,6 +317,13 @@ fn assigning_structs() { } declare void @prg(%prg*) + + define void @__user_init_prg(%prg* %0) { + entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -320,13 +337,16 @@ fn assigning_structs() { define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) - "###); + + declare void @__user_init_prg(%prg*) + "#); } /// Accessing STRUCT's members uses the LLVM GEP statement to get a pointer @@ -358,7 +378,7 @@ fn accessing_struct_members() { "#; // ... will be initialized directly in the variable's definition - insta::assert_snapshot!(codegen(src), @r###" + insta::assert_snapshot!(codegen(src), @r#" ; ModuleID = '' source_filename = "" @@ -427,6 +447,13 @@ fn accessing_struct_members() { } declare void @prg(%prg*) + + define void @__user_init_prg(%prg* %0) { + entry: + %self = alloca %prg*, align 8 + store %prg* %0, %prg** %self, align 8 + ret void + } ; ModuleID = '__init___testproject' source_filename = "__init___testproject" @@ -442,11 +469,14 @@ fn accessing_struct_members() { define void @__init___testproject() { entry: call void @__init_prg(%prg* @prg_instance) + call void @__user_init_prg(%prg* @prg_instance) ret void } declare void @__init_prg(%prg*) declare void @prg(%prg*) - "###); + + declare void @__user_init_prg(%prg*) + "#); } diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__actions_debug.snap b/tests/integration/snapshots/tests__integration__cfc__ir__actions_debug.snap index f265533ff7..2605fc0979 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__actions_debug.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__actions_debug.snap @@ -1,6 +1,7 @@ --- source: tests/integration/cfc.rs expression: output_file_content_without_headers +snapshot_kind: text --- %main = type { i32, i32 } @@ -50,9 +51,17 @@ entry: ret void } +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} + define void @__init___plc() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return.snap b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return.snap index ec537c437d..2938a5a281 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return.snap @@ -1,6 +1,7 @@ --- source: tests/integration/cfc.rs expression: output_file_content_without_headers +snapshot_kind: text --- %conditional_return = type { i32 } @@ -29,6 +30,13 @@ entry: ret void } +define void @__user_init_conditional_return(%conditional_return* %0) { +entry: + %self = alloca %conditional_return*, align 8 + store %conditional_return* %0, %conditional_return** %self, align 8 + ret void +} + define void @__init___plc() { entry: ret void diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true.snap b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true.snap index 74638796d3..6c5202c5ef 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true.snap @@ -1,6 +1,7 @@ --- source: tests/integration/cfc.rs expression: output_file_content_without_headers +snapshot_kind: text --- %conditional_return = type { i32 } @@ -53,6 +54,13 @@ entry: ret void } +define void @__user_init_conditional_return(%conditional_return* %0) { +entry: + %self = alloca %conditional_return*, align 8 + store %conditional_return* %0, %conditional_return** %self, align 8 + ret void +} + define void @__init___plc() { entry: ret void diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true_negated.snap b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true_negated.snap index 6a0ec004aa..cbe9d93a93 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true_negated.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true_negated.snap @@ -1,6 +1,7 @@ --- source: tests/integration/cfc.rs expression: output_file_content_without_headers +snapshot_kind: text --- %conditional_return = type { i32 } @@ -54,6 +55,13 @@ entry: ret void } +define void @__user_init_conditional_return(%conditional_return* %0) { +entry: + %self = alloca %conditional_return*, align 8 + store %conditional_return* %0, %conditional_return** %self, align 8 + ret void +} + define void @__init___plc() { entry: ret void diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__jump_debug.snap b/tests/integration/snapshots/tests__integration__cfc__ir__jump_debug.snap index 91abc495ef..f550a61ff9 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__jump_debug.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__jump_debug.snap @@ -1,6 +1,7 @@ --- source: tests/integration/cfc.rs expression: output_file_content_without_headers +snapshot_kind: text --- %foo = type { i32 } @@ -33,9 +34,17 @@ entry: ret void } +define void @__user_init_foo(%foo* %0) { +entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void +} + define void @__init___plc() { entry: call void @__init_foo(%foo* @foo_instance) + call void @__user_init_foo(%foo* @foo_instance) ret void } diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__sink_source_debug.snap b/tests/integration/snapshots/tests__integration__cfc__ir__sink_source_debug.snap index 78b2db812e..0acd5b2ed9 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__sink_source_debug.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__sink_source_debug.snap @@ -1,6 +1,7 @@ --- source: tests/integration/cfc.rs expression: output_file_content_without_headers +snapshot_kind: text --- %main = type { i32 } @@ -25,9 +26,17 @@ entry: ret void } +define void @__user_init_main(%main* %0) { +entry: + %self = alloca %main*, align 8 + store %main* %0, %main** %self, align 8 + ret void +} + define void @__init___plc() { entry: call void @__init_main(%main* @main_instance) + call void @__user_init_main(%main* @main_instance) ret void } From d67dad65ad4f5e39b7b2b367f0739325e6f94c04 Mon Sep 17 00:00:00 2001 From: Michael Haselberger Date: Tue, 15 Apr 2025 11:03:11 +0200 Subject: [PATCH 3/9] update snapshots --- .../src/tests/inheritance_tests.rs | 24 +- src/codegen/tests/oop_tests/super_tests.rs | 275 ++++++++++++++++++ 2 files changed, 297 insertions(+), 2 deletions(-) diff --git a/compiler/plc_lowering/src/tests/inheritance_tests.rs b/compiler/plc_lowering/src/tests/inheritance_tests.rs index 6fc747c6ca..a6ab636c7c 100644 --- a/compiler/plc_lowering/src/tests/inheritance_tests.rs +++ b/compiler/plc_lowering/src/tests/inheritance_tests.rs @@ -1533,7 +1533,7 @@ mod units_tests { let (_, project) = parse_and_annotate("test", vec![src]).unwrap(); let unit = &project.units[0].get_unit().implementations[3]; - assert_debug_snapshot!(unit, @r###" + assert_debug_snapshot!(unit, @r#" Implementation { name: "main", type_name: "main", @@ -1560,6 +1560,26 @@ mod units_tests { }, ), }, + CallStatement { + operator: ReferenceExpr { + kind: Member( + Identifier { + name: "__user_init_child", + }, + ), + base: None, + }, + parameters: Some( + ReferenceExpr { + kind: Member( + Identifier { + name: "fb", + }, + ), + base: None, + }, + ), + }, Assignment { left: ReferenceExpr { kind: Deref, @@ -1721,7 +1741,7 @@ mod units_tests { generic: false, access: None, } - "###) + "#) } #[test] diff --git a/src/codegen/tests/oop_tests/super_tests.rs b/src/codegen/tests/oop_tests/super_tests.rs index b13ab2a4ee..82547ebb86 100644 --- a/src/codegen/tests/oop_tests/super_tests.rs +++ b/src/codegen/tests/oop_tests/super_tests.rs @@ -58,6 +58,23 @@ fn super_keyword_basic_access() { ret void } + define void @__user_init_child(%child* %0) { + entry: + %self = alloca %child*, align 8 + store %child* %0, %child** %self, align 8 + %deref = load %child*, %child** %self, align 8 + %__parent = getelementptr inbounds %child, %child* %deref, i32 0, i32 0 + call void @__user_init_parent(%parent* %__parent) + ret void + } + + define void @__user_init_parent(%parent* %0) { + entry: + %self = alloca %parent*, align 8 + store %parent* %0, %parent** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void @@ -126,6 +143,23 @@ fn super_without_deref() { ret void } + define void @__user_init_child(%child* %0) { + entry: + %self = alloca %child*, align 8 + store %child* %0, %child** %self, align 8 + %deref = load %child*, %child** %self, align 8 + %__parent = getelementptr inbounds %child, %child* %deref, i32 0, i32 0 + call void @__user_init_parent(%parent* %__parent) + ret void + } + + define void @__user_init_parent(%parent* %0) { + entry: + %self = alloca %parent*, align 8 + store %parent* %0, %parent** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void @@ -239,6 +273,23 @@ fn super_in_method_calls() { ret void } + define void @__user_init_child(%child* %0) { + entry: + %self = alloca %child*, align 8 + store %child* %0, %child** %self, align 8 + %deref = load %child*, %child** %self, align 8 + %__parent = getelementptr inbounds %child, %child* %deref, i32 0, i32 0 + call void @__user_init_parent(%parent* %__parent) + ret void + } + + define void @__user_init_parent(%parent* %0) { + entry: + %self = alloca %parent*, align 8 + store %parent* %0, %parent** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void @@ -318,6 +369,23 @@ fn super_in_complex_expressions() { ret void } + define void @__user_init_child(%child* %0) { + entry: + %self = alloca %child*, align 8 + store %child* %0, %child** %self, align 8 + %deref = load %child*, %child** %self, align 8 + %__parent = getelementptr inbounds %child, %child* %deref, i32 0, i32 0 + call void @__user_init_parent(%parent* %__parent) + ret void + } + + define void @__user_init_parent(%parent* %0) { + entry: + %self = alloca %parent*, align 8 + store %parent* %0, %parent** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void @@ -393,6 +461,23 @@ fn super_with_array_access() { ret void } + define void @__user_init_child(%child* %0) { + entry: + %self = alloca %child*, align 8 + store %child* %0, %child** %self, align 8 + %deref = load %child*, %child** %self, align 8 + %__parent = getelementptr inbounds %child, %child* %deref, i32 0, i32 0 + call void @__user_init_parent(%parent* %__parent) + ret void + } + + define void @__user_init_parent(%parent* %0) { + entry: + %self = alloca %parent*, align 8 + store %parent* %0, %parent** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void @@ -536,6 +621,33 @@ fn super_in_multi_level_inheritance() { ret void } + define void @__user_init_grandparent(%grandparent* %0) { + entry: + %self = alloca %grandparent*, align 8 + store %grandparent* %0, %grandparent** %self, align 8 + ret void + } + + define void @__user_init_child(%child* %0) { + entry: + %self = alloca %child*, align 8 + store %child* %0, %child** %self, align 8 + %deref = load %child*, %child** %self, align 8 + %__parent = getelementptr inbounds %child, %child* %deref, i32 0, i32 0 + call void @__user_init_parent(%parent* %__parent) + ret void + } + + define void @__user_init_parent(%parent* %0) { + entry: + %self = alloca %parent*, align 8 + store %parent* %0, %parent** %self, align 8 + %deref = load %parent*, %parent** %self, align 8 + %__grandparent = getelementptr inbounds %parent, %parent* %deref, i32 0, i32 0 + call void @__user_init_grandparent(%grandparent* %__grandparent) + ret void + } + define void @__init___Test() { entry: ret void @@ -614,6 +726,23 @@ fn super_with_pointer_operations() { ret void } + define void @__user_init_child(%child* %0) { + entry: + %self = alloca %child*, align 8 + store %child* %0, %child** %self, align 8 + %deref = load %child*, %child** %self, align 8 + %__parent = getelementptr inbounds %child, %child* %deref, i32 0, i32 0 + call void @__user_init_parent(%parent* %__parent) + ret void + } + + define void @__user_init_parent(%parent* %0) { + entry: + %self = alloca %parent*, align 8 + store %parent* %0, %parent** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void @@ -740,6 +869,23 @@ fn super_in_conditionals() { ret void } + define void @__user_init_child(%child* %0) { + entry: + %self = alloca %child*, align 8 + store %child* %0, %child** %self, align 8 + %deref = load %child*, %child** %self, align 8 + %__parent = getelementptr inbounds %child, %child* %deref, i32 0, i32 0 + call void @__user_init_parent(%parent* %__parent) + ret void + } + + define void @__user_init_parent(%parent* %0) { + entry: + %self = alloca %parent*, align 8 + store %parent* %0, %parent** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void @@ -809,6 +955,23 @@ fn super_with_const_variables() { ret void } + define void @__user_init_child(%child* %0) { + entry: + %self = alloca %child*, align 8 + store %child* %0, %child** %self, align 8 + %deref = load %child*, %child** %self, align 8 + %__parent = getelementptr inbounds %child, %child* %deref, i32 0, i32 0 + call void @__user_init_parent(%parent* %__parent) + ret void + } + + define void @__user_init_parent(%parent* %0) { + entry: + %self = alloca %parent*, align 8 + store %parent* %0, %parent** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void @@ -927,6 +1090,23 @@ fn super_as_function_parameter() { ret void } + define void @__user_init_child(%child* %0) { + entry: + %self = alloca %child*, align 8 + store %child* %0, %child** %self, align 8 + %deref = load %child*, %child** %self, align 8 + %__parent = getelementptr inbounds %child, %child* %deref, i32 0, i32 0 + call void @__user_init_parent(%parent* %__parent) + ret void + } + + define void @__user_init_parent(%parent* %0) { + entry: + %self = alloca %parent*, align 8 + store %parent* %0, %parent** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void @@ -1053,6 +1233,23 @@ fn super_with_deeply_nested_expressions() { ret void } + define void @__user_init_child(%child* %0) { + entry: + %self = alloca %child*, align 8 + store %child* %0, %child** %self, align 8 + %deref = load %child*, %child** %self, align 8 + %__parent = getelementptr inbounds %child, %child* %deref, i32 0, i32 0 + call void @__user_init_parent(%parent* %__parent) + ret void + } + + define void @__user_init_parent(%parent* %0) { + entry: + %self = alloca %parent*, align 8 + store %parent* %0, %parent** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void @@ -1264,6 +1461,23 @@ fn super_in_loop_constructs() { ret void } + define void @__user_init_child(%child* %0) { + entry: + %self = alloca %child*, align 8 + store %child* %0, %child** %self, align 8 + %deref = load %child*, %child** %self, align 8 + %__parent = getelementptr inbounds %child, %child* %deref, i32 0, i32 0 + call void @__user_init_parent(%parent* %__parent) + ret void + } + + define void @__user_init_parent(%parent* %0) { + entry: + %self = alloca %parent*, align 8 + store %parent* %0, %parent** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void @@ -1390,6 +1604,33 @@ fn super_with_method_overrides_in_three_levels() { ret void } + define void @__user_init_grandparent(%grandparent* %0) { + entry: + %self = alloca %grandparent*, align 8 + store %grandparent* %0, %grandparent** %self, align 8 + ret void + } + + define void @__user_init_child(%child* %0) { + entry: + %self = alloca %child*, align 8 + store %child* %0, %child** %self, align 8 + %deref = load %child*, %child** %self, align 8 + %__parent = getelementptr inbounds %child, %child* %deref, i32 0, i32 0 + call void @__user_init_parent(%parent* %__parent) + ret void + } + + define void @__user_init_parent(%parent* %0) { + entry: + %self = alloca %parent*, align 8 + store %parent* %0, %parent** %self, align 8 + %deref = load %parent*, %parent** %self, align 8 + %__grandparent = getelementptr inbounds %parent, %parent* %deref, i32 0, i32 0 + call void @__user_init_grandparent(%grandparent* %__grandparent) + ret void + } + define void @__init___Test() { entry: ret void @@ -1574,6 +1815,23 @@ fn super_with_structured_types() { ret void } + define void @__user_init_child(%child* %0) { + entry: + %self = alloca %child*, align 8 + store %child* %0, %child** %self, align 8 + %deref = load %child*, %child** %self, align 8 + %__parent = getelementptr inbounds %child, %child* %deref, i32 0, i32 0 + call void @__user_init_parent(%parent* %__parent) + ret void + } + + define void @__user_init_parent(%parent* %0) { + entry: + %self = alloca %parent*, align 8 + store %parent* %0, %parent** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void @@ -1672,6 +1930,23 @@ fn super_in_action_blocks() { ret void } + define void @__user_init_child(%child* %0) { + entry: + %self = alloca %child*, align 8 + store %child* %0, %child** %self, align 8 + %deref = load %child*, %child** %self, align 8 + %__parent = getelementptr inbounds %child, %child* %deref, i32 0, i32 0 + call void @__user_init_parent(%parent* %__parent) + ret void + } + + define void @__user_init_parent(%parent* %0) { + entry: + %self = alloca %parent*, align 8 + store %parent* %0, %parent** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void From c755d85baf55831919005851b83edacad674ac69 Mon Sep 17 00:00:00 2001 From: Michael Haselberger Date: Tue, 15 Apr 2025 12:30:27 +0200 Subject: [PATCH 4/9] add struct support, tests --- src/codegen/tests/debug_tests.rs | 22 +- .../complex_initializers.rs | 239 ++++++++++++++++++ src/codegen/tests/oop_tests/super_tests.rs | 11 + ...var_nested_struct_added_to_debug_info.snap | 19 ++ ...global_var_struct_added_to_debug_info.snap | 9 + src/lowering.rs | 3 + src/tests/adr/initializer_functions_adr.rs | 34 ++- tests/lit/single/init/user_init.st | 29 +++ 8 files changed, 358 insertions(+), 8 deletions(-) create mode 100644 tests/lit/single/init/user_init.st diff --git a/src/codegen/tests/debug_tests.rs b/src/codegen/tests/debug_tests.rs index a3a4fc622b..91d86b89eb 100644 --- a/src/codegen/tests/debug_tests.rs +++ b/src/codegen/tests/debug_tests.rs @@ -599,7 +599,7 @@ END_FUNCTION ", ); - assert_snapshot!(result, @r###" + assert_snapshot!(result, @r#" ; ModuleID = '' source_filename = "" @@ -631,6 +631,7 @@ END_FUNCTION call void @llvm.dbg.declare(metadata i16* %i, metadata !48, metadata !DIExpression()), !dbg !49 store i16 0, i16* %i, align 2 call void @__init_struct_(%struct_* %st), !dbg !50 + call void @__user_init_struct_(%struct_* %st), !dbg !50 %s1 = getelementptr inbounds %struct_, %struct_* %st, i32 0, i32 2, !dbg !51 %3 = bitcast [81 x i8]* %s to i8*, !dbg !51 %4 = bitcast [81 x i8]* %s1 to i8*, !dbg !51 @@ -715,6 +716,23 @@ END_FUNCTION ret void } + define void @__user_init_inner(%inner* %0) { + entry: + %self = alloca %inner*, align 8 + store %inner* %0, %inner** %self, align 8 + ret void + } + + define void @__user_init_struct_(%struct_* %0) { + entry: + %self = alloca %struct_*, align 8 + store %struct_* %0, %struct_** %self, align 8 + %deref = load %struct_*, %struct_** %self, align 8 + %inner = getelementptr inbounds %struct_, %struct_* %deref, i32 0, i32 0 + call void @__user_init_inner(%inner* %inner) + ret void + } + define void @__init___Test() { entry: ret void @@ -790,5 +808,5 @@ END_FUNCTION !60 = !DILocation(line: 42, column: 4, scope: !36) !61 = !DILocation(line: 43, column: 4, scope: !36) !62 = !DILocation(line: 45, scope: !36) - "###); + "#); } diff --git a/src/codegen/tests/initialization_test/complex_initializers.rs b/src/codegen/tests/initialization_test/complex_initializers.rs index f0c5559cc4..213c6e0bbd 100644 --- a/src/codegen/tests/initialization_test/complex_initializers.rs +++ b/src/codegen/tests/initialization_test/complex_initializers.rs @@ -749,10 +749,20 @@ fn struct_types() { ret void } + define void @__user_init_myStruct(%myStruct* %0) { + entry: + %self = alloca %myStruct*, align 8 + store %myStruct* %0, %myStruct** %self, align 8 + ret void + } + define void @__user_init_prog(%prog* %0) { entry: %self = alloca %prog*, align 8 store %prog* %0, %prog** %self, align 8 + %deref = load %prog*, %prog** %self, align 8 + %str = getelementptr inbounds %prog, %prog* %deref, i32 0, i32 0 + call void @__user_init_myStruct(%myStruct* %str) ret void } @@ -879,6 +889,13 @@ fn stateful_pous_methods_and_structs_get_init_functions() { ret void } + define void @__user_init_myStruct(%myStruct* %0) { + entry: + %self = alloca %myStruct*, align 8 + store %myStruct* %0, %myStruct** %self, align 8 + ret void + } + define void @__user_init_prog(%prog* %0) { entry: %self = alloca %prog*, align 8 @@ -2205,3 +2222,225 @@ fn user_fb_init_is_added_and_called_if_it_exists() { } "#); } + +#[test] +fn user_fb_init_in_global_struct() { + let res = generate_to_string( + "Test", + vec![SourceCode::from( + r#" + TYPE + bar : STRUCT + f: foo; + END_STRUCT; + END_TYPE + + FUNCTION_BLOCK foo + VAR + x : INT := 0; + y : INT := 0; + END_VAR + METHOD FB_INIT + x := 1; + y := 2; + END_METHOD + END_FUNCTION_BLOCK + + PROGRAM prog + VAR + str: bar; + END_VAR + str.f(); + END_PROGRAM + "#, + )], + ) + .unwrap(); + + assert_snapshot!(res, @r#" + ; ModuleID = '' + source_filename = "" + + %prog = type { %bar } + %bar = type { %foo } + %foo = type { i16, i16 } + + @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @__init___Test, i8* null }] + @prog_instance = global %prog zeroinitializer + @__bar__init = constant %bar zeroinitializer + @__foo__init = constant %foo zeroinitializer + + define void @foo(%foo* %0) { + entry: + %x = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 + %y = getelementptr inbounds %foo, %foo* %0, i32 0, i32 1 + ret void + } + + define void @foo_FB_INIT(%foo* %0) { + entry: + %x = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 + %y = getelementptr inbounds %foo, %foo* %0, i32 0, i32 1 + store i16 1, i16* %x, align 2 + store i16 2, i16* %y, align 2 + ret void + } + + define void @prog(%prog* %0) { + entry: + %str = getelementptr inbounds %prog, %prog* %0, i32 0, i32 0 + %f = getelementptr inbounds %bar, %bar* %str, i32 0, i32 0 + call void @foo(%foo* %f) + ret void + } + + define void @__init_bar(%bar* %0) { + entry: + %self = alloca %bar*, align 8 + store %bar* %0, %bar** %self, align 8 + %deref = load %bar*, %bar** %self, align 8 + %f = getelementptr inbounds %bar, %bar* %deref, i32 0, i32 0 + call void @__init_foo(%foo* %f) + ret void + } + + define void @__init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } + + define void @__init_prog(%prog* %0) { + entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + %deref = load %prog*, %prog** %self, align 8 + %str = getelementptr inbounds %prog, %prog* %deref, i32 0, i32 0 + call void @__init_bar(%bar* %str) + ret void + } + + define void @__user_init_prog(%prog* %0) { + entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + %deref = load %prog*, %prog** %self, align 8 + %str = getelementptr inbounds %prog, %prog* %deref, i32 0, i32 0 + call void @__user_init_bar(%bar* %str) + ret void + } + + define void @__user_init_bar(%bar* %0) { + entry: + %self = alloca %bar*, align 8 + store %bar* %0, %bar** %self, align 8 + %deref = load %bar*, %bar** %self, align 8 + %f = getelementptr inbounds %bar, %bar* %deref, i32 0, i32 0 + call void @__user_init_foo(%foo* %f) + ret void + } + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + %deref = load %foo*, %foo** %self, align 8 + call void @foo_FB_INIT(%foo* %deref) + ret void + } + + define void @__init___Test() { + entry: + call void @__init_prog(%prog* @prog_instance) + call void @__user_init_prog(%prog* @prog_instance) + ret void + } + "#); +} + +#[test] +fn user_init_called_when_declared_as_external() { + let res = generate_to_string( + "Test", + vec![SourceCode::from( + r#" + {external} + FUNCTION_BLOCK foo + VAR + x : INT := 0; + y : INT := 0; + END_VAR + METHOD FB_INIT + x := 1; + y := 2; + END_METHOD + END_FUNCTION_BLOCK + + PROGRAM prog + VAR + f: foo; + END_VAR + f(); + END_PROGRAM + "#, + )], + ) + .unwrap(); + + assert_snapshot!(res, @r#" + ; ModuleID = '' + source_filename = "" + + %prog = type { %foo } + %foo = type { i16, i16 } + + @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @__init___Test, i8* null }] + @prog_instance = global %prog zeroinitializer + @__foo__init = external global %foo + + declare void @foo(%foo*) + + declare void @foo_FB_INIT(%foo*) + + define void @prog(%prog* %0) { + entry: + %f = getelementptr inbounds %prog, %prog* %0, i32 0, i32 0 + call void @foo(%foo* %f) + ret void + } + + define void @__init_prog(%prog* %0) { + entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + ret void + } + + define void @__user_init_prog(%prog* %0) { + entry: + %self = alloca %prog*, align 8 + store %prog* %0, %prog** %self, align 8 + %deref = load %prog*, %prog** %self, align 8 + %f = getelementptr inbounds %prog, %prog* %deref, i32 0, i32 0 + call void @__user_init_foo(%foo* %f) + ret void + } + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + %deref = load %foo*, %foo** %self, align 8 + call void @foo_FB_INIT(%foo* %deref) + ret void + } + + define void @__init___Test() { + entry: + call void @__init_prog(%prog* @prog_instance) + call void @__user_init_prog(%prog* @prog_instance) + ret void + } + "#); +} diff --git a/src/codegen/tests/oop_tests/super_tests.rs b/src/codegen/tests/oop_tests/super_tests.rs index 82547ebb86..197afdfda9 100644 --- a/src/codegen/tests/oop_tests/super_tests.rs +++ b/src/codegen/tests/oop_tests/super_tests.rs @@ -1752,6 +1752,7 @@ fn super_with_structured_types() { %1 = bitcast %Complex_Type* %local_data to i8* call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %1, i8* align 1 bitcast (%Complex_Type* @__Complex_Type__init to i8*), i64 ptrtoint (%Complex_Type* getelementptr (%Complex_Type, %Complex_Type* null, i32 1) to i64), i1 false) call void @__init_complex_type(%Complex_Type* %local_data) + call void @__user_init_Complex_Type(%Complex_Type* %local_data) %x = getelementptr inbounds %Complex_Type, %Complex_Type* %local_data, i32 0, i32 0 %data = getelementptr inbounds %parent, %parent* %__parent, i32 0, i32 0 %x1 = getelementptr inbounds %Complex_Type, %Complex_Type* %data, i32 0, i32 0 @@ -1815,6 +1816,13 @@ fn super_with_structured_types() { ret void } + define void @__user_init_Complex_Type(%Complex_Type* %0) { + entry: + %self = alloca %Complex_Type*, align 8 + store %Complex_Type* %0, %Complex_Type** %self, align 8 + ret void + } + define void @__user_init_child(%child* %0) { entry: %self = alloca %child*, align 8 @@ -1829,6 +1837,9 @@ fn super_with_structured_types() { entry: %self = alloca %parent*, align 8 store %parent* %0, %parent** %self, align 8 + %deref = load %parent*, %parent** %self, align 8 + %data = getelementptr inbounds %parent, %parent* %deref, i32 0, i32 0 + call void @__user_init_Complex_Type(%Complex_Type* %data) ret void } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_nested_struct_added_to_debug_info.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_nested_struct_added_to_debug_info.snap index 70eb4d745b..fc94f16178 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_nested_struct_added_to_debug_info.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_nested_struct_added_to_debug_info.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/debug_tests.rs expression: codegen +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -30,9 +31,27 @@ entry: ret void } +define void @__user_init_myStruct(%myStruct* %0) { +entry: + %self = alloca %myStruct*, align 8 + store %myStruct* %0, %myStruct** %self, align 8 + %deref = load %myStruct*, %myStruct** %self, align 8 + %b = getelementptr inbounds %myStruct, %myStruct* %deref, i32 0, i32 1 + call void @__user_init_myStruct2(%myStruct2* %b) + ret void +} + +define void @__user_init_myStruct2(%myStruct2* %0) { +entry: + %self = alloca %myStruct2*, align 8 + store %myStruct2* %0, %myStruct2** %self, align 8 + ret void +} + define void @__init___Test() { entry: call void @__init_mystruct(%myStruct* @gStruct) + call void @__user_init_myStruct(%myStruct* @gStruct) ret void } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_struct_added_to_debug_info.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_struct_added_to_debug_info.snap index 47f1a4af24..53d7ac7bcc 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_struct_added_to_debug_info.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_struct_added_to_debug_info.snap @@ -1,6 +1,7 @@ --- source: src/codegen/tests/debug_tests.rs expression: codegen +snapshot_kind: text --- ; ModuleID = '' source_filename = "" @@ -19,9 +20,17 @@ entry: ret void } +define void @__user_init_myStruct(%myStruct* %0) { +entry: + %self = alloca %myStruct*, align 8 + store %myStruct* %0, %myStruct** %self, align 8 + ret void +} + define void @__init___Test() { entry: call void @__init_mystruct(%myStruct* @gStruct) + call void @__user_init_myStruct(%myStruct* @gStruct) ret void } diff --git a/src/lowering.rs b/src/lowering.rs index d3c00eb627..ae9172252a 100644 --- a/src/lowering.rs +++ b/src/lowering.rs @@ -338,6 +338,9 @@ impl AstVisitorMut for InitVisitor { fn visit_data_type(&mut self, data_type: &mut DataType) { if matches!(data_type, plc_ast::ast::DataType::StructType { .. }) { + if let Some(name) = data_type.get_name() { + self.user_inits.insert(name.to_string(), false); + }; self.walk_with_scope(data_type, data_type.get_name().map(ToOwned::to_owned)) } else { data_type.walk(self) diff --git a/src/tests/adr/initializer_functions_adr.rs b/src/tests/adr/initializer_functions_adr.rs index 3a5b20efc1..0dc08c1cc2 100644 --- a/src/tests/adr/initializer_functions_adr.rs +++ b/src/tests/adr/initializer_functions_adr.rs @@ -507,6 +507,20 @@ fn generating_init_functions() { ret void } + define void @__user_init_myStruct(%myStruct* %0) { + entry: + %self = alloca %myStruct*, align 8 + store %myStruct* %0, %myStruct** %self, align 8 + ret void + } + + define void @__user_init_myRefStruct(%myRefStruct* %0) { + entry: + %self = alloca %myRefStruct*, align 8 + store %myRefStruct* %0, %myRefStruct** %self, align 8 + ret void + } + define void @__init___Test() { entry: ret void @@ -618,6 +632,16 @@ fn generating_init_functions() { ret void } + define void @__user_init_baz(%baz* %0) { + entry: + %self = alloca %baz*, align 8 + store %baz* %0, %baz** %self, align 8 + %deref = load %baz*, %baz** %self, align 8 + %fb = getelementptr inbounds %baz, %baz* %deref, i32 0, i32 0 + call void @__user_init_bar(%bar* %fb) + ret void + } + define void @__user_init_bar(%bar* %0) { entry: %self = alloca %bar*, align 8 @@ -635,13 +659,10 @@ fn generating_init_functions() { ret void } - define void @__user_init_baz(%baz* %0) { + define void @__user_init_myStruct(%myStruct* %0) { entry: - %self = alloca %baz*, align 8 - store %baz* %0, %baz** %self, align 8 - %deref = load %baz*, %baz** %self, align 8 - %fb = getelementptr inbounds %baz, %baz* %deref, i32 0, i32 0 - call void @__user_init_bar(%bar* %fb) + %self = alloca %myStruct*, align 8 + store %myStruct* %0, %myStruct** %self, align 8 ret void } @@ -650,6 +671,7 @@ fn generating_init_functions() { call void @__init_baz(%baz* @baz_instance) call void @__init_mystruct(%myStruct* @s) call void @__user_init_baz(%baz* @baz_instance) + call void @__user_init_myStruct(%myStruct* @s) ret void } "#); diff --git a/tests/lit/single/init/user_init.st b/tests/lit/single/init/user_init.st new file mode 100644 index 0000000000..30bc27f786 --- /dev/null +++ b/tests/lit/single/init/user_init.st @@ -0,0 +1,29 @@ +// RUN: (%COMPILE %s && %RUN) | %CHECK %s +TYPE + bar : STRUCT + f: foo; + END_STRUCT; +END_TYPE + +FUNCTION_BLOCK foo +VAR + x : INT := 0; + y : INT := 0; +END_VAR + METHOD FB_INIT + x := 1; + y := 2; + END_METHOD +END_FUNCTION_BLOCK + +PROGRAM prog +VAR + str: bar; +END_VAR + printf('%d$N', str.f.x); // CHECK: 1 + printf('%d$N', str.f.y); // CHECK: 2 +END_PROGRAM + +FUNCTION main: DINT + prog(); +END_FUNCTION \ No newline at end of file From 48a095914bd509331f9f69315914e22a135c6ccc Mon Sep 17 00:00:00 2001 From: Michael Haselberger Date: Wed, 16 Apr 2025 12:41:46 +0200 Subject: [PATCH 5/9] support external fb-inits --- src/codegen/generators/llvm.rs | 5 ++- src/codegen/generators/pou_generator.rs | 6 ++-- .../complex_initializers.rs | 6 ++-- src/lowering.rs | 29 ++++++++++++------ src/lowering/initializers.rs | 4 +-- ...r__conditional_return_evaluating_true.snap | 1 + ...tional_return_evaluating_true_negated.snap | 1 + .../extern_C_fb_init/extern_C_fb_init.test | 2 ++ tests/lit/multi/extern_C_fb_init/foo.c | 14 +++++++++ tests/lit/multi/extern_C_fb_init/header.pli | 9 ++++++ tests/lit/multi/extern_C_fb_init/libfoo.so | Bin 0 -> 15448 bytes tests/lit/multi/extern_C_fb_init/main.st | 7 +++++ 12 files changed, 64 insertions(+), 20 deletions(-) create mode 100644 tests/lit/multi/extern_C_fb_init/extern_C_fb_init.test create mode 100644 tests/lit/multi/extern_C_fb_init/foo.c create mode 100644 tests/lit/multi/extern_C_fb_init/header.pli create mode 100755 tests/lit/multi/extern_C_fb_init/libfoo.so create mode 100644 tests/lit/multi/extern_C_fb_init/main.st diff --git a/src/codegen/generators/llvm.rs b/src/codegen/generators/llvm.rs index 060634f224..424d6df7a5 100644 --- a/src/codegen/generators/llvm.rs +++ b/src/codegen/generators/llvm.rs @@ -12,7 +12,7 @@ use inkwell::{ values::{BasicValue, BasicValueEnum, GlobalValue, IntValue, PointerValue}, AddressSpace, }; -use plc_ast::ast::AstNode; +use plc_ast::ast::{AstNode, LinkageType}; use plc_diagnostics::diagnostics::Diagnostic; use plc_source::source_location::SourceLocation; @@ -318,6 +318,9 @@ impl<'a> Llvm<'a> { exp_gen: &ExpressionCodeGenerator, ) -> Result<(), Diagnostic> { let (qualified_name, type_name, location) = variable; + if index.find_pou(type_name).is_some_and(|it| it.get_linkage() == &LinkageType::External) { + return Ok(()); + } let variable_llvm_type = llvm_index.get_associated_type(type_name).map_err(|err| err.with_location(location))?; diff --git a/src/codegen/generators/pou_generator.rs b/src/codegen/generators/pou_generator.rs index b35c072b00..7fcc19d5ad 100644 --- a/src/codegen/generators/pou_generator.rs +++ b/src/codegen/generators/pou_generator.rs @@ -38,7 +38,7 @@ use inkwell::{ types::{BasicType, StructType}, values::PointerValue, }; -use plc_ast::ast::{AstNode, Implementation, PouType}; +use plc_ast::ast::{AstNode, Implementation, LinkageType, PouType}; use plc_diagnostics::diagnostics::{Diagnostic, INTERNAL_LLVM_ERROR}; use plc_source::source_location::SourceLocation; use rustc_hash::FxHashMap; @@ -110,8 +110,8 @@ pub fn generate_global_constants_for_pou_members<'ink>( .filter(|it| it.is_in_unit(location)); for implementation in implementations { let type_name = implementation.get_type_name(); - if implementation.is_init() { - // initializer functions don't need global constants to initialize members + if implementation.is_init() || index.find_pou(type_name).is_some_and(|it| it.get_linkage() == &LinkageType::External) { + // initializer functions and externals don't need global constants to initialize members continue; } let pou_members = index.get_pou_members(type_name); diff --git a/src/codegen/tests/initialization_test/complex_initializers.rs b/src/codegen/tests/initialization_test/complex_initializers.rs index 213c6e0bbd..f31e571ce8 100644 --- a/src/codegen/tests/initialization_test/complex_initializers.rs +++ b/src/codegen/tests/initialization_test/complex_initializers.rs @@ -2368,12 +2368,10 @@ fn user_init_called_when_declared_as_external() { {external} FUNCTION_BLOCK foo VAR - x : INT := 0; - y : INT := 0; + x : INT; + y : INT; END_VAR METHOD FB_INIT - x := 1; - y := 2; END_METHOD END_FUNCTION_BLOCK diff --git a/src/lowering.rs b/src/lowering.rs index ae9172252a..c1270e515b 100644 --- a/src/lowering.rs +++ b/src/lowering.rs @@ -35,6 +35,11 @@ impl InitVisitor { init_symbol_name: &'static str, ) -> Vec { let mut visitor = Self::new(index, unresolvables, id_provider); + // before visiting, we need to collect all candidates for user-defined init functions + units.iter().for_each(|unit| { + // TODO: probably also need to consider structs here + visitor.collect_user_init_candidates(unit); + }); // visit all units units.iter_mut().for_each(|unit| { visitor.visit_compilation_unit(unit); @@ -66,6 +71,15 @@ impl InitVisitor { self.ctxt.scope(old); } + fn collect_user_init_candidates(&mut self, unit: &CompilationUnit) { + // TODO: probably also need to consider structs here + // collect all candidates for user-defined init functions + for pou in unit.pous.iter().filter(|it| matches!(it.kind, PouType::FunctionBlock | PouType::Program)) { + // add the POU to potential `FB_INIT` candidates + self.user_inits.insert(pou.name.to_owned(), self.index.find_method(&pou.name, "FB_INIT").is_some()); + } + } + fn update_initializer(&mut self, variable: &mut plc_ast::ast::Variable) { // flat references to stateful pou-local variables need to have a qualifier added, so they can be resolved in the init functions let scope = self.ctxt.get_scope().as_ref().map(|it| it.as_str()).unwrap_or(GLOBAL_SCOPE); @@ -219,11 +233,12 @@ impl InitVisitor { // collect necessary call statements to init-functions and user-defined init-functions let mut implicit_calls = Vec::new(); let mut user_init_calls = Vec::new(); - self.index.get_pou_members(&implementation.name).iter().filter(|var| predicate(var)).for_each( + self.index.get_pou_members(dbg!(&implementation.name)).iter().filter(|var| predicate(var)).for_each( |var| { let dti = self.index.get_effective_type_or_void_by_name(var.get_type_name()).get_type_information(); - if dti.is_struct() { + let is_external = self.index.find_pou(dti.get_name()).is_some_and(|it| it.get_linkage() == &LinkageType::External); + if dti.is_struct() && !is_external { implicit_calls.push(create_call_statement( &get_init_fn_name(dti.get_name()), var.get_name(), @@ -232,9 +247,9 @@ impl InitVisitor { &implementation.name_location, )); } - if self.user_inits.contains_key(dti.get_name()) { + if dbg!(&self.user_inits).contains_key(dbg!(dti.get_name())) { user_init_calls.push(create_call_statement( - &get_user_init_fn_name(dti.get_name()), + dbg!(&get_user_init_fn_name(dti.get_name())), var.get_name(), None, self.ctxt.get_id_provider(), @@ -352,12 +367,6 @@ impl AstVisitorMut for InitVisitor { self.unresolved_initializers.maybe_insert_initializer(&pou.name, None, &None); } - if matches!(pou.kind, PouType::FunctionBlock | PouType::Program) { - // add the POU to potential `FB_INIT` candidates - self.user_inits - .insert(pou.name.to_owned(), self.index.find_method(&pou.name, "fb_init").is_some()); - } - self.walk_with_scope(pou, Some(&pou.name.to_owned())); } } diff --git a/src/lowering/initializers.rs b/src/lowering/initializers.rs index 45e76eecb5..01c971a068 100644 --- a/src/lowering/initializers.rs +++ b/src/lowering/initializers.rs @@ -230,8 +230,8 @@ fn create_init_unit( } fn create_user_init_units(lowerer: &InitVisitor) -> Vec { - lowerer - .user_inits + dbg!(&lowerer + .user_inits) .iter() .map(|(container_name, has_fb_init)| { let location = SourceLocation::internal_in_unit(Some(INIT_COMPILATION_UNIT)); diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true.snap b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true.snap index 6c5202c5ef..740b1fac16 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true.snap @@ -18,6 +18,7 @@ entry: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 bitcast (%conditional_return* @__conditional_return__init to i8*), i64 ptrtoint (%conditional_return* getelementptr (%conditional_return, %conditional_return* null, i32 1) to i64), i1 false) store i32 0, i32* %main, align 4 call void @__init_conditional_return(%conditional_return* %conditional) + call void @__user_init_conditional_return(%conditional_return* %conditional) %val = getelementptr inbounds %conditional_return, %conditional_return* %conditional, i32 0, i32 0 %load_my_val = load i32, i32* %my_val, align 4 store i32 %load_my_val, i32* %val, align 4 diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true_negated.snap b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true_negated.snap index cbe9d93a93..9555be0e52 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true_negated.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true_negated.snap @@ -18,6 +18,7 @@ entry: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 bitcast (%conditional_return* @__conditional_return__init to i8*), i64 ptrtoint (%conditional_return* getelementptr (%conditional_return, %conditional_return* null, i32 1) to i64), i1 false) store i32 0, i32* %main, align 4 call void @__init_conditional_return(%conditional_return* %conditional) + call void @__user_init_conditional_return(%conditional_return* %conditional) %val = getelementptr inbounds %conditional_return, %conditional_return* %conditional, i32 0, i32 0 %load_my_val = load i32, i32* %my_val, align 4 store i32 %load_my_val, i32* %val, align 4 diff --git a/tests/lit/multi/extern_C_fb_init/extern_C_fb_init.test b/tests/lit/multi/extern_C_fb_init/extern_C_fb_init.test new file mode 100644 index 0000000000..500cf2a326 --- /dev/null +++ b/tests/lit/multi/extern_C_fb_init/extern_C_fb_init.test @@ -0,0 +1,2 @@ +RUN: %COMPILE %S/main.st %S/header.pli && %RUN | %CHECK %s +CHECK:6 \ No newline at end of file diff --git a/tests/lit/multi/extern_C_fb_init/foo.c b/tests/lit/multi/extern_C_fb_init/foo.c new file mode 100644 index 0000000000..658bcb6c84 --- /dev/null +++ b/tests/lit/multi/extern_C_fb_init/foo.c @@ -0,0 +1,14 @@ +#include + +typedef struct { + int a; + int b; +} myFunctionBlock; + +// myFunctionBlock __myFunctionBlock__init; + +void myFunctionBlock_FB_INIT(myFunctionBlock* fb_instance) { + fb_instance->a = 1; + fb_instance->b = 2; + printf("myFunctionBlock initialized with a = %d, b = %d\n", fb_instance->a, fb_instance->b); +} \ No newline at end of file diff --git a/tests/lit/multi/extern_C_fb_init/header.pli b/tests/lit/multi/extern_C_fb_init/header.pli new file mode 100644 index 0000000000..25a81fe17a --- /dev/null +++ b/tests/lit/multi/extern_C_fb_init/header.pli @@ -0,0 +1,9 @@ +{external} +FUNCTION_BLOCK myFunctionBlock +VAR + a : DINT; + b : DINT; +END_VAR + METHOD FB_INIT + END_METHOD +END_FUNCTION_BLOCK \ No newline at end of file diff --git a/tests/lit/multi/extern_C_fb_init/libfoo.so b/tests/lit/multi/extern_C_fb_init/libfoo.so new file mode 100755 index 0000000000000000000000000000000000000000..e1314fb78fa1deeb1995a1b7010acd6143f734ee GIT binary patch literal 15448 zcmeHOUu+!38K1j2a3M~7K$4~jG)t5qLX*XIoHQ*pIoq+bMotLE7KzlbtZ&c0EB7b8 z+aorDkYcqoO(R9BcmW>ZE${+@Ct47RKp_Gig2V$zMT$ft83~0T1h}n~>-WvfZ@pg5 zC=wF9%t*K2-`_Xiemi%wdpq-Z|Ik1(kq~H$#9d-e5+b7w`?tY^bvwioI^HDKO5c__ z(|5R2+6XGr%7yz_%&eB<)YD0T!p>?L(qb?*OCCe|p%y`-xNFEZyG1$7cF(7)lS;NU z1&&3=rEFzS-8G+{)_H=alv(D;dG65h;&g-d1C{4Qx_uV|pZP9JIm9XaL4muMaGdAW zHk5r>_qR}8QaXQ7eY*1eR#0b)=(Bt8sQBZ)j zT$o=f6Y}4#d1;#c7HXWQ)x=mL-3?9j+>g~nzj*=u0O{8^@gF7K4Wd<~uUE!i__*#w zsZw@pfmaP&SGa>Cdt5(P%}o?)L9RNor>|Hk=SIA-VouqbTiooV=Z+W3Ua{~g8-usFZt)mFz?AK(9NvcW^`;sus$@xF{CJvUaUvZx_3V27CM5PP^0QuVaF$n+T5y z5s(howZ5jXgsXo<=Z*1>@hS9q(bruz=uhhabcyEaA)ni+^n5M3)@bJ=dL9#KA4T*S zt8BXv(aYZf05XcXmWUpDuo!A8U@BlLU@BlLU@BlLU@BlLU@GtfEAUm@FaGOHf1YxV zFFtdJ5YC@Y2g$~HXZr2bTQYKE+qW;;W_`K-Th=1^m0inv^vMTZzW;o0A)Gj)8Xvm zn@LU_q`t%c8UNW~GU|Lr2}<=yJI5ZIb&mJXz9XM4UGqd`?mAEdH{H4UpsIMYl8Oa)8@Oa)8@Oa)8@Oa)8@Oa)8@Oa)8@e!>dGUOifc zav>*YqnC;Bg&42#5MIGH__)5;VhzJd3s>^>bu*P9!?zKebu8oQ zF<(4Ket0*@?u`8%efCp7@||qY^7NmReao(Sj5=Tk(@X_S1xy7@1xy7@1xy7@1xy7@ z1xy7@1?E>kum8k)PpswSHKg2H6$uxVF4OXe#{FE&SXU|+`;rdNU~7Qa>r45$jT`J= zUujfWeo!y+#2V0ceyF5|wZebVcKP5*`oBu65KA>(t*M5I8NIGl!vySj9_4kV+%KXo1e|m!~Wz>-#Po?}1ZU2v!k*5y#qY+ zoz5r?u1}xT(+YAuK9yC7-xI^}!}ZbH@UZm1USPb#|0!ac<-gE*JuBm+#d!-6=4i7x zFOoSamI-|C;QcZ&39(9~GSDdchSc9E;@A7EG`EHO3V`}p`mYM>1N}v*Um1R%p#L8+ zN!tA(V)f@OBo>?^^k&jGTc_W?fd5YE|J`->_b=f82hy*P^cS+(YETR6dX@o@3940?&2K;9FaS#RouK+_IcyLt^<2} z_6+usmiAV-{f-7WyM{?cdkg^GJ#oNRZndu3}5Wyx797O_c&~jA&3*G!L#^33B#Cxo(fu3q^lR!531>d$qi< z{i!k`6%DG&qJL=S2`<^HxuVAa%^fNR!j^@wiM1yxBnG)jI?8g})r#*0p0IOyeaZ4Z z1%afX>e?v;c!6s& z$wfAf5p50$Jf{MWc@&iA0dB}2exSU6hv#U>n5RK422+dYue3t=+6FxC3qW!H=pXgN z`Ij}mR|mv>1}OX(zmh(2{3PkPCb$m@e{c2gF7CI;MK(T_&EnX z62oV-0TlTn3}nzJV|dKtpvl+;N56=7B8JEO2a5Yq_{Y!x?;76;2TL=Wc0jKw(gA&j z^vvV>cUj62bb}JZW4!+t$P&fxx0EaBqaji;s2kL;62oI0;|up4*rylwhYb2AVcR13 z@IHrs7^uNdNpmvv?~#GW9{R`q1olCm)`h}(1BdJQ1Yy|)ch literal 0 HcmV?d00001 diff --git a/tests/lit/multi/extern_C_fb_init/main.st b/tests/lit/multi/extern_C_fb_init/main.st new file mode 100644 index 0000000000..d494bce9c7 --- /dev/null +++ b/tests/lit/multi/extern_C_fb_init/main.st @@ -0,0 +1,7 @@ +FUNCTION main +VAR + f: myFunctionBlock; +END_VAR + printf('%d$N', f.a); + printf('%d$N', f.b); +END_FUNCTION \ No newline at end of file From 47400543db7de5871746f62370d8e2e08039cbff Mon Sep 17 00:00:00 2001 From: Michael Haselberger Date: Tue, 22 Apr 2025 08:24:26 +0200 Subject: [PATCH 6/9] add lit test for external lib fb init --- src/codegen/generators/pou_generator.rs | 4 ++- .../complex_initializers.rs | 31 ++++++++++++------- src/lowering.rs | 19 +++++++----- src/lowering/initializers.rs | 4 +-- .../extern_C_fb_init/extern_C_fb_init.test | 6 ++-- .../lit/multi/extern_C_fb_init/lit.local.cfg | 29 +++++++++++++++++ 6 files changed, 69 insertions(+), 24 deletions(-) create mode 100644 tests/lit/multi/extern_C_fb_init/lit.local.cfg diff --git a/src/codegen/generators/pou_generator.rs b/src/codegen/generators/pou_generator.rs index 7fcc19d5ad..4f474674e7 100644 --- a/src/codegen/generators/pou_generator.rs +++ b/src/codegen/generators/pou_generator.rs @@ -110,7 +110,9 @@ pub fn generate_global_constants_for_pou_members<'ink>( .filter(|it| it.is_in_unit(location)); for implementation in implementations { let type_name = implementation.get_type_name(); - if implementation.is_init() || index.find_pou(type_name).is_some_and(|it| it.get_linkage() == &LinkageType::External) { + if implementation.is_init() + || index.find_pou(type_name).is_some_and(|it| it.get_linkage() == &LinkageType::External) + { // initializer functions and externals don't need global constants to initialize members continue; } diff --git a/src/codegen/tests/initialization_test/complex_initializers.rs b/src/codegen/tests/initialization_test/complex_initializers.rs index f31e571ce8..857e3c94bf 100644 --- a/src/codegen/tests/initialization_test/complex_initializers.rs +++ b/src/codegen/tests/initialization_test/complex_initializers.rs @@ -2118,10 +2118,10 @@ fn methods_call_init_functions_for_their_members() { #[test] fn user_fb_init_is_added_and_called_if_it_exists() { - let res = generate_to_string( - "Test", - vec![SourceCode::from( - r#" + let res = generate_to_string( + "Test", + vec![SourceCode::from( + r#" FUNCTION_BLOCK foo VAR x : INT := 0; @@ -2225,16 +2225,20 @@ fn user_fb_init_is_added_and_called_if_it_exists() { #[test] fn user_fb_init_in_global_struct() { - let res = generate_to_string( - "Test", - vec![SourceCode::from( - r#" + let res = generate_to_string( + "Test", + vec![SourceCode::from( + r#" TYPE bar : STRUCT f: foo; END_STRUCT; END_TYPE + VAR_GLOBAL + str: bar; + END_VAR + FUNCTION_BLOCK foo VAR x : INT := 0; @@ -2269,6 +2273,7 @@ fn user_fb_init_in_global_struct() { @prog_instance = global %prog zeroinitializer @__bar__init = constant %bar zeroinitializer @__foo__init = constant %foo zeroinitializer + @str = global %bar zeroinitializer define void @foo(%foo* %0) { entry: @@ -2353,7 +2358,9 @@ fn user_fb_init_in_global_struct() { define void @__init___Test() { entry: call void @__init_prog(%prog* @prog_instance) + call void @__init_bar(%bar* @str) call void @__user_init_prog(%prog* @prog_instance) + call void @__user_init_bar(%bar* @str) ret void } "#); @@ -2361,10 +2368,10 @@ fn user_fb_init_in_global_struct() { #[test] fn user_init_called_when_declared_as_external() { - let res = generate_to_string( - "Test", - vec![SourceCode::from( - r#" + let res = generate_to_string( + "Test", + vec![SourceCode::from( + r#" {external} FUNCTION_BLOCK foo VAR diff --git a/src/lowering.rs b/src/lowering.rs index c1270e515b..c0d0d16ff7 100644 --- a/src/lowering.rs +++ b/src/lowering.rs @@ -74,9 +74,11 @@ impl InitVisitor { fn collect_user_init_candidates(&mut self, unit: &CompilationUnit) { // TODO: probably also need to consider structs here // collect all candidates for user-defined init functions - for pou in unit.pous.iter().filter(|it| matches!(it.kind, PouType::FunctionBlock | PouType::Program)) { - // add the POU to potential `FB_INIT` candidates - self.user_inits.insert(pou.name.to_owned(), self.index.find_method(&pou.name, "FB_INIT").is_some()); + for pou in unit.pous.iter().filter(|it| matches!(it.kind, PouType::FunctionBlock | PouType::Program)) + { + // add the POU to potential `FB_INIT` candidates + self.user_inits + .insert(pou.name.to_owned(), self.index.find_method(&pou.name, "FB_INIT").is_some()); } } @@ -233,11 +235,14 @@ impl InitVisitor { // collect necessary call statements to init-functions and user-defined init-functions let mut implicit_calls = Vec::new(); let mut user_init_calls = Vec::new(); - self.index.get_pou_members(dbg!(&implementation.name)).iter().filter(|var| predicate(var)).for_each( + self.index.get_pou_members(&implementation.name).iter().filter(|var| predicate(var)).for_each( |var| { let dti = self.index.get_effective_type_or_void_by_name(var.get_type_name()).get_type_information(); - let is_external = self.index.find_pou(dti.get_name()).is_some_and(|it| it.get_linkage() == &LinkageType::External); + let is_external = self + .index + .find_pou(dti.get_name()) + .is_some_and(|it| it.get_linkage() == &LinkageType::External); if dti.is_struct() && !is_external { implicit_calls.push(create_call_statement( &get_init_fn_name(dti.get_name()), @@ -247,9 +252,9 @@ impl InitVisitor { &implementation.name_location, )); } - if dbg!(&self.user_inits).contains_key(dbg!(dti.get_name())) { + if self.user_inits.contains_key(dti.get_name()) { user_init_calls.push(create_call_statement( - dbg!(&get_user_init_fn_name(dti.get_name())), + &get_user_init_fn_name(dti.get_name()), var.get_name(), None, self.ctxt.get_id_provider(), diff --git a/src/lowering/initializers.rs b/src/lowering/initializers.rs index 01c971a068..45e76eecb5 100644 --- a/src/lowering/initializers.rs +++ b/src/lowering/initializers.rs @@ -230,8 +230,8 @@ fn create_init_unit( } fn create_user_init_units(lowerer: &InitVisitor) -> Vec { - dbg!(&lowerer - .user_inits) + lowerer + .user_inits .iter() .map(|(container_name, has_fb_init)| { let location = SourceLocation::internal_in_unit(Some(INIT_COMPILATION_UNIT)); diff --git a/tests/lit/multi/extern_C_fb_init/extern_C_fb_init.test b/tests/lit/multi/extern_C_fb_init/extern_C_fb_init.test index 500cf2a326..0743e3f4ed 100644 --- a/tests/lit/multi/extern_C_fb_init/extern_C_fb_init.test +++ b/tests/lit/multi/extern_C_fb_init/extern_C_fb_init.test @@ -1,2 +1,4 @@ -RUN: %COMPILE %S/main.st %S/header.pli && %RUN | %CHECK %s -CHECK:6 \ No newline at end of file +RUN: %COMPILE %S/main.st && %RUN | %CHECK %s +CHECK: myFunctionBlock initialized with a = 1, b = 2 +CHECK: 1 +CHECK: 2 \ No newline at end of file diff --git a/tests/lit/multi/extern_C_fb_init/lit.local.cfg b/tests/lit/multi/extern_C_fb_init/lit.local.cfg new file mode 100644 index 0000000000..bbac64e691 --- /dev/null +++ b/tests/lit/multi/extern_C_fb_init/lit.local.cfg @@ -0,0 +1,29 @@ +# Override the compile command to include the custom library +import os.path + +# Access the same parameters that the main configuration uses +stdlibLocation = lit_config.params["LIB"] +compilerLocation = lit_config.params["COMPILER"] +rustyRootDirectory = "/home/michael/dev/rusty" + +test_dir = os.path.dirname(__file__) +lib_path = os.path.abspath(test_dir) + +# Build on the existing compile command but add our custom library +compile = f'{compilerLocation}' +compile = f'{compile} -o /tmp/%basename_t.out' +compile = f'{compile} -liec61131std -L{stdlibLocation}/lib -i "{stdlibLocation}/include/*.st"' +compile = f'{compile} -i "{rustyRootDirectory}/tests/lit/util/*.pli"' +compile = f'{compile} -L{lib_path} -lfoo -i {lib_path}/header.pli' +compile = f'{compile} --linker=cc' + +# Log the compile command +lit_config.note(f"Compile command: {compile}") + +# Update the run command to include the custom library path +run_cmd = f'LD_LIBRARY_PATH="{stdlibLocation}/lib:{lib_path}" /tmp/%basename_t.out' + +# Override the substitutions +config.substitutions = [s for s in config.substitutions if s[0] not in ['%COMPILE', '%RUN']] +config.substitutions.append(('%COMPILE', f'{compile}')) +config.substitutions.append(('%RUN', f'{run_cmd}')) \ No newline at end of file From 8c9f120a0c1b0fcab89139657c4247de6ac3d6ea Mon Sep 17 00:00:00 2001 From: Michael Haselberger Date: Tue, 22 Apr 2025 09:26:06 +0200 Subject: [PATCH 7/9] update book --- book/src/libraries/api_lib_guide.md | 65 +++++++++++++++++- book/src/pous.md | 22 ++++++ book/src/using_rusty.md | 26 +++++++ compiler/plc_project/src/project.rs | 2 +- src/codegen/generators/llvm.rs | 5 +- src/codegen/generators/pou_generator.rs | 8 +-- src/lowering.rs | 14 ++-- tests/lit/multi/extern_C_fb_init/foo.c | 2 +- tests/lit/multi/extern_C_fb_init/libfoo.so | Bin 15448 -> 0 bytes .../lit/multi/extern_C_fb_init/lit.local.cfg | 26 +++++-- 10 files changed, 147 insertions(+), 23 deletions(-) delete mode 100755 tests/lit/multi/extern_C_fb_init/libfoo.so diff --git a/book/src/libraries/api_lib_guide.md b/book/src/libraries/api_lib_guide.md index 880316beaf..15d15acb51 100644 --- a/book/src/libraries/api_lib_guide.md +++ b/book/src/libraries/api_lib_guide.md @@ -142,8 +142,6 @@ void Count(CountStruct* countInst) { } ``` - - #### 2.2.3 Return values A `FUNCTION` defines a return value in the signature, while a `FUNCTION_BLOCK` relies on `VAR_OUTPUT` definitions. @@ -334,6 +332,67 @@ pub struct myStruct { ``` ### 2.5 `FUNCTION_BLOCK` initialization -Not yet implemented. + +When creating a library with `FUNCTION_BLOCK`s, you can implement initialization logic that runs when an instance is created. + +For more details on `FB_INIT` in IEC61131-3, refer to the [Program Organization Units (POUs)](../pous.md#function_block-initialization) documentation. + +#### Interoperability with libraries written in other languages + +When implementing a `FUNCTION_BLOCK` with initialization in C or other languages, you need to follow a specific naming convention for the initialization function. + +For a C implementation: + +1. Define a struct that matches your `FUNCTION_BLOCK` variables: + +```c +typedef struct { + int a; + int b; + // Other members as needed +} myFunctionBlock; +``` + +2. ruSTy expects a default-initializer to be present to initialize instances on the stack +(`VAR_TEMP` blocks or `VAR` blocks in functions or methods) + +This global instance follows the naming scheme of `____init`, below is an example of a zero-initializer: + +```c +myFunctionBlock __myFunctionBlock__init = { 0 }; +``` + +3. Optionally create an initialization function following the naming pattern `_FB_INIT`: + +```c +void myFunctionBlock_FB_INIT(myFunctionBlock* fb_instance) { + // Initialize members here + fb_instance->a = 1; + fb_instance->b = 2; + + // ...perform any other needed initialization +} +``` + +4. In your IEC61131-3 declaration (e.g., in a header file [`*.pli`]), ensure your `FUNCTION_BLOCK` includes the `FB_INIT` method (if present): + +``` +{external} +FUNCTION_BLOCK myFunctionBlock +VAR + a : DINT; + b : DINT; +END_VAR + METHOD FB_INIT + END_METHOD +END_FUNCTION_BLOCK +``` + +Note that the `FB_INIT` method doesn't need implementation details in the IEC61131-3 declaration when using an external implementation - the declaration just signals that initialization is available. + +#### Project-wide initialization + +See [Project-wide initialization](../using_rusty.md#project-wide-initialization) + diff --git a/book/src/pous.md b/book/src/pous.md index d923d74fe0..9222b0dc9f 100644 --- a/book/src/pous.md +++ b/book/src/pous.md @@ -147,6 +147,28 @@ END_VAR END_FUNCTION_BLOCK ``` +#### `FUNCTION_BLOCK` initialization +Function blocks can define a special method called `FB_INIT` that is automatically called when an instance is created. This is analogous to a constructor in object-oriented programming. + +The `FB_INIT` method allows you to initialize the function block's variables to specific values. It is called during program initialization before any other code runs. + +`FB_INIT` methods can neither have parameters nor a return type in their current implementation - violating this contract will lead to undefined behaviour at runtime. + +```iecst +FUNCTION_BLOCK MyFB +VAR + x : INT; + y : INT; +END_VAR + METHOD FB_INIT + x := 1; + y := 2; + END_METHOD + + // Other methods and code... +END_FUNCTION_BLOCK +``` + ### Action An action is represented by a parent struct, and does not define its own interface (VAR blocks). diff --git a/book/src/using_rusty.md b/book/src/using_rusty.md index a9623987d8..042040bafa 100644 --- a/book/src/using_rusty.md +++ b/book/src/using_rusty.md @@ -136,3 +136,29 @@ Outputs the json schema used for the validation of the `plc.json` file Ouputs a json file with the default error severity configuration for the project. See [Error Configuration](./error_configuration.md) for more information. +## Project-wide initialization + +When your code is compiled, the compiler creates a special initialization function with the naming pattern `__init___`. This function is responsible for calling all implicit and user-defined initialization code, including all [`FB_INIT`](../pous.md#function_block-initialization) methods. + +`` is either taken directly from the `plc.json`'s `name` field or derived from the first input file (replacing `.`/`-` with `_`) when compiling without a `plc.json` (e.g. `plc prog.st ...` would yield `__init___prog_st`). + +This function is added to the global constructor list, therefore loading the binary will automatically call the `__init___` function (and therefore your `_FB_INIT` function) when an instance of your function block is created, before any other methods are called. This allows you to set default values or perform required setup for your function block. + +> **IMPORTANT:** The global constructor initialization is currently only supported for `x86` ISAs. To make sure initialization code runs reliably regardless of target-architecture, ensure your runtime calls this function before starting main task execution. +If you're using the executable without a runtime, you **must** ensure that `__init___` is called before any other code runs. Failure to do so will result in uninitialized function blocks and pointers, which can lead to undefined behavior and/or crashes. + +Example of ensuring initialization when using C (crt0): + +```c +int main() { + // Call the project initialization function first + __init___myproject(); + + // Now it's safe to start cyclic execution + for (;;) { + mainProg(); + } + + return 0; +} +``` \ No newline at end of file diff --git a/compiler/plc_project/src/project.rs b/compiler/plc_project/src/project.rs index 1d617d87da..5cca51c62c 100644 --- a/compiler/plc_project/src/project.rs +++ b/compiler/plc_project/src/project.rs @@ -302,7 +302,7 @@ impl Project { /// Returns the symbol name of this projects main initializer function pub fn get_init_symbol_name(&self) -> &'static str { //Converts into static because this will live forever - format!("__init___{}", self.get_name().replace('.', "_")).leak() + format!("__init___{}", self.get_name().replace(['.', '-'], "_")).leak() } } diff --git a/src/codegen/generators/llvm.rs b/src/codegen/generators/llvm.rs index 424d6df7a5..060634f224 100644 --- a/src/codegen/generators/llvm.rs +++ b/src/codegen/generators/llvm.rs @@ -12,7 +12,7 @@ use inkwell::{ values::{BasicValue, BasicValueEnum, GlobalValue, IntValue, PointerValue}, AddressSpace, }; -use plc_ast::ast::{AstNode, LinkageType}; +use plc_ast::ast::AstNode; use plc_diagnostics::diagnostics::Diagnostic; use plc_source::source_location::SourceLocation; @@ -318,9 +318,6 @@ impl<'a> Llvm<'a> { exp_gen: &ExpressionCodeGenerator, ) -> Result<(), Diagnostic> { let (qualified_name, type_name, location) = variable; - if index.find_pou(type_name).is_some_and(|it| it.get_linkage() == &LinkageType::External) { - return Ok(()); - } let variable_llvm_type = llvm_index.get_associated_type(type_name).map_err(|err| err.with_location(location))?; diff --git a/src/codegen/generators/pou_generator.rs b/src/codegen/generators/pou_generator.rs index 4f474674e7..b35c072b00 100644 --- a/src/codegen/generators/pou_generator.rs +++ b/src/codegen/generators/pou_generator.rs @@ -38,7 +38,7 @@ use inkwell::{ types::{BasicType, StructType}, values::PointerValue, }; -use plc_ast::ast::{AstNode, Implementation, LinkageType, PouType}; +use plc_ast::ast::{AstNode, Implementation, PouType}; use plc_diagnostics::diagnostics::{Diagnostic, INTERNAL_LLVM_ERROR}; use plc_source::source_location::SourceLocation; use rustc_hash::FxHashMap; @@ -110,10 +110,8 @@ pub fn generate_global_constants_for_pou_members<'ink>( .filter(|it| it.is_in_unit(location)); for implementation in implementations { let type_name = implementation.get_type_name(); - if implementation.is_init() - || index.find_pou(type_name).is_some_and(|it| it.get_linkage() == &LinkageType::External) - { - // initializer functions and externals don't need global constants to initialize members + if implementation.is_init() { + // initializer functions don't need global constants to initialize members continue; } let pou_members = index.get_pou_members(type_name); diff --git a/src/lowering.rs b/src/lowering.rs index c0d0d16ff7..e9a0e533c2 100644 --- a/src/lowering.rs +++ b/src/lowering.rs @@ -37,7 +37,6 @@ impl InitVisitor { let mut visitor = Self::new(index, unresolvables, id_provider); // before visiting, we need to collect all candidates for user-defined init functions units.iter().for_each(|unit| { - // TODO: probably also need to consider structs here visitor.collect_user_init_candidates(unit); }); // visit all units @@ -72,7 +71,6 @@ impl InitVisitor { } fn collect_user_init_candidates(&mut self, unit: &CompilationUnit) { - // TODO: probably also need to consider structs here // collect all candidates for user-defined init functions for pou in unit.pous.iter().filter(|it| matches!(it.kind, PouType::FunctionBlock | PouType::Program)) { @@ -80,6 +78,15 @@ impl InitVisitor { self.user_inits .insert(pou.name.to_owned(), self.index.find_method(&pou.name, "FB_INIT").is_some()); } + + for user_type in + unit.user_types.iter().filter(|it| matches!(it.data_type, DataType::StructType { .. })) + { + // add the struct to potential `STRUCT_INIT` candidates + if let Some(name) = user_type.data_type.get_name() { + self.user_inits.insert(name.to_string(), false); + }; + } } fn update_initializer(&mut self, variable: &mut plc_ast::ast::Variable) { @@ -358,9 +365,6 @@ impl AstVisitorMut for InitVisitor { fn visit_data_type(&mut self, data_type: &mut DataType) { if matches!(data_type, plc_ast::ast::DataType::StructType { .. }) { - if let Some(name) = data_type.get_name() { - self.user_inits.insert(name.to_string(), false); - }; self.walk_with_scope(data_type, data_type.get_name().map(ToOwned::to_owned)) } else { data_type.walk(self) diff --git a/tests/lit/multi/extern_C_fb_init/foo.c b/tests/lit/multi/extern_C_fb_init/foo.c index 658bcb6c84..47f2db666e 100644 --- a/tests/lit/multi/extern_C_fb_init/foo.c +++ b/tests/lit/multi/extern_C_fb_init/foo.c @@ -5,7 +5,7 @@ typedef struct { int b; } myFunctionBlock; -// myFunctionBlock __myFunctionBlock__init; +myFunctionBlock __myFunctionBlock__init = { 0 }; void myFunctionBlock_FB_INIT(myFunctionBlock* fb_instance) { fb_instance->a = 1; diff --git a/tests/lit/multi/extern_C_fb_init/libfoo.so b/tests/lit/multi/extern_C_fb_init/libfoo.so deleted file mode 100755 index e1314fb78fa1deeb1995a1b7010acd6143f734ee..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15448 zcmeHOUu+!38K1j2a3M~7K$4~jG)t5qLX*XIoHQ*pIoq+bMotLE7KzlbtZ&c0EB7b8 z+aorDkYcqoO(R9BcmW>ZE${+@Ct47RKp_Gig2V$zMT$ft83~0T1h}n~>-WvfZ@pg5 zC=wF9%t*K2-`_Xiemi%wdpq-Z|Ik1(kq~H$#9d-e5+b7w`?tY^bvwioI^HDKO5c__ z(|5R2+6XGr%7yz_%&eB<)YD0T!p>?L(qb?*OCCe|p%y`-xNFEZyG1$7cF(7)lS;NU z1&&3=rEFzS-8G+{)_H=alv(D;dG65h;&g-d1C{4Qx_uV|pZP9JIm9XaL4muMaGdAW zHk5r>_qR}8QaXQ7eY*1eR#0b)=(Bt8sQBZ)j zT$o=f6Y}4#d1;#c7HXWQ)x=mL-3?9j+>g~nzj*=u0O{8^@gF7K4Wd<~uUE!i__*#w zsZw@pfmaP&SGa>Cdt5(P%}o?)L9RNor>|Hk=SIA-VouqbTiooV=Z+W3Ua{~g8-usFZt)mFz?AK(9NvcW^`;sus$@xF{CJvUaUvZx_3V27CM5PP^0QuVaF$n+T5y z5s(howZ5jXgsXo<=Z*1>@hS9q(bruz=uhhabcyEaA)ni+^n5M3)@bJ=dL9#KA4T*S zt8BXv(aYZf05XcXmWUpDuo!A8U@BlLU@BlLU@BlLU@BlLU@GtfEAUm@FaGOHf1YxV zFFtdJ5YC@Y2g$~HXZr2bTQYKE+qW;;W_`K-Th=1^m0inv^vMTZzW;o0A)Gj)8Xvm zn@LU_q`t%c8UNW~GU|Lr2}<=yJI5ZIb&mJXz9XM4UGqd`?mAEdH{H4UpsIMYl8Oa)8@Oa)8@Oa)8@Oa)8@Oa)8@Oa)8@e!>dGUOifc zav>*YqnC;Bg&42#5MIGH__)5;VhzJd3s>^>bu*P9!?zKebu8oQ zF<(4Ket0*@?u`8%efCp7@||qY^7NmReao(Sj5=Tk(@X_S1xy7@1xy7@1xy7@1xy7@ z1xy7@1?E>kum8k)PpswSHKg2H6$uxVF4OXe#{FE&SXU|+`;rdNU~7Qa>r45$jT`J= zUujfWeo!y+#2V0ceyF5|wZebVcKP5*`oBu65KA>(t*M5I8NIGl!vySj9_4kV+%KXo1e|m!~Wz>-#Po?}1ZU2v!k*5y#qY+ zoz5r?u1}xT(+YAuK9yC7-xI^}!}ZbH@UZm1USPb#|0!ac<-gE*JuBm+#d!-6=4i7x zFOoSamI-|C;QcZ&39(9~GSDdchSc9E;@A7EG`EHO3V`}p`mYM>1N}v*Um1R%p#L8+ zN!tA(V)f@OBo>?^^k&jGTc_W?fd5YE|J`->_b=f82hy*P^cS+(YETR6dX@o@3940?&2K;9FaS#RouK+_IcyLt^<2} z_6+usmiAV-{f-7WyM{?cdkg^GJ#oNRZndu3}5Wyx797O_c&~jA&3*G!L#^33B#Cxo(fu3q^lR!531>d$qi< z{i!k`6%DG&qJL=S2`<^HxuVAa%^fNR!j^@wiM1yxBnG)jI?8g})r#*0p0IOyeaZ4Z z1%afX>e?v;c!6s& z$wfAf5p50$Jf{MWc@&iA0dB}2exSU6hv#U>n5RK422+dYue3t=+6FxC3qW!H=pXgN z`Ij}mR|mv>1}OX(zmh(2{3PkPCb$m@e{c2gF7CI;MK(T_&EnX z62oV-0TlTn3}nzJV|dKtpvl+;N56=7B8JEO2a5Yq_{Y!x?;76;2TL=Wc0jKw(gA&j z^vvV>cUj62bb}JZW4!+t$P&fxx0EaBqaji;s2kL;62oI0;|up4*rylwhYb2AVcR13 z@IHrs7^uNdNpmvv?~#GW9{R`q1olCm)`h}(1BdJQ1Yy|)ch diff --git a/tests/lit/multi/extern_C_fb_init/lit.local.cfg b/tests/lit/multi/extern_C_fb_init/lit.local.cfg index bbac64e691..214961981b 100644 --- a/tests/lit/multi/extern_C_fb_init/lit.local.cfg +++ b/tests/lit/multi/extern_C_fb_init/lit.local.cfg @@ -1,27 +1,45 @@ # Override the compile command to include the custom library import os.path +import subprocess # Access the same parameters that the main configuration uses stdlibLocation = lit_config.params["LIB"] compilerLocation = lit_config.params["COMPILER"] -rustyRootDirectory = "/home/michael/dev/rusty" +# Derive rusty root directory using relative paths test_dir = os.path.dirname(__file__) -lib_path = os.path.abspath(test_dir) +source_path = os.path.abspath(test_dir) +rustyRootDirectory = os.path.abspath(os.path.join(test_dir, "..", "..", "..", "..")) + +# Use tmp directory for compiled library +tmp_lib_path = "/tmp" +tmp_lib_file = f"{tmp_lib_path}/libfoo.so" + +# Compile foo.c to libfoo.so in the tmp directory +try: + lit_config.note(f"Compiling foo.c into {tmp_lib_file}...") + gcc_cmd = f"gcc -shared -fPIC -o {tmp_lib_file} {source_path}/foo.c" + lit_config.note(f"Running: {gcc_cmd}") + result = subprocess.run(gcc_cmd, shell=True, check=True, + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + lit_config.note(f"Successfully compiled {tmp_lib_file}") +except subprocess.CalledProcessError as e: + lit_config.error(f"Failed to compile foo.c: {e.stderr.decode()}") + raise # Build on the existing compile command but add our custom library compile = f'{compilerLocation}' compile = f'{compile} -o /tmp/%basename_t.out' compile = f'{compile} -liec61131std -L{stdlibLocation}/lib -i "{stdlibLocation}/include/*.st"' compile = f'{compile} -i "{rustyRootDirectory}/tests/lit/util/*.pli"' -compile = f'{compile} -L{lib_path} -lfoo -i {lib_path}/header.pli' +compile = f'{compile} -L{tmp_lib_path} -lfoo -i {source_path}/header.pli' compile = f'{compile} --linker=cc' # Log the compile command lit_config.note(f"Compile command: {compile}") # Update the run command to include the custom library path -run_cmd = f'LD_LIBRARY_PATH="{stdlibLocation}/lib:{lib_path}" /tmp/%basename_t.out' +run_cmd = f'LD_LIBRARY_PATH="{stdlibLocation}/lib:{tmp_lib_path}" /tmp/%basename_t.out' # Override the substitutions config.substitutions = [s for s in config.substitutions if s[0] not in ['%COMPILE', '%RUN']] From 489c4117dbe71c0a5e2ba8b6a8d2f0dd7e12fac0 Mon Sep 17 00:00:00 2001 From: Michael Haselberger Date: Mon, 28 Apr 2025 06:25:15 +0200 Subject: [PATCH 8/9] fix: method and action IR names are now separated by __ instead of _ --- book/src/libraries/api_lib_guide.md | 4 +- book/src/using_rusty.md | 2 +- src/codegen/tests/code_gen_tests.rs | 40 ++++---- src/codegen/tests/debug_tests.rs | 6 +- .../complex_initializers.rs | 44 ++++----- src/codegen/tests/oop_tests.rs | 4 +- src/codegen/tests/oop_tests/debug_tests.rs | 6 +- src/codegen/tests/oop_tests/super_tests.rs | 98 +++++++++---------- ...e_gen_tests__action_called_in_program.snap | 4 +- ...ests__class_member_access_from_method.snap | 2 +- ...__code_gen_tests__class_method_in_pou.snap | 6 +- ...n_tests__fb_method_called_as_function.snap | 10 +- ...sts__code_gen_tests__fb_method_in_pou.snap | 6 +- ..._gen_tests__fb_method_with_var_in_out.snap | 4 +- ...ts__fb_method_with_var_input_defaults.snap | 4 +- ...code_gen_tests__method_codegen_return.snap | 6 +- ...__code_gen_tests__method_codegen_void.snap | 2 +- ...method_codegen_with_initialized_input.snap | 10 +- ...s__method_codegen_with_multiple_input.snap | 14 +-- ...ts__method_with_aggregate_return_type.snap | 4 +- ...s__code_gen_tests__methods_var_output.snap | 6 +- ...fied_action_from_fb_called_in_program.snap | 4 +- ...fied_foreign_action_called_in_program.snap | 4 +- ...lified_local_action_called_in_program.snap | 4 +- ...var_in_out_params_can_be_out_of_order.snap | 6 +- src/index.rs | 2 +- src/tests/adr/initializer_functions_adr.rs | 8 +- ...__integration__cfc__ir__actions_debug.snap | 8 +- tests/lit/multi/extern_C_fb_init/foo.c | 2 +- 29 files changed, 160 insertions(+), 160 deletions(-) diff --git a/book/src/libraries/api_lib_guide.md b/book/src/libraries/api_lib_guide.md index 15d15acb51..c7d9c8398f 100644 --- a/book/src/libraries/api_lib_guide.md +++ b/book/src/libraries/api_lib_guide.md @@ -362,10 +362,10 @@ This global instance follows the naming scheme of `____init`, myFunctionBlock __myFunctionBlock__init = { 0 }; ``` -3. Optionally create an initialization function following the naming pattern `_FB_INIT`: +3. Optionally create an initialization function following the naming pattern `__FB_INIT`: ```c -void myFunctionBlock_FB_INIT(myFunctionBlock* fb_instance) { +void myFunctionBlock__FB_INIT(myFunctionBlock* fb_instance) { // Initialize members here fb_instance->a = 1; fb_instance->b = 2; diff --git a/book/src/using_rusty.md b/book/src/using_rusty.md index 042040bafa..83fa8f68d1 100644 --- a/book/src/using_rusty.md +++ b/book/src/using_rusty.md @@ -142,7 +142,7 @@ When your code is compiled, the compiler creates a special initialization functi `` is either taken directly from the `plc.json`'s `name` field or derived from the first input file (replacing `.`/`-` with `_`) when compiling without a `plc.json` (e.g. `plc prog.st ...` would yield `__init___prog_st`). -This function is added to the global constructor list, therefore loading the binary will automatically call the `__init___` function (and therefore your `_FB_INIT` function) when an instance of your function block is created, before any other methods are called. This allows you to set default values or perform required setup for your function block. +This function is added to the global constructor list, therefore loading the binary will automatically call the `__init___` function (and therefore your `__FB_INIT` function) when an instance of your function block is created, before any other methods are called. This allows you to set default values or perform required setup for your function block. > **IMPORTANT:** The global constructor initialization is currently only supported for `x86` ISAs. To make sure initialization code runs reliably regardless of target-architecture, ensure your runtime calls this function before starting main task execution. If you're using the executable without a runtime, you **must** ensure that `__init___` is called before any other code runs. Failure to do so will result in uninitialized function blocks and pointers, which can lead to undefined behavior and/or crashes. diff --git a/src/codegen/tests/code_gen_tests.rs b/src/codegen/tests/code_gen_tests.rs index 26f29a137a..e6ca190d62 100644 --- a/src/codegen/tests/code_gen_tests.rs +++ b/src/codegen/tests/code_gen_tests.rs @@ -1115,11 +1115,11 @@ fn fb_method_called_locally() { define void @foo(%foo* %0) { entry: %bar = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 - %call = call i32 @foo_addToBar(%foo* %0, i16 42) + %call = call i32 @foo__addToBar(%foo* %0, i16 42) ret void } - define i32 @foo_addToBar(%foo* %0, i16 %1) { + define i32 @foo__addToBar(%foo* %0, i16 %1) { entry: %bar = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %foo.addToBar = alloca i32, align 4 @@ -1133,8 +1133,8 @@ fn fb_method_called_locally() { store i32 %tmpVar, i32* %bar, align 4 %load_bar1 = load i32, i32* %bar, align 4 store i32 %load_bar1, i32* %foo.addToBar, align 4 - %foo_addToBar_ret = load i32, i32* %foo.addToBar, align 4 - ret i32 %foo_addToBar_ret + %foo__addToBar_ret = load i32, i32* %foo.addToBar, align 4 + ret i32 %foo__addToBar_ret } define void @main() { @@ -1144,7 +1144,7 @@ fn fb_method_called_locally() { %0 = bitcast %foo* %fb to i8* call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 bitcast (%foo* @__foo__init to i8*), i64 ptrtoint (%foo* getelementptr (%foo, %foo* null, i32 1) to i64), i1 false) store i32 0, i32* %x, align 4 - %call = call i32 @foo_addToBar(%foo* %fb, i16 3) + %call = call i32 @foo__addToBar(%foo* %fb, i16 3) store i32 %call, i32* %x, align 4 ret void } @@ -1198,11 +1198,11 @@ fn fb_local_method_var_shadows_parent_var() { define void @foo(%foo* %0) { entry: %bar = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 - %call = call i32 @foo_addToBar(%foo* %0, i16 42) + %call = call i32 @foo__addToBar(%foo* %0, i16 42) ret void } - define i32 @foo_addToBar(%foo* %0, i16 %1) { + define i32 @foo__addToBar(%foo* %0, i16 %1) { entry: %bar = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %foo.addToBar = alloca i32, align 4 @@ -1218,8 +1218,8 @@ fn fb_local_method_var_shadows_parent_var() { store i32 %tmpVar, i32* %bar1, align 4 %load_bar2 = load i32, i32* %bar1, align 4 store i32 %load_bar2, i32* %foo.addToBar, align 4 - %foo_addToBar_ret = load i32, i32* %foo.addToBar, align 4 - ret i32 %foo_addToBar_ret + %foo__addToBar_ret = load i32, i32* %foo.addToBar, align 4 + ret i32 %foo__addToBar_ret } define void @main() { @@ -1229,7 +1229,7 @@ fn fb_local_method_var_shadows_parent_var() { %0 = bitcast %foo* %fb to i8* call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 bitcast (%foo* @__foo__init to i8*), i64 ptrtoint (%foo* getelementptr (%foo, %foo* null, i32 1) to i64), i1 false) store i32 0, i32* %x, align 4 - %call = call i32 @foo_addToBar(%foo* %fb, i16 3) + %call = call i32 @foo__addToBar(%foo* %fb, i16 3) store i32 %call, i32* %x, align 4 ret void } @@ -1280,11 +1280,11 @@ fn prog_method_called_locally() { define void @foo(%foo* %0) { entry: %bar = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 - %call = call i32 @foo_addToBar(%foo* %0, i16 42) + %call = call i32 @foo__addToBar(%foo* %0, i16 42) ret void } - define i32 @foo_addToBar(%foo* %0, i16 %1) { + define i32 @foo__addToBar(%foo* %0, i16 %1) { entry: %bar = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %foo.addToBar = alloca i32, align 4 @@ -1298,15 +1298,15 @@ fn prog_method_called_locally() { store i32 %tmpVar, i32* %bar, align 4 %load_bar1 = load i32, i32* %bar, align 4 store i32 %load_bar1, i32* %foo.addToBar, align 4 - %foo_addToBar_ret = load i32, i32* %foo.addToBar, align 4 - ret i32 %foo_addToBar_ret + %foo__addToBar_ret = load i32, i32* %foo.addToBar, align 4 + ret i32 %foo__addToBar_ret } define void @main() { entry: %x = alloca i32, align 4 store i32 0, i32* %x, align 4 - %call = call i32 @foo_addToBar(%foo* @foo_instance, i16 3) + %call = call i32 @foo__addToBar(%foo* @foo_instance, i16 3) store i32 %call, i32* %x, align 4 ret void } @@ -1354,11 +1354,11 @@ fn prog_local_method_var_shadows_parent_var() { define void @foo(%foo* %0) { entry: %bar = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 - %call = call i32 @foo_addToBar(%foo* %0, i16 42) + %call = call i32 @foo__addToBar(%foo* %0, i16 42) ret void } - define i32 @foo_addToBar(%foo* %0, i16 %1) { + define i32 @foo__addToBar(%foo* %0, i16 %1) { entry: %bar = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %foo.addToBar = alloca i32, align 4 @@ -1374,15 +1374,15 @@ fn prog_local_method_var_shadows_parent_var() { store i32 %tmpVar, i32* %bar1, align 4 %load_bar2 = load i32, i32* %bar1, align 4 store i32 %load_bar2, i32* %foo.addToBar, align 4 - %foo_addToBar_ret = load i32, i32* %foo.addToBar, align 4 - ret i32 %foo_addToBar_ret + %foo__addToBar_ret = load i32, i32* %foo.addToBar, align 4 + ret i32 %foo__addToBar_ret } define void @main() { entry: %x = alloca i32, align 4 store i32 0, i32* %x, align 4 - %call = call i32 @foo_addToBar(%foo* @foo_instance, i16 3) + %call = call i32 @foo__addToBar(%foo* @foo_instance, i16 3) store i32 %call, i32* %x, align 4 ret void } diff --git a/src/codegen/tests/debug_tests.rs b/src/codegen/tests/debug_tests.rs index 91d86b89eb..0cd6f32a86 100644 --- a/src/codegen/tests/debug_tests.rs +++ b/src/codegen/tests/debug_tests.rs @@ -364,7 +364,7 @@ fn dbg_declare_has_valid_metadata_references_for_methods() { ret void, !dbg !13 } - define void @fb_foo(%fb* %0) !dbg !14 { + define void @fb__foo(%fb* %0) !dbg !14 { entry: call void @llvm.dbg.declare(metadata %fb* %0, metadata !15, metadata !DIExpression()), !dbg !16 ret void, !dbg !16 @@ -457,7 +457,7 @@ fn action_with_var_temp() { call void @llvm.dbg.declare(metadata i32* %main, metadata !12, metadata !DIExpression()), !dbg !14 store i32 0, i32* %main, align 4 call void @PLC_PRG(%PLC_PRG* @PLC_PRG_instance), !dbg !15 - call void @PLC_PRG_act(%PLC_PRG* @PLC_PRG_instance), !dbg !16 + call void @PLC_PRG__act(%PLC_PRG* @PLC_PRG_instance), !dbg !16 %main_ret = load i32, i32* %main, align 4, !dbg !17 ret i32 %main_ret, !dbg !17 } @@ -472,7 +472,7 @@ fn action_with_var_temp() { ret void, !dbg !25 } - define void @PLC_PRG_act(%PLC_PRG* %0) !dbg !26 { + define void @PLC_PRG__act(%PLC_PRG* %0) !dbg !26 { entry: call void @llvm.dbg.declare(metadata %PLC_PRG* %0, metadata !27, metadata !DIExpression()), !dbg !28 %x = alloca i32, align 4 diff --git a/src/codegen/tests/initialization_test/complex_initializers.rs b/src/codegen/tests/initialization_test/complex_initializers.rs index 857e3c94bf..7ac7588494 100644 --- a/src/codegen/tests/initialization_test/complex_initializers.rs +++ b/src/codegen/tests/initialization_test/complex_initializers.rs @@ -388,7 +388,7 @@ fn nested_initializer_pous() { entry: %str_ref = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %b = getelementptr inbounds %foo, %foo* %0, i32 0, i32 1 - call void @bar_print(%bar* %b) + call void @bar__print(%bar* %b) call void @bar(%bar* %b) ret void } @@ -396,7 +396,7 @@ fn nested_initializer_pous() { define void @bar(%bar* %0) { entry: %b = getelementptr inbounds %bar, %bar* %0, i32 0, i32 0 - call void @baz_print(%baz* %b) + call void @baz__print(%baz* %b) ret void } @@ -418,24 +418,24 @@ fn nested_initializer_pous() { %other_ref_to_global = getelementptr inbounds %sideProg, %sideProg* %0, i32 0, i32 0 %f = getelementptr inbounds %sideProg, %sideProg* %0, i32 0, i32 1 call void @foo(%foo* %f) - call void @foo_print(%foo* %f) + call void @foo__print(%foo* %f) ret void } - define void @bar_print(%bar* %0) { + define void @bar__print(%bar* %0) { entry: %b = getelementptr inbounds %bar, %bar* %0, i32 0, i32 0 ret void } - define void @foo_print(%foo* %0) { + define void @foo__print(%foo* %0) { entry: %str_ref = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %b = getelementptr inbounds %foo, %foo* %0, i32 0, i32 1 ret void } - define void @baz_print(%baz* %0) { + define void @baz__print(%baz* %0) { entry: %str_ref = getelementptr inbounds %baz, %baz* %0, i32 0, i32 0 ret void @@ -834,7 +834,7 @@ fn stateful_pous_methods_and_structs_get_init_functions() { ret void } - define void @foo_m(%foo* %0) { + define void @foo__m(%foo* %0) { entry: ret void } @@ -844,12 +844,12 @@ fn stateful_pous_methods_and_structs_get_init_functions() { ret void } - define void @cl_m(%cl* %0) { + define void @cl__m(%cl* %0) { entry: ret void } - define void @foo_act(%foo* %0) { + define void @foo__act(%foo* %0) { entry: ret void } @@ -1657,7 +1657,7 @@ fn initializing_method_variables_with_refs() { ret void } - define void @foo_bar(%foo* %0) { + define void @foo__bar(%foo* %0) { entry: %x = alloca i32, align 4 %px = alloca i32*, align 8 @@ -1724,7 +1724,7 @@ fn initializing_method_variables_with_refs_referencing_parent_pou_variable() { ret void } - define void @foo_bar(%foo* %0) { + define void @foo__bar(%foo* %0) { entry: %x = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %px = alloca i32*, align 8 @@ -1790,7 +1790,7 @@ fn initializing_method_variables_with_refs_referencing_global_variable() { ret void } - define void @foo_bar(%foo* %0) { + define void @foo__bar(%foo* %0) { entry: %px = alloca i32*, align 8 store i32* @x, i32** %px, align 8 @@ -1856,7 +1856,7 @@ fn initializing_method_variables_with_refs_shadowing() { ret void } - define void @foo_bar(%foo* %0) { + define void @foo__bar(%foo* %0) { entry: %x = alloca i32, align 4 %px = alloca i32*, align 8 @@ -1919,7 +1919,7 @@ fn initializing_method_variables_with_alias() { ret void } - define void @foo_bar(%foo* %0) { + define void @foo__bar(%foo* %0) { entry: %x = alloca i32, align 4 %px = alloca i32*, align 8 @@ -1982,7 +1982,7 @@ fn initializing_method_variables_with_reference_to() { ret void } - define void @foo_bar(%foo* %0) { + define void @foo__bar(%foo* %0) { entry: %x = alloca i32, align 4 %px = alloca i32*, align 8 @@ -2061,7 +2061,7 @@ fn methods_call_init_functions_for_their_members() { ret void } - define void @bar_baz(%bar* %0) { + define void @bar__baz(%bar* %0) { entry: %fb = alloca %foo, align 8 %1 = bitcast %foo* %fb to i8* @@ -2162,7 +2162,7 @@ fn user_fb_init_is_added_and_called_if_it_exists() { ret void } - define void @foo_FB_INIT(%foo* %0) { + define void @foo__FB_INIT(%foo* %0) { entry: %x = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %y = getelementptr inbounds %foo, %foo* %0, i32 0, i32 1 @@ -2210,7 +2210,7 @@ fn user_fb_init_is_added_and_called_if_it_exists() { %self = alloca %foo*, align 8 store %foo* %0, %foo** %self, align 8 %deref = load %foo*, %foo** %self, align 8 - call void @foo_FB_INIT(%foo* %deref) + call void @foo__FB_INIT(%foo* %deref) ret void } @@ -2282,7 +2282,7 @@ fn user_fb_init_in_global_struct() { ret void } - define void @foo_FB_INIT(%foo* %0) { + define void @foo__FB_INIT(%foo* %0) { entry: %x = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %y = getelementptr inbounds %foo, %foo* %0, i32 0, i32 1 @@ -2351,7 +2351,7 @@ fn user_fb_init_in_global_struct() { %self = alloca %foo*, align 8 store %foo* %0, %foo** %self, align 8 %deref = load %foo*, %foo** %self, align 8 - call void @foo_FB_INIT(%foo* %deref) + call void @foo__FB_INIT(%foo* %deref) ret void } @@ -2406,7 +2406,7 @@ fn user_init_called_when_declared_as_external() { declare void @foo(%foo*) - declare void @foo_FB_INIT(%foo*) + declare void @foo__FB_INIT(%foo*) define void @prog(%prog* %0) { entry: @@ -2437,7 +2437,7 @@ fn user_init_called_when_declared_as_external() { %self = alloca %foo*, align 8 store %foo* %0, %foo** %self, align 8 %deref = load %foo*, %foo** %self, align 8 - call void @foo_FB_INIT(%foo* %deref) + call void @foo__FB_INIT(%foo* %deref) ret void } diff --git a/src/codegen/tests/oop_tests.rs b/src/codegen/tests/oop_tests.rs index 29c8eae4a8..c0c602f417 100644 --- a/src/codegen/tests/oop_tests.rs +++ b/src/codegen/tests/oop_tests.rs @@ -250,7 +250,7 @@ fn write_to_parent_variable_in_instance() { ret void } - define void @foo_baz(%foo* %0) { + define void @foo__baz(%foo* %0) { entry: %s = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %1 = bitcast [81 x i8]* %s to i8* @@ -278,7 +278,7 @@ fn write_to_parent_variable_in_instance() { call void @__init_bar(%bar* %fb) call void @__user_init_bar(%bar* %fb) %__foo = getelementptr inbounds %bar, %bar* %fb, i32 0, i32 0 - call void @foo_baz(%foo* %__foo) + call void @foo__baz(%foo* %__foo) call void @bar(%bar* %fb) ret void } diff --git a/src/codegen/tests/oop_tests/debug_tests.rs b/src/codegen/tests/oop_tests/debug_tests.rs index ea080bc34a..3157f54d35 100644 --- a/src/codegen/tests/oop_tests/debug_tests.rs +++ b/src/codegen/tests/oop_tests/debug_tests.rs @@ -346,7 +346,7 @@ fn write_to_parent_variable_in_instance() { ret void, !dbg !24 } - define void @foo_baz(%foo* %0) !dbg !25 { + define void @foo__baz(%foo* %0) !dbg !25 { entry: call void @llvm.dbg.declare(metadata %foo* %0, metadata !26, metadata !DIExpression()), !dbg !27 %s = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 @@ -378,7 +378,7 @@ fn write_to_parent_variable_in_instance() { call void @__init_bar(%bar* %fb), !dbg !42 call void @__user_init_bar(%bar* %fb), !dbg !42 %__foo = getelementptr inbounds %bar, %bar* %fb, i32 0, i32 0, !dbg !42 - call void @foo_baz(%foo* %__foo), !dbg !43 + call void @foo__baz(%foo* %__foo), !dbg !43 call void @bar(%bar* %fb), !dbg !44 ret void, !dbg !45 } @@ -967,7 +967,7 @@ fn function_block_method_debug_info() { ret void, !dbg !18 } - define void @foo_baz(%foo* %0) !dbg !19 { + define void @foo__baz(%foo* %0) !dbg !19 { entry: call void @llvm.dbg.declare(metadata %foo* %0, metadata !20, metadata !DIExpression()), !dbg !21 ret void, !dbg !21 diff --git a/src/codegen/tests/oop_tests/super_tests.rs b/src/codegen/tests/oop_tests/super_tests.rs index 197afdfda9..9f1695a320 100644 --- a/src/codegen/tests/oop_tests/super_tests.rs +++ b/src/codegen/tests/oop_tests/super_tests.rs @@ -210,7 +210,7 @@ fn super_in_method_calls() { ret void } - define i16 @parent_process(%parent* %0) { + define i16 @parent__process(%parent* %0) { entry: %value = getelementptr inbounds %parent, %parent* %0, i32 0, i32 0 %parent.process = alloca i16, align 2 @@ -220,8 +220,8 @@ fn super_in_method_calls() { %tmpVar = mul i32 %1, 2 %2 = trunc i32 %tmpVar to i16 store i16 %2, i16* %parent.process, align 2 - %parent_process_ret = load i16, i16* %parent.process, align 2 - ret i16 %parent_process_ret + %parent__process_ret = load i16, i16* %parent.process, align 2 + ret i16 %parent__process_ret } define void @child(%child* %0) { @@ -230,7 +230,7 @@ fn super_in_method_calls() { ret void } - define i16 @child_process(%child* %0) { + define i16 @child__process(%child* %0) { entry: %__parent = getelementptr inbounds %child, %child* %0, i32 0, i32 0 %child.process = alloca i16, align 2 @@ -241,19 +241,19 @@ fn super_in_method_calls() { %tmpVar = add i32 %1, 5 %2 = trunc i32 %tmpVar to i16 store i16 %2, i16* %child.process, align 2 - %child_process_ret = load i16, i16* %child.process, align 2 - ret i16 %child_process_ret + %child__process_ret = load i16, i16* %child.process, align 2 + ret i16 %child__process_ret } - define i16 @child_test(%child* %0) { + define i16 @child__test(%child* %0) { entry: %__parent = getelementptr inbounds %child, %child* %0, i32 0, i32 0 %child.test = alloca i16, align 2 store i16 0, i16* %child.test, align 2 - %call = call i16 @parent_process(%parent* %__parent) + %call = call i16 @parent__process(%parent* %__parent) store i16 %call, i16* %child.test, align 2 - %child_test_ret = load i16, i16* %child.test, align 2 - ret i16 %child_test_ret + %child__test_ret = load i16, i16* %child.test, align 2 + ret i16 %child__test_ret } define void @__init_parent(%parent* %0) { @@ -540,15 +540,15 @@ fn super_in_multi_level_inheritance() { ret void } - define i16 @grandparent_gp_method(%grandparent* %0) { + define i16 @grandparent__gp_method(%grandparent* %0) { entry: %g_val = getelementptr inbounds %grandparent, %grandparent* %0, i32 0, i32 0 %grandparent.gp_method = alloca i16, align 2 store i16 0, i16* %grandparent.gp_method, align 2 %load_g_val = load i16, i16* %g_val, align 2 store i16 %load_g_val, i16* %grandparent.gp_method, align 2 - %grandparent_gp_method_ret = load i16, i16* %grandparent.gp_method, align 2 - ret i16 %grandparent_gp_method_ret + %grandparent__gp_method_ret = load i16, i16* %grandparent.gp_method, align 2 + ret i16 %grandparent__gp_method_ret } define void @parent(%parent* %0) { @@ -558,7 +558,7 @@ fn super_in_multi_level_inheritance() { ret void } - define i16 @parent_p_method(%parent* %0) { + define i16 @parent__p_method(%parent* %0) { entry: %__grandparent = getelementptr inbounds %parent, %parent* %0, i32 0, i32 0 %p_val = getelementptr inbounds %parent, %parent* %0, i32 0, i32 1 @@ -566,13 +566,13 @@ fn super_in_multi_level_inheritance() { store i16 0, i16* %parent.p_method, align 2 %load_p_val = load i16, i16* %p_val, align 2 %1 = sext i16 %load_p_val to i32 - %call = call i16 @grandparent_gp_method(%grandparent* %__grandparent) + %call = call i16 @grandparent__gp_method(%grandparent* %__grandparent) %2 = sext i16 %call to i32 %tmpVar = add i32 %1, %2 %3 = trunc i32 %tmpVar to i16 store i16 %3, i16* %parent.p_method, align 2 - %parent_p_method_ret = load i16, i16* %parent.p_method, align 2 - ret i16 %parent_p_method_ret + %parent__p_method_ret = load i16, i16* %parent.p_method, align 2 + ret i16 %parent__p_method_ret } define void @child(%child* %0) { @@ -582,16 +582,16 @@ fn super_in_multi_level_inheritance() { ret void } - define i16 @child_test(%child* %0) { + define i16 @child__test(%child* %0) { entry: %__parent = getelementptr inbounds %child, %child* %0, i32 0, i32 0 %c_val = getelementptr inbounds %child, %child* %0, i32 0, i32 1 %child.test = alloca i16, align 2 store i16 0, i16* %child.test, align 2 - %call = call i16 @parent_p_method(%parent* %__parent) + %call = call i16 @parent__p_method(%parent* %__parent) store i16 %call, i16* %child.test, align 2 - %child_test_ret = load i16, i16* %child.test, align 2 - ret i16 %child_test_ret + %child__test_ret = load i16, i16* %child.test, align 2 + ret i16 %child__test_ret } define void @__init_parent(%parent* %0) { @@ -803,7 +803,7 @@ fn super_in_conditionals() { ret void } - define void @child_test(%child* %0) { + define void @child__test(%child* %0) { entry: %__parent = getelementptr inbounds %child, %child* %0, i32 0, i32 0 %value = getelementptr inbounds %parent, %parent* %__parent, i32 0, i32 1 @@ -1035,7 +1035,7 @@ fn super_as_function_parameter() { ret void } - define void @child_test(%child* %0) { + define void @child__test(%child* %0) { entry: %__parent = getelementptr inbounds %child, %child* %0, i32 0, i32 0 %call = call i16 @process_ref(%parent* %__parent) @@ -1159,7 +1159,7 @@ fn super_with_deeply_nested_expressions() { ret void } - define i16 @parent_calc(%parent* %0) { + define i16 @parent__calc(%parent* %0) { entry: %a = getelementptr inbounds %parent, %parent* %0, i32 0, i32 0 %b = getelementptr inbounds %parent, %parent* %0, i32 0, i32 1 @@ -1176,8 +1176,8 @@ fn super_with_deeply_nested_expressions() { %tmpVar1 = add i32 %1, %tmpVar %4 = trunc i32 %tmpVar1 to i16 store i16 %4, i16* %parent.calc, align 2 - %parent_calc_ret = load i16, i16* %parent.calc, align 2 - ret i16 %parent_calc_ret + %parent__calc_ret = load i16, i16* %parent.calc, align 2 + ret i16 %parent__calc_ret } define void @child(%child* %0) { @@ -1186,7 +1186,7 @@ fn super_with_deeply_nested_expressions() { ret void } - define i16 @child_test(%child* %0) { + define i16 @child__test(%child* %0) { entry: %__parent = getelementptr inbounds %child, %child* %0, i32 0, i32 0 %child.test = alloca i16, align 2 @@ -1202,7 +1202,7 @@ fn super_with_deeply_nested_expressions() { %load_c = load i16, i16* %c, align 2 %3 = sext i16 %load_c to i32 %tmpVar1 = mul i32 %tmpVar, %3 - %call = call i16 @parent_calc(%parent* %__parent) + %call = call i16 @parent__calc(%parent* %__parent) %4 = sext i16 %call to i32 %tmpVar2 = add i32 %tmpVar1, %4 %a3 = getelementptr inbounds %parent, %parent* %__parent, i32 0, i32 0 @@ -1212,8 +1212,8 @@ fn super_with_deeply_nested_expressions() { %tmpVar6 = sdiv i32 %tmpVar2, %tmpVar5 %6 = trunc i32 %tmpVar6 to i16 store i16 %6, i16* %child.test, align 2 - %child_test_ret = load i16, i16* %child.test, align 2 - ret i16 %child_test_ret + %child__test_ret = load i16, i16* %child.test, align 2 + ret i16 %child__test_ret } define void @__init_parent(%parent* %0) { @@ -1318,7 +1318,7 @@ fn super_in_loop_constructs() { ret void } - define void @parent_increment(%parent* %0) { + define void @parent__increment(%parent* %0) { entry: %counter = getelementptr inbounds %parent, %parent* %0, i32 0, i32 0 %arr = getelementptr inbounds %parent, %parent* %0, i32 0, i32 1 @@ -1336,7 +1336,7 @@ fn super_in_loop_constructs() { ret void } - define void @child_process(%child* %0) { + define void @child__process(%child* %0) { entry: %__parent = getelementptr inbounds %child, %child* %0, i32 0, i32 0 %i = alloca i16, align 2 @@ -1372,7 +1372,7 @@ fn super_in_loop_constructs() { %tmpVar4 = add i32 %5, %7 %8 = trunc i32 %tmpVar4 to i16 store i16 %8, i16* %sum, align 2 - call void @parent_increment(%parent* %__parent) + call void @parent__increment(%parent* %__parent) br label %increment increment: ; preds = %loop @@ -1409,7 +1409,7 @@ fn super_in_loop_constructs() { br label %continue6 continue6: ; preds = %buffer_block, %while_body - call void @parent_increment(%parent* %__parent) + call void @parent__increment(%parent* %__parent) br label %condition_check condition_check9: ; preds = %continue16, %continue5 @@ -1528,13 +1528,13 @@ fn super_with_method_overrides_in_three_levels() { ret void } - define i16 @grandparent_calculate(%grandparent* %0) { + define i16 @grandparent__calculate(%grandparent* %0) { entry: %grandparent.calculate = alloca i16, align 2 store i16 0, i16* %grandparent.calculate, align 2 store i16 100, i16* %grandparent.calculate, align 2 - %grandparent_calculate_ret = load i16, i16* %grandparent.calculate, align 2 - ret i16 %grandparent_calculate_ret + %grandparent__calculate_ret = load i16, i16* %grandparent.calculate, align 2 + ret i16 %grandparent__calculate_ret } define void @parent(%parent* %0) { @@ -1543,18 +1543,18 @@ fn super_with_method_overrides_in_three_levels() { ret void } - define i16 @parent_calculate(%parent* %0) { + define i16 @parent__calculate(%parent* %0) { entry: %__grandparent = getelementptr inbounds %parent, %parent* %0, i32 0, i32 0 %parent.calculate = alloca i16, align 2 store i16 0, i16* %parent.calculate, align 2 - %call = call i16 @grandparent_calculate(%grandparent* %__grandparent) + %call = call i16 @grandparent__calculate(%grandparent* %__grandparent) %1 = sext i16 %call to i32 %tmpVar = add i32 %1, 50 %2 = trunc i32 %tmpVar to i16 store i16 %2, i16* %parent.calculate, align 2 - %parent_calculate_ret = load i16, i16* %parent.calculate, align 2 - ret i16 %parent_calculate_ret + %parent__calculate_ret = load i16, i16* %parent.calculate, align 2 + ret i16 %parent__calculate_ret } define void @child(%child* %0) { @@ -1563,18 +1563,18 @@ fn super_with_method_overrides_in_three_levels() { ret void } - define i16 @child_calculate(%child* %0) { + define i16 @child__calculate(%child* %0) { entry: %__parent = getelementptr inbounds %child, %child* %0, i32 0, i32 0 %child.calculate = alloca i16, align 2 store i16 0, i16* %child.calculate, align 2 - %call = call i16 @parent_calculate(%parent* %__parent) + %call = call i16 @parent__calculate(%parent* %__parent) %1 = sext i16 %call to i32 %tmpVar = add i32 %1, 25 %2 = trunc i32 %tmpVar to i16 store i16 %2, i16* %child.calculate, align 2 - %child_calculate_ret = load i16, i16* %child.calculate, align 2 - ret i16 %child_calculate_ret + %child__calculate_ret = load i16, i16* %child.calculate, align 2 + ret i16 %child__calculate_ret } define void @__init_parent(%parent* %0) { @@ -1745,7 +1745,7 @@ fn super_with_structured_types() { ret void } - define void @child_test(%child* %0) { + define void @child__test(%child* %0) { entry: %__parent = getelementptr inbounds %child, %child* %0, i32 0, i32 0 %local_data = alloca %Complex_Type, align 8 @@ -1893,7 +1893,7 @@ fn super_in_action_blocks() { ret void } - define void @parent_increment(%parent* %0) { + define void @parent__increment(%parent* %0) { entry: %value = getelementptr inbounds %parent, %parent* %0, i32 0, i32 0 %load_value = load i16, i16* %value, align 2 @@ -1910,7 +1910,7 @@ fn super_in_action_blocks() { ret void } - define void @child_increase(%child* %0) { + define void @child__increase(%child* %0) { entry: %__parent = getelementptr inbounds %child, %child* %0, i32 0, i32 0 %value = getelementptr inbounds %parent, %parent* %__parent, i32 0, i32 0 @@ -1920,7 +1920,7 @@ fn super_in_action_blocks() { %tmpVar = add i32 %1, 5 %2 = trunc i32 %tmpVar to i16 store i16 %2, i16* %value, align 2 - call void @parent_increment(%parent* %__parent) + call void @parent__increment(%parent* %__parent) ret void } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__action_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__action_called_in_program.snap index c5d565cfed..6988447b8d 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__action_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__action_called_in_program.snap @@ -13,11 +13,11 @@ source_filename = "" define void @prg(%prg* %0) { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 - call void @prg_foo(%prg* %0) + call void @prg__foo(%prg* %0) ret void } -define void @prg_foo(%prg* %0) { +define void @prg__foo(%prg* %0) { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i32 2, i32* %x, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__class_member_access_from_method.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__class_member_access_from_method.snap index dec0e75534..a8077e6321 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__class_member_access_from_method.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__class_member_access_from_method.snap @@ -17,7 +17,7 @@ entry: ret void } -define void @MyClass_testMethod(%MyClass* %0, i16 %1) { +define void @MyClass__testMethod(%MyClass* %0, i16 %1) { entry: %x = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 0 %y = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__class_method_in_pou.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__class_method_in_pou.snap index 50357bb56b..fea5756587 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__class_method_in_pou.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__class_method_in_pou.snap @@ -19,7 +19,7 @@ entry: ret void } -define void @MyClass_testMethod(%MyClass* %0, i16 %1) { +define void @MyClass__testMethod(%MyClass* %0, i16 %1) { entry: %x = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 0 %y = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 1 @@ -47,8 +47,8 @@ entry: %load_x = load i16, i16* %x1, align 2 store i16 %load_x, i16* %x, align 2 %load_x2 = load i16, i16* %x, align 2 - call void @MyClass_testMethod(%MyClass* %cl, i16 %load_x2) + call void @MyClass__testMethod(%MyClass* %cl, i16 %load_x2) %load_x3 = load i16, i16* %x, align 2 - call void @MyClass_testMethod(%MyClass* %cl, i16 %load_x3) + call void @MyClass__testMethod(%MyClass* %cl, i16 %load_x3) ret void } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_called_as_function.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_called_as_function.snap index 2630bd0c34..7e7fb47588 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_called_as_function.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_called_as_function.snap @@ -14,12 +14,12 @@ define void @MyClass(%MyClass* %0) { entry: %x = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 0 %y = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 1 - %call = call i16 @MyClass_testMethod(%MyClass* %0, i16 1) - %call1 = call i16 @MyClass_testMethod(%MyClass* %0, i16 3) + %call = call i16 @MyClass__testMethod(%MyClass* %0, i16 1) + %call1 = call i16 @MyClass__testMethod(%MyClass* %0, i16 3) ret void } -define i16 @MyClass_testMethod(%MyClass* %0, i16 %1) { +define i16 @MyClass__testMethod(%MyClass* %0, i16 %1) { entry: %x = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 0 %y = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 1 @@ -46,6 +46,6 @@ entry: %tmpVar2 = add i32 %6, 1 %7 = trunc i32 %tmpVar2 to i16 store i16 %7, i16* %MyClass.testMethod, align 2 - %MyClass_testMethod_ret = load i16, i16* %MyClass.testMethod, align 2 - ret i16 %MyClass_testMethod_ret + %MyClass__testMethod_ret = load i16, i16* %MyClass.testMethod, align 2 + ret i16 %MyClass__testMethod_ret } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_in_pou.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_in_pou.snap index 50357bb56b..fea5756587 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_in_pou.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_in_pou.snap @@ -19,7 +19,7 @@ entry: ret void } -define void @MyClass_testMethod(%MyClass* %0, i16 %1) { +define void @MyClass__testMethod(%MyClass* %0, i16 %1) { entry: %x = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 0 %y = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 1 @@ -47,8 +47,8 @@ entry: %load_x = load i16, i16* %x1, align 2 store i16 %load_x, i16* %x, align 2 %load_x2 = load i16, i16* %x, align 2 - call void @MyClass_testMethod(%MyClass* %cl, i16 %load_x2) + call void @MyClass__testMethod(%MyClass* %cl, i16 %load_x2) %load_x3 = load i16, i16* %x, align 2 - call void @MyClass_testMethod(%MyClass* %cl, i16 %load_x3) + call void @MyClass__testMethod(%MyClass* %cl, i16 %load_x3) ret void } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_with_var_in_out.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_with_var_in_out.snap index 3b49aa33b9..d41b415537 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_with_var_in_out.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_with_var_in_out.snap @@ -19,7 +19,7 @@ entry: ret void } -define void @MyClass_testMethod(%MyClass* %0, i16* %1) { +define void @MyClass__testMethod(%MyClass* %0, i16* %1) { entry: %x = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 0 %y = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 1 @@ -35,6 +35,6 @@ define void @prg(%prg* %0) { entry: %cl = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 - call void @MyClass_testMethod(%MyClass* %cl, i16* %x) + call void @MyClass__testMethod(%MyClass* %cl, i16* %x) ret void } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_with_var_input_defaults.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_with_var_input_defaults.snap index c4fa686240..ad0d53b36e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_with_var_input_defaults.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_with_var_input_defaults.snap @@ -19,7 +19,7 @@ entry: ret void } -define void @MyClass_testMethod(%MyClass* %0, i16 %1) { +define void @MyClass__testMethod(%MyClass* %0, i16 %1) { entry: %x = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 0 %y = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 1 @@ -33,6 +33,6 @@ entry: define void @prg(%prg* %0) { entry: %cl = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 - call void @MyClass_testMethod(%MyClass* %cl, i16 3) + call void @MyClass__testMethod(%MyClass* %cl, i16 3) ret void } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_return.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_return.snap index a343c626bb..f7e2f2e162 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_return.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_return.snap @@ -15,13 +15,13 @@ entry: ret void } -define i16 @MyClass_testMethod(%MyClass* %0, i16 %1) { +define i16 @MyClass__testMethod(%MyClass* %0, i16 %1) { entry: %MyClass.testMethod = alloca i16, align 2 %myMethodArg = alloca i16, align 2 store i16 %1, i16* %myMethodArg, align 2 store i16 0, i16* %MyClass.testMethod, align 2 store i16 1, i16* %MyClass.testMethod, align 2 - %MyClass_testMethod_ret = load i16, i16* %MyClass.testMethod, align 2 - ret i16 %MyClass_testMethod_ret + %MyClass__testMethod_ret = load i16, i16* %MyClass.testMethod, align 2 + ret i16 %MyClass__testMethod_ret } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_void.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_void.snap index d941e6b626..9159ec326e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_void.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_void.snap @@ -15,7 +15,7 @@ entry: ret void } -define void @MyClass_testMethod(%MyClass* %0, i16 %1) { +define void @MyClass__testMethod(%MyClass* %0, i16 %1) { entry: %myMethodArg = alloca i16, align 2 store i16 %1, i16* %myMethodArg, align 2 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_with_initialized_input.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_with_initialized_input.snap index 84bec9d108..b13882ad66 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_with_initialized_input.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_with_initialized_input.snap @@ -12,19 +12,19 @@ source_filename = "" define void @fb(%fb* %0) { entry: - %call = call i32 @fb_meth(%fb* %0, i32 5) - %call1 = call i32 @fb_meth(%fb* %0, i32 4) + %call = call i32 @fb__meth(%fb* %0, i32 5) + %call1 = call i32 @fb__meth(%fb* %0, i32 4) ret void } -define i32 @fb_meth(%fb* %0, i32 %1) { +define i32 @fb__meth(%fb* %0, i32 %1) { entry: %fb.meth = alloca i32, align 4 %a = alloca i32, align 4 store i32 %1, i32* %a, align 4 store i32 0, i32* %fb.meth, align 4 - %fb_meth_ret = load i32, i32* %fb.meth, align 4 - ret i32 %fb_meth_ret + %fb__meth_ret = load i32, i32* %fb.meth, align 4 + ret i32 %fb__meth_ret } define i32 @foo() { diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_with_multiple_input.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_with_multiple_input.snap index c1b33f8462..e4ff4020a2 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_with_multiple_input.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_with_multiple_input.snap @@ -12,14 +12,14 @@ source_filename = "" define void @fb(%fb* %0) { entry: - %call = call i32 @fb_meth(%fb* %0, i32 1, i32 2, i32 3) - %call1 = call i32 @fb_meth(%fb* %0, i32 5, i32 7, i32 10) - %call2 = call i32 @fb_meth(%fb* %0, i32 3, i32 4, i32 10) - %call3 = call i32 @fb_meth(%fb* %0, i32 6, i32 4, i32 10) + %call = call i32 @fb__meth(%fb* %0, i32 1, i32 2, i32 3) + %call1 = call i32 @fb__meth(%fb* %0, i32 5, i32 7, i32 10) + %call2 = call i32 @fb__meth(%fb* %0, i32 3, i32 4, i32 10) + %call3 = call i32 @fb__meth(%fb* %0, i32 6, i32 4, i32 10) ret void } -define i32 @fb_meth(%fb* %0, i32 %1, i32 %2, i32 %3) { +define i32 @fb__meth(%fb* %0, i32 %1, i32 %2, i32 %3) { entry: %fb.meth = alloca i32, align 4 %a = alloca i32, align 4 @@ -29,6 +29,6 @@ entry: %c = alloca i32, align 4 store i32 %3, i32* %c, align 4 store i32 0, i32* %fb.meth, align 4 - %fb_meth_ret = load i32, i32* %fb.meth, align 4 - ret i32 %fb_meth_ret + %fb__meth_ret = load i32, i32* %fb.meth, align 4 + ret i32 %fb__meth_ret } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_with_aggregate_return_type.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_with_aggregate_return_type.snap index cb1b14c815..f608376cb2 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_with_aggregate_return_type.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_with_aggregate_return_type.snap @@ -20,14 +20,14 @@ entry: %2 = bitcast [81 x i8]* %__method_with_aggregagte_return0 to i8* call void @llvm.memset.p0i8.i64(i8* align 1 %2, i8 0, i64 ptrtoint ([81 x i8]* getelementptr ([81 x i8], [81 x i8]* null, i32 1) to i64), i1 false) %3 = bitcast [81 x i8]* %__method_with_aggregagte_return0 to i8* - call void @fb_with_method_method_with_aggregagte_return(%fb_with_method* %0, i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @utf08_literal_0, i32 0, i32 0)) + call void @fb_with_method__method_with_aggregagte_return(%fb_with_method* %0, i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @utf08_literal_0, i32 0, i32 0)) %4 = bitcast [81 x i8]* %ret to i8* %5 = bitcast [81 x i8]* %__method_with_aggregagte_return0 to i8* call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %4, i8* align 1 %5, i32 80, i1 false) ret void } -define void @fb_with_method_method_with_aggregagte_return(%fb_with_method* %0, i8* %1, i8* %2) { +define void @fb_with_method__method_with_aggregagte_return(%fb_with_method* %0, i8* %1, i8* %2) { entry: %ret = alloca [81 x i8], align 1 %method_with_aggregagte_return = alloca i8*, align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__methods_var_output.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__methods_var_output.snap index 3e54d86274..f4cfb1c632 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__methods_var_output.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__methods_var_output.snap @@ -16,7 +16,7 @@ entry: ret void } -define void @foo_baz(%foo* %0, [81 x i8]* %1) { +define void @foo__baz(%foo* %0, [81 x i8]* %1) { entry: %out = alloca [81 x i8]*, align 8 store [81 x i8]* %1, [81 x i8]** %out, align 8 @@ -35,9 +35,9 @@ entry: %1 = bitcast %foo* %fb to i8* call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %1, i8* align 1 bitcast (%foo* @__foo__init to i8*), i64 ptrtoint (%foo* getelementptr (%foo, %foo* null, i32 1) to i64), i1 false) %2 = bitcast [81 x i8]* %s to i8* - call void @foo_baz(%foo* %fb, i8* %2) + call void @foo__baz(%foo* %fb, i8* %2) %3 = bitcast [81 x i8]* %s to i8* - call void @foo_baz(%foo* %fb, i8* %3) + call void @foo__baz(%foo* %fb, i8* %3) ret void } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_action_from_fb_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_action_from_fb_called_in_program.snap index 4577ec2a96..15f2368dca 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_action_from_fb_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_action_from_fb_called_in_program.snap @@ -15,7 +15,7 @@ source_filename = "" define void @bar(%bar* %0) { entry: %fb_inst = getelementptr inbounds %bar, %bar* %0, i32 0, i32 0 - call void @fb_foo(%fb* %fb_inst) + call void @fb__foo(%fb* %fb_inst) ret void } @@ -25,7 +25,7 @@ entry: ret void } -define void @fb_foo(%fb* %0) { +define void @fb__foo(%fb* %0) { entry: %x = getelementptr inbounds %fb, %fb* %0, i32 0, i32 0 store i32 2, i32* %x, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_foreign_action_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_foreign_action_called_in_program.snap index 2dc60feae3..5f2ef3954b 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_foreign_action_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_foreign_action_called_in_program.snap @@ -14,7 +14,7 @@ source_filename = "" define void @bar(%bar* %0) { entry: - call void @prg_foo(%prg* @prg_instance) + call void @prg__foo(%prg* @prg_instance) ret void } @@ -24,7 +24,7 @@ entry: ret void } -define void @prg_foo(%prg* %0) { +define void @prg__foo(%prg* %0) { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i32 2, i32* %x, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_local_action_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_local_action_called_in_program.snap index c4e5486ba8..1ae762f39e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_local_action_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_local_action_called_in_program.snap @@ -13,11 +13,11 @@ source_filename = "" define void @prg(%prg* %0) { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 - call void @prg_foo(%prg* @prg_instance) + call void @prg__foo(%prg* @prg_instance) ret void } -define void @prg_foo(%prg* %0) { +define void @prg__foo(%prg* %0) { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i32 2, i32* %x, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__var_in_out_params_can_be_out_of_order.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__var_in_out_params_can_be_out_of_order.snap index 78c37314a1..1b188c51cc 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__var_in_out_params_can_be_out_of_order.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__var_in_out_params_can_be_out_of_order.snap @@ -29,10 +29,10 @@ entry: call void @fb_t(%fb_t* %fb) %load_out2 = load i8, i8* %out2, align 1 %load_out1 = load i8, i8* %out1, align 1 - call void @fb_t_foo(%fb_t* %fb) + call void @fb_t__foo(%fb_t* %fb) %load_out21 = load i8, i8* %out2, align 1 %load_out12 = load i8, i8* %out1, align 1 - call void @fb_t_foo(%fb_t* %fb) + call void @fb_t__foo(%fb_t* %fb) ret void } @@ -46,7 +46,7 @@ entry: ret void } -define void @fb_t_foo(%fb_t* %0) { +define void @fb_t__foo(%fb_t* %0) { entry: %myVar = getelementptr inbounds %fb_t, %fb_t* %0, i32 0, i32 0 %myInput = getelementptr inbounds %fb_t, %fb_t* %0, i32 0, i32 1 diff --git a/src/index.rs b/src/index.rs index a29d51c14f..f7c591d33f 100644 --- a/src/index.rs +++ b/src/index.rs @@ -434,7 +434,7 @@ impl ImplementationIndexEntry { pub fn get_call_name_for_ir(&self) -> String { match self.implementation_type { - ImplementationType::Method | ImplementationType::Action => self.call_name.replace(".", "_"), + ImplementationType::Method | ImplementationType::Action => self.call_name.replace(".", "__"), _ => self.call_name.clone(), } } diff --git a/src/tests/adr/initializer_functions_adr.rs b/src/tests/adr/initializer_functions_adr.rs index 0dc08c1cc2..9dead18eeb 100644 --- a/src/tests/adr/initializer_functions_adr.rs +++ b/src/tests/adr/initializer_functions_adr.rs @@ -813,7 +813,7 @@ fn initializing_method_variables() { ret void } - define void @foo_bar(%foo* %0) { + define void @foo__bar(%foo* %0) { entry: %x = alloca i32, align 4 %px = alloca i32*, align 8 @@ -886,7 +886,7 @@ fn initializing_method_variables() { ret void } - define void @foo_bar(%foo* %0) { + define void @foo__bar(%foo* %0) { entry: %x = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %px = alloca i32*, align 8 @@ -895,7 +895,7 @@ fn initializing_method_variables() { ret void } - define void @foo_baz(%foo* %0) { + define void @foo__baz(%foo* %0) { entry: %x = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %px = alloca i32*, align 8 @@ -956,7 +956,7 @@ fn initializing_method_variables() { ret void } - define void @foo_bar(%foo* %0) { + define void @foo__bar(%foo* %0) { entry: %x = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %x1 = alloca i32, align 4 diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__actions_debug.snap b/tests/integration/snapshots/tests__integration__cfc__ir__actions_debug.snap index 3fbb9d5812..cf8da06223 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__actions_debug.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__actions_debug.snap @@ -14,12 +14,12 @@ entry: %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1 store i32 0, i32* %a, align 4, !dbg !18 - call void @main_newAction(%main* %0), !dbg !17 - call void @main_newAction2(%main* %0), !dbg !19 + call void @main__newAction(%main* %0), !dbg !17 + call void @main__newAction2(%main* %0), !dbg !19 ret void, !dbg !20 } -define void @main_newAction(%main* %0) !dbg !21 { +define void @main__newAction(%main* %0) !dbg !21 { entry: call void @llvm.dbg.declare(metadata %main* %0, metadata !22, metadata !DIExpression()), !dbg !23 %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0 @@ -30,7 +30,7 @@ entry: ret void, !dbg !24 } -define void @main_newAction2(%main* %0) !dbg !25 { +define void @main__newAction2(%main* %0) !dbg !25 { entry: call void @llvm.dbg.declare(metadata %main* %0, metadata !26, metadata !DIExpression()), !dbg !27 %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0 diff --git a/tests/lit/multi/extern_C_fb_init/foo.c b/tests/lit/multi/extern_C_fb_init/foo.c index 47f2db666e..b2d7e5febf 100644 --- a/tests/lit/multi/extern_C_fb_init/foo.c +++ b/tests/lit/multi/extern_C_fb_init/foo.c @@ -7,7 +7,7 @@ typedef struct { myFunctionBlock __myFunctionBlock__init = { 0 }; -void myFunctionBlock_FB_INIT(myFunctionBlock* fb_instance) { +void myFunctionBlock__FB_INIT(myFunctionBlock* fb_instance) { fb_instance->a = 1; fb_instance->b = 2; printf("myFunctionBlock initialized with a = %d, b = %d\n", fb_instance->a, fb_instance->b); From a7bfcbfb5602f18731e44ec8917c2879fd56e394 Mon Sep 17 00:00:00 2001 From: Michael Haselberger Date: Mon, 28 Apr 2025 07:13:50 +0200 Subject: [PATCH 9/9] add test for user_init with stack-variables --- .../complex_initializers.rs | 127 +++++++++++++++--- .../init/user_init_for_stack_variable.st | 13 ++ 2 files changed, 124 insertions(+), 16 deletions(-) create mode 100644 tests/lit/single/init/user_init_for_stack_variable.st diff --git a/src/codegen/tests/initialization_test/complex_initializers.rs b/src/codegen/tests/initialization_test/complex_initializers.rs index 1baef9d33d..136532c900 100644 --- a/src/codegen/tests/initialization_test/complex_initializers.rs +++ b/src/codegen/tests/initialization_test/complex_initializers.rs @@ -148,18 +148,10 @@ fn init_functions_generated_for_programs() { ret void } - define void @__user_init_PLC_PRG(%PLC_PRG* %0) { - entry: - %self = alloca %PLC_PRG*, align 8 - store %PLC_PRG* %0, %PLC_PRG** %self, align 8 - ret void - } - define void @__init___Test() { entry: call void @__init_plc_prg(%PLC_PRG* @PLC_PRG_instance) call void @__user_init_PLC_PRG(%PLC_PRG* @PLC_PRG_instance) - call void @__user_init_PLC_PRG(%PLC_PRG* @PLC_PRG_instance) ret void } "#); @@ -567,7 +559,6 @@ fn nested_initializer_pous() { } #[test] -#[ignore = "initializing references in same POU not yet supported"] fn local_address() { let res = generate_to_string( "Test", @@ -584,12 +575,50 @@ fn local_address() { ) .unwrap(); - insta::assert_snapshot!(res, @r###""###); + insta::assert_snapshot!(res, @r#" + ; ModuleID = '' + source_filename = "" + + %foo = type { i16, i16* } + + @__foo__init = constant %foo zeroinitializer + @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @__init___Test, i8* null }] + + define void @foo(%foo* %0) { + entry: + %i = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 + %pi = getelementptr inbounds %foo, %foo* %0, i32 0, i32 1 + ret void + } + + define void @__init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + %deref = load %foo*, %foo** %self, align 8 + %pi = getelementptr inbounds %foo, %foo* %deref, i32 0, i32 1 + %deref1 = load %foo*, %foo** %self, align 8 + %i = getelementptr inbounds %foo, %foo* %deref1, i32 0, i32 0 + store i16* %i, i16** %pi, align 8 + ret void + } + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } + + define void @__init___Test() { + entry: + ret void + } + "#); } #[test] -#[ignore = "initializing references in same POU not yet supported"] -fn tmpo() { +fn user_init_called_for_variables_on_stack() { let result = generate_to_string( "Test", vec![SourceCode::from( @@ -599,17 +628,83 @@ fn tmpo() { i : INT; pi: REF_TO INT; END_VAR + METHOD FB_INIT + pi := ADR(i); + END_METHOD END_FUNCTION_BLOCK - ACTION foo.init - pi := REF(i); - END_ACTION + FUNCTION main + VAR + fb: foo; + END_VAR + fb(); + END_FUNCTION "#, )], ) .unwrap(); - insta::assert_snapshot!(result, @r###""###); + insta::assert_snapshot!(result, @r#" + ; ModuleID = '' + source_filename = "" + + %foo = type { i16, i16* } + + @__foo__init = constant %foo zeroinitializer + @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @__init___Test, i8* null }] + + define void @foo(%foo* %0) { + entry: + %i = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 + %pi = getelementptr inbounds %foo, %foo* %0, i32 0, i32 1 + ret void + } + + define void @foo__FB_INIT(%foo* %0) { + entry: + %i = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 + %pi = getelementptr inbounds %foo, %foo* %0, i32 0, i32 1 + store i16* %i, i16** %pi, align 8 + ret void + } + + define void @main() { + entry: + %fb = alloca %foo, align 8 + %0 = bitcast %foo* %fb to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 bitcast (%foo* @__foo__init to i8*), i64 ptrtoint (%foo* getelementptr (%foo, %foo* null, i32 1) to i64), i1 false) + call void @__init_foo(%foo* %fb) + call void @__user_init_foo(%foo* %fb) + call void @foo(%foo* %fb) + ret void + } + + ; Function Attrs: argmemonly nofree nounwind willreturn + declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0 + + define void @__init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + ret void + } + + define void @__user_init_foo(%foo* %0) { + entry: + %self = alloca %foo*, align 8 + store %foo* %0, %foo** %self, align 8 + %deref = load %foo*, %foo** %self, align 8 + call void @foo__FB_INIT(%foo* %deref) + ret void + } + + define void @__init___Test() { + entry: + ret void + } + + attributes #0 = { argmemonly nofree nounwind willreturn } + "#); } #[test] diff --git a/tests/lit/single/init/user_init_for_stack_variable.st b/tests/lit/single/init/user_init_for_stack_variable.st new file mode 100644 index 0000000000..24009e7fd5 --- /dev/null +++ b/tests/lit/single/init/user_init_for_stack_variable.st @@ -0,0 +1,13 @@ +// RUN: (%COMPILE %s && %RUN) | %CHECK %s +FUNCTION_BLOCK foo + METHOD FB_INIT + printf('FB_INIT called$N'); + END_METHOD +END_FUNCTION_BLOCK + +FUNCTION main +VAR + fb: foo; +END_VAR + // CHECK: FB_INIT called +END_FUNCTION \ No newline at end of file