From 8d5f1d5663b905398fde87c43aa915f39a94feba Mon Sep 17 00:00:00 2001 From: Wodann Date: Mon, 23 Mar 2020 11:50:38 +0100 Subject: [PATCH] test(code_gen): add snapshot tests for the group_ir function --- ... => test__binary_expressions_file_ir.snap} | 0 .../test__binary_expressions_group_ir.snap | 7 +++ ...est__conditional_return_expr_file_ir.snap} | 0 ...est__conditional_return_expr_group_ir.snap | 7 +++ ...p => test__equality_operands_file_ir.snap} | 0 .../test__equality_operands_group_ir.snap | 7 +++ ...n_fn.snap => test__extern_fn_file_ir.snap} | 0 .../snapshots/test__extern_fn_group_ir.snap | 11 +++++ ...acci.snap => test__fibonacci_file_ir.snap} | 0 .../snapshots/test__fibonacci_group_ir.snap | 13 +++++ ...snap => test__fibonacci_loop_file_ir.snap} | 0 .../test__fibonacci_loop_group_ir.snap | 7 +++ ...sh.snap => test__field_crash_file_ir.snap} | 0 .../snapshots/test__field_crash_group_ir.snap | 32 ++++++++++++ ...xpr.snap => test__field_expr_file_ir.snap} | 0 .../snapshots/test__field_expr_group_ir.snap | 48 ++++++++++++++++++ ... => test__function_arguments_file_ir.snap} | 0 .../test__function_arguments_group_ir.snap | 7 +++ ...snap => test__function_calls_file_ir.snap} | 0 .../test__function_calls_group_ir.snap | 15 ++++++ ...ction.snap => test__function_file_ir.snap} | 0 .../snapshots/test__function_group_ir.snap | 7 +++ ...ruct.snap => test__gc_struct_file_ir.snap} | 0 .../snapshots/test__gc_struct_group_ir.snap | 33 +++++++++++++ ...t.snap => test__if_statement_file_ir.snap} | 0 .../test__if_statement_group_ir.snap | 7 +++ ... => test__invalid_binary_ops_file_ir.snap} | 0 .../test__invalid_binary_ops_group_ir.snap | 6 +++ ....snap => test__let_statement_file_ir.snap} | 0 .../test__let_statement_group_ir.snap | 7 +++ ...nap => test__loop_break_expr_file_ir.snap} | 0 .../test__loop_break_expr_group_ir.snap | 7 +++ ...expr.snap => test__loop_expr_file_ir.snap} | 0 .../snapshots/test__loop_expr_group_ir.snap | 7 +++ ...ever_conditional_return_expr_file_ir.snap} | 0 ...ever_conditional_return_expr_group_ir.snap | 7 +++ ...nap => test__primitive_types_file_ir.snap} | 0 .../test__primitive_types_group_ir.snap | 7 +++ ...pr.snap => test__return_expr_file_ir.snap} | 0 .../snapshots/test__return_expr_group_ir.snap | 7 +++ ...pe.snap => test__return_type_file_ir.snap} | 0 .../snapshots/test__return_type_group_ir.snap | 7 +++ ...wing.snap => test__shadowing_file_ir.snap} | 0 .../snapshots/test__shadowing_group_ir.snap | 7 +++ ...st.snap => test__struct_test_file_ir.snap} | 0 .../snapshots/test__struct_test_group_ir.snap | 49 +++++++++++++++++++ ...e.snap => test__true_is_true_file_ir.snap} | 0 .../test__true_is_true_group_ir.snap | 7 +++ ...ap => test__update_operators_file_ir.snap} | 0 .../test__update_operators_group_ir.snap | 7 +++ ...ap => test__update_parameter_file_ir.snap} | 0 .../test__update_parameter_group_ir.snap | 7 +++ ...rn.snap => test__void_return_file_ir.snap} | 0 .../snapshots/test__void_return_group_ir.snap | 13 +++++ ...xpr.snap => test__while_expr_file_ir.snap} | 0 .../snapshots/test__while_expr_group_ir.snap | 7 +++ crates/mun_codegen/src/test.rs | 30 +++++++++--- 57 files changed, 377 insertions(+), 6 deletions(-) rename crates/mun_codegen/src/snapshots/{test__binary_expressions.snap => test__binary_expressions_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__binary_expressions_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__conditional_return_expr.snap => test__conditional_return_expr_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__conditional_return_expr_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__equality_operands.snap => test__equality_operands_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__equality_operands_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__extern_fn.snap => test__extern_fn_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__extern_fn_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__fibonacci.snap => test__fibonacci_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__fibonacci_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__fibonacci_loop.snap => test__fibonacci_loop_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__fibonacci_loop_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__field_crash.snap => test__field_crash_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__field_crash_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__field_expr.snap => test__field_expr_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__field_expr_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__function_arguments.snap => test__function_arguments_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__function_arguments_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__function_calls.snap => test__function_calls_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__function_calls_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__function.snap => test__function_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__function_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__gc_struct.snap => test__gc_struct_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__gc_struct_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__if_statement.snap => test__if_statement_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__if_statement_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__invalid_binary_ops.snap => test__invalid_binary_ops_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__invalid_binary_ops_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__let_statement.snap => test__let_statement_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__let_statement_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__loop_break_expr.snap => test__loop_break_expr_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__loop_break_expr_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__loop_expr.snap => test__loop_expr_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__loop_expr_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__never_conditional_return_expr.snap => test__never_conditional_return_expr_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__never_conditional_return_expr_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__primitive_types.snap => test__primitive_types_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__primitive_types_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__return_expr.snap => test__return_expr_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__return_expr_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__return_type.snap => test__return_type_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__return_type_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__shadowing.snap => test__shadowing_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__shadowing_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__struct_test.snap => test__struct_test_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__struct_test_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__true_is_true.snap => test__true_is_true_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__true_is_true_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__update_operators.snap => test__update_operators_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__update_operators_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__update_parameter.snap => test__update_parameter_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__update_parameter_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__void_return.snap => test__void_return_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__void_return_group_ir.snap rename crates/mun_codegen/src/snapshots/{test__while_expr.snap => test__while_expr_file_ir.snap} (100%) create mode 100644 crates/mun_codegen/src/snapshots/test__while_expr_group_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__binary_expressions.snap b/crates/mun_codegen/src/snapshots/test__binary_expressions_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__binary_expressions.snap rename to crates/mun_codegen/src/snapshots/test__binary_expressions_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__binary_expressions_group_ir.snap b/crates/mun_codegen/src/snapshots/test__binary_expressions_group_ir.snap new file mode 100644 index 000000000..cc5524683 --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__binary_expressions_group_ir.snap @@ -0,0 +1,7 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn add(a:int, b:int):int {\n a+b\n}\n\nfn subtract(a:int, b:int):int {\n a-b\n}\n\nfn multiply(a:int, b:int):int {\n a*b\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + diff --git a/crates/mun_codegen/src/snapshots/test__conditional_return_expr.snap b/crates/mun_codegen/src/snapshots/test__conditional_return_expr_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__conditional_return_expr.snap rename to crates/mun_codegen/src/snapshots/test__conditional_return_expr_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__conditional_return_expr_group_ir.snap b/crates/mun_codegen/src/snapshots/test__conditional_return_expr_group_ir.snap new file mode 100644 index 000000000..5de1e82ea --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__conditional_return_expr_group_ir.snap @@ -0,0 +1,7 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn main(a:int):int {\n if a > 4 {\n return a;\n }\n a - 1\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + diff --git a/crates/mun_codegen/src/snapshots/test__equality_operands.snap b/crates/mun_codegen/src/snapshots/test__equality_operands_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__equality_operands.snap rename to crates/mun_codegen/src/snapshots/test__equality_operands_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__equality_operands_group_ir.snap b/crates/mun_codegen/src/snapshots/test__equality_operands_group_ir.snap new file mode 100644 index 000000000..9e8674043 --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__equality_operands_group_ir.snap @@ -0,0 +1,7 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn equals(a:int, b:int):bool { a == b }\nfn not_equals(a:int, b:int):bool { a != b }\nfn less(a:int, b:int):bool { a < b }\nfn less_equal(a:int, b:int):bool { a <= b }\nfn greater(a:int, b:int):bool { a > b }\nfn greater_equal(a:int, b:int):bool { a >= b }\nfn equalsf(a:float, b:float):bool { a == b }\nfn not_equalsf(a:float, b:float):bool { a != b }\nfn lessf(a:float, b:float):bool { a < b }\nfn less_equalf(a:float, b:float):bool { a <= b }\nfn greaterf(a:float, b:float):bool { a > b }\nfn greater_equalf(a:float, b:float):bool { a >= b }" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + diff --git a/crates/mun_codegen/src/snapshots/test__extern_fn.snap b/crates/mun_codegen/src/snapshots/test__extern_fn_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__extern_fn.snap rename to crates/mun_codegen/src/snapshots/test__extern_fn_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__extern_fn_group_ir.snap b/crates/mun_codegen/src/snapshots/test__extern_fn_group_ir.snap new file mode 100644 index 000000000..38abd3eef --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__extern_fn_group_ir.snap @@ -0,0 +1,11 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "extern fn add(a:int, b:int): int;\nfn main() {\n add(3,4);\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + +%DispatchTable = type { i64 (i64, i64)* } + +@dispatchTable = global %DispatchTable zeroinitializer + diff --git a/crates/mun_codegen/src/snapshots/test__fibonacci.snap b/crates/mun_codegen/src/snapshots/test__fibonacci_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__fibonacci.snap rename to crates/mun_codegen/src/snapshots/test__fibonacci_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__fibonacci_group_ir.snap b/crates/mun_codegen/src/snapshots/test__fibonacci_group_ir.snap new file mode 100644 index 000000000..bb17c0fc0 --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__fibonacci_group_ir.snap @@ -0,0 +1,13 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn fibonacci(n:int):int {\n if n <= 1 {\n n\n } else {\n fibonacci(n-1) + fibonacci(n-2)\n }\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + +%DispatchTable = type { i64 (i64)* } + +@dispatchTable = global %DispatchTable { i64 (i64)* @fibonacci } + +declare i64 @fibonacci(i64) + diff --git a/crates/mun_codegen/src/snapshots/test__fibonacci_loop.snap b/crates/mun_codegen/src/snapshots/test__fibonacci_loop_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__fibonacci_loop.snap rename to crates/mun_codegen/src/snapshots/test__fibonacci_loop_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__fibonacci_loop_group_ir.snap b/crates/mun_codegen/src/snapshots/test__fibonacci_loop_group_ir.snap new file mode 100644 index 000000000..9e313c346 --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__fibonacci_loop_group_ir.snap @@ -0,0 +1,7 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn fibonacci(n:int):int {\n let a = 0;\n let b = 1;\n let i = 1;\n loop {\n if i > n {\n return a\n }\n let sum = a + b;\n a = b;\n b = sum;\n i += 1;\n }\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + diff --git a/crates/mun_codegen/src/snapshots/test__field_crash.snap b/crates/mun_codegen/src/snapshots/test__field_crash_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__field_crash.snap rename to crates/mun_codegen/src/snapshots/test__field_crash_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__field_crash_group_ir.snap b/crates/mun_codegen/src/snapshots/test__field_crash_group_ir.snap new file mode 100644 index 000000000..df07cfe1d --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__field_crash_group_ir.snap @@ -0,0 +1,32 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "struct(gc) Foo { a: int };\n\nfn main(c:int):int {\n let b = Foo { a: c + 5 }\n b.a\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + +%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunStructInfo = type { i8 addrspace(4)*, i8 addrspace(4)* addrspace(4)*, %struct.MunTypeInfo addrspace(4)* addrspace(4)*, i16 addrspace(4)*, i16, i8 } +%DispatchTable = type { i8* addrspace(4)* (i8 addrspace(4)*, i8*)*, i8* addrspace(4)* (i8 addrspace(4)*, i8*)* } + +@"type_info::::name" = private unnamed_addr constant [4 x i8] c"Foo\00" +@"struct_info::::name" = private unnamed_addr constant [4 x i8] c"Foo\00" +@"struct_info::::field_names" = private unnamed_addr constant [2 x i8] c"a\00" +@0 = private unnamed_addr constant [1 x i8 addrspace(4)*] [i8 addrspace(4)* @"struct_info::::field_names"] +@"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i64\00" +@"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"G\13;t\97j8\18\D7M\83`\1D\C8\19%", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } +@"struct_info::::field_types" = private unnamed_addr constant [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@"struct_info::::field_offsets" = private unnamed_addr constant [1 x i16] zeroinitializer +@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"\13V\C6}z\D1c\8D\81k\FB\82-\D2\C2]", [4 x i8]* @"type_info::::name", i32 64, i8 8, i8 1 }, %struct.MunStructInfo { [4 x i8]* @"struct_info::::name", [1 x i8 addrspace(4)*]* @0, [1 x %struct.MunTypeInfo addrspace(4)*]* @"struct_info::::field_types", [1 x i16]* @"struct_info::::field_offsets", i16 1, i8 0 } } +@"type_info::<*const TypeInfo>::name" = private unnamed_addr constant [16 x i8] c"*const TypeInfo\00" +@"type_info::<*const TypeInfo>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"=\A1-\1F\C2\A7\88`d\90\F4\B5\BEE}x", [16 x i8]* @"type_info::<*const TypeInfo>::name", i32 64, i8 8, i8 0 } +@"type_info::<*const *mut core::void>::name" = private unnamed_addr constant [23 x i8] c"*const *mut core::void\00" +@"type_info::<*const *mut core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\C5fO\BD\84\DF\06\BFd+\B1\9Abv\CE\00", [23 x i8]* @"type_info::<*const *mut core::void>::name", i32 64, i8 8, i8 0 } +@"type_info::<*const core::void>::name" = private unnamed_addr constant [18 x i8] c"*const core::void\00" +@"type_info::<*const core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\EF\D3\E0ac~\5C\D4\EF\AE\B1}\CA\BE\DA\16", [18 x i8]* @"type_info::<*const core::void>::name", i32 64, i8 8, i8 0 } +@"type_info::<*mut core::void>::name" = private unnamed_addr constant [16 x i8] c"*mut core::void\00" +@"type_info::<*mut core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\F0Y\22\FC\95\9E\7F\CE\08T\B1\A2\CD\A7\FAz", [16 x i8]* @"type_info::<*mut core::void>::name", i32 64, i8 8, i8 0 } +@global_type_table = global [6 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const TypeInfo>", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const *mut core::void>", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const core::void>", %struct.MunTypeInfo addrspace(4)* @"type_info::<*mut core::void>"] +@dispatchTable = global %DispatchTable zeroinitializer +@allocatorHandle = unnamed_addr global i8* null + diff --git a/crates/mun_codegen/src/snapshots/test__field_expr.snap b/crates/mun_codegen/src/snapshots/test__field_expr_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__field_expr.snap rename to crates/mun_codegen/src/snapshots/test__field_expr_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__field_expr_group_ir.snap b/crates/mun_codegen/src/snapshots/test__field_expr_group_ir.snap new file mode 100644 index 000000000..72d20f4bf --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__field_expr_group_ir.snap @@ -0,0 +1,48 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "struct(value) Bar(float, Foo);\nstruct(value) Foo { a: int };\n\nfn bar_0(bar: Bar): float {\n bar.0\n}\n\nfn bar_1(bar: Bar): Foo {\n bar.1\n}\n\nfn bar_1_a(bar: Bar): int {\n bar.1.a\n}\n\nfn foo_a(foo: Foo): int {\n foo.a\n}\n\nfn bar_1_foo_a(bar: Bar): int {\n foo_a(bar_1(bar))\n}\n\nfn main(): int {\n let a: Foo = Foo { a: 5 };\n let b: Bar = Bar(1.23, a);\n let aa_lhs = a.a + 2;\n let aa_rhs = 2 + a.a;\n aa_lhs + aa_rhs\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + +%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunStructInfo = type { i8 addrspace(4)*, i8 addrspace(4)* addrspace(4)*, %struct.MunTypeInfo addrspace(4)* addrspace(4)*, i16 addrspace(4)*, i16, i8 } +%DispatchTable = type { i8* addrspace(4)* (i8 addrspace(4)*, i8*)*, i8* addrspace(4)* (i8 addrspace(4)*, i8*)*, i64 (%Foo)*, %Foo (%Bar)* } +%Foo = type { i64 } +%Bar = type { double, %Foo } + +@"type_info::::name" = private unnamed_addr constant [4 x i8] c"Foo\00" +@"struct_info::::name" = private unnamed_addr constant [4 x i8] c"Foo\00" +@"struct_info::::field_names" = private unnamed_addr constant [2 x i8] c"a\00" +@0 = private unnamed_addr constant [1 x i8 addrspace(4)*] [i8 addrspace(4)* @"struct_info::::field_names"] +@"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i64\00" +@"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"G\13;t\97j8\18\D7M\83`\1D\C8\19%", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } +@"struct_info::::field_types" = private unnamed_addr constant [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@"struct_info::::field_offsets" = private unnamed_addr constant [1 x i16] zeroinitializer +@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"\13V\C6}z\D1c\8D\81k\FB\82-\D2\C2]", [4 x i8]* @"type_info::::name", i32 64, i8 8, i8 1 }, %struct.MunStructInfo { [4 x i8]* @"struct_info::::name", [1 x i8 addrspace(4)*]* @0, [1 x %struct.MunTypeInfo addrspace(4)*]* @"struct_info::::field_types", [1 x i16]* @"struct_info::::field_offsets", i16 1, i8 1 } } +@"type_info::<*const TypeInfo>::name" = private unnamed_addr constant [16 x i8] c"*const TypeInfo\00" +@"type_info::<*const TypeInfo>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"=\A1-\1F\C2\A7\88`d\90\F4\B5\BEE}x", [16 x i8]* @"type_info::<*const TypeInfo>::name", i32 64, i8 8, i8 0 } +@"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::f64\00" +@"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"`\DBF\9C?YJ%G\AD4\9F\D5\92%A", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } +@"type_info::<*const *mut core::void>::name" = private unnamed_addr constant [23 x i8] c"*const *mut core::void\00" +@"type_info::<*const *mut core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\C5fO\BD\84\DF\06\BFd+\B1\9Abv\CE\00", [23 x i8]* @"type_info::<*const *mut core::void>::name", i32 64, i8 8, i8 0 } +@"type_info::::name" = private unnamed_addr constant [4 x i8] c"Bar\00" +@"struct_info::::name" = private unnamed_addr constant [4 x i8] c"Bar\00" +@"struct_info::::field_names" = private unnamed_addr constant [2 x i8] c"0\00" +@"struct_info::::field_names.1" = private unnamed_addr constant [2 x i8] c"1\00" +@1 = private unnamed_addr constant [2 x i8 addrspace(4)*] [i8 addrspace(4)* @"struct_info::::field_names", i8 addrspace(4)* @"struct_info::::field_names.1"] +@"struct_info::::field_types" = private unnamed_addr constant [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@"struct_info::::field_offsets" = private unnamed_addr constant [2 x i16] [i16 0, i16 8] +@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"\DD\C3_\88\FAq\B6\EF\14*\E6\1F56FS", [4 x i8]* @"type_info::::name", i32 128, i8 8, i8 1 }, %struct.MunStructInfo { [4 x i8]* @"struct_info::::name", [2 x i8 addrspace(4)*]* @1, [2 x %struct.MunTypeInfo addrspace(4)*]* @"struct_info::::field_types", [2 x i16]* @"struct_info::::field_offsets", i16 2, i8 1 } } +@"type_info::<*const core::void>::name" = private unnamed_addr constant [18 x i8] c"*const core::void\00" +@"type_info::<*const core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\EF\D3\E0ac~\5C\D4\EF\AE\B1}\CA\BE\DA\16", [18 x i8]* @"type_info::<*const core::void>::name", i32 64, i8 8, i8 0 } +@"type_info::<*mut core::void>::name" = private unnamed_addr constant [16 x i8] c"*mut core::void\00" +@"type_info::<*mut core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\F0Y\22\FC\95\9E\7F\CE\08T\B1\A2\CD\A7\FAz", [16 x i8]* @"type_info::<*mut core::void>::name", i32 64, i8 8, i8 0 } +@global_type_table = global [8 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const TypeInfo>", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const *mut core::void>", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const core::void>", %struct.MunTypeInfo addrspace(4)* @"type_info::<*mut core::void>"] +@dispatchTable = global %DispatchTable { i8* addrspace(4)* (i8 addrspace(4)*, i8*)* null, i8* addrspace(4)* (i8 addrspace(4)*, i8*)* null, i64 (%Foo)* @foo_a, %Foo (%Bar)* @bar_1 } +@allocatorHandle = unnamed_addr global i8* null + +declare i64 @foo_a(%Foo) + +declare %Foo @bar_1(%Bar) + diff --git a/crates/mun_codegen/src/snapshots/test__function_arguments.snap b/crates/mun_codegen/src/snapshots/test__function_arguments_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__function_arguments.snap rename to crates/mun_codegen/src/snapshots/test__function_arguments_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__function_arguments_group_ir.snap b/crates/mun_codegen/src/snapshots/test__function_arguments_group_ir.snap new file mode 100644 index 000000000..52d4a44eb --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__function_arguments_group_ir.snap @@ -0,0 +1,7 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn main(a:int):int {\n a\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + diff --git a/crates/mun_codegen/src/snapshots/test__function_calls.snap b/crates/mun_codegen/src/snapshots/test__function_calls_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__function_calls.snap rename to crates/mun_codegen/src/snapshots/test__function_calls_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__function_calls_group_ir.snap b/crates/mun_codegen/src/snapshots/test__function_calls_group_ir.snap new file mode 100644 index 000000000..a2e9dc106 --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__function_calls_group_ir.snap @@ -0,0 +1,15 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn add_impl(a:int, b:int):int {\n a+b\n}\n\nfn add(a:int, b:int):int {\n add_impl(a,b)\n}\n\nfn test():int {\n add(4,5)\n add_impl(4,5)\n add(4,5)\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + +%DispatchTable = type { i64 (i64, i64)*, i64 (i64, i64)* } + +@dispatchTable = global %DispatchTable { i64 (i64, i64)* @add_impl, i64 (i64, i64)* @add } + +declare i64 @add_impl(i64, i64) + +declare i64 @add(i64, i64) + diff --git a/crates/mun_codegen/src/snapshots/test__function.snap b/crates/mun_codegen/src/snapshots/test__function_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__function.snap rename to crates/mun_codegen/src/snapshots/test__function_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__function_group_ir.snap b/crates/mun_codegen/src/snapshots/test__function_group_ir.snap new file mode 100644 index 000000000..5588e11fd --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__function_group_ir.snap @@ -0,0 +1,7 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn main() {\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + diff --git a/crates/mun_codegen/src/snapshots/test__gc_struct.snap b/crates/mun_codegen/src/snapshots/test__gc_struct_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__gc_struct.snap rename to crates/mun_codegen/src/snapshots/test__gc_struct_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__gc_struct_group_ir.snap b/crates/mun_codegen/src/snapshots/test__gc_struct_group_ir.snap new file mode 100644 index 000000000..d809106ab --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__gc_struct_group_ir.snap @@ -0,0 +1,33 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "struct(gc) Foo { a: int, b: int };\n\nfn foo() {\n let a = Foo { a: 3, b: 4 };\n a.b += 3;\n let b = a;\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + +%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunStructInfo = type { i8 addrspace(4)*, i8 addrspace(4)* addrspace(4)*, %struct.MunTypeInfo addrspace(4)* addrspace(4)*, i16 addrspace(4)*, i16, i8 } +%DispatchTable = type { i8* addrspace(4)* (i8 addrspace(4)*, i8*)*, i8* addrspace(4)* (i8 addrspace(4)*, i8*)* } + +@"type_info::::name" = private unnamed_addr constant [4 x i8] c"Foo\00" +@"struct_info::::name" = private unnamed_addr constant [4 x i8] c"Foo\00" +@"struct_info::::field_names" = private unnamed_addr constant [2 x i8] c"a\00" +@"struct_info::::field_names.1" = private unnamed_addr constant [2 x i8] c"b\00" +@0 = private unnamed_addr constant [2 x i8 addrspace(4)*] [i8 addrspace(4)* @"struct_info::::field_names", i8 addrspace(4)* @"struct_info::::field_names.1"] +@"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i64\00" +@"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"G\13;t\97j8\18\D7M\83`\1D\C8\19%", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } +@"struct_info::::field_types" = private unnamed_addr constant [2 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@"struct_info::::field_offsets" = private unnamed_addr constant [2 x i16] [i16 0, i16 8] +@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"\13V\C6}z\D1c\8D\81k\FB\82-\D2\C2]", [4 x i8]* @"type_info::::name", i32 128, i8 8, i8 1 }, %struct.MunStructInfo { [4 x i8]* @"struct_info::::name", [2 x i8 addrspace(4)*]* @0, [2 x %struct.MunTypeInfo addrspace(4)*]* @"struct_info::::field_types", [2 x i16]* @"struct_info::::field_offsets", i16 2, i8 0 } } +@"type_info::<*const TypeInfo>::name" = private unnamed_addr constant [16 x i8] c"*const TypeInfo\00" +@"type_info::<*const TypeInfo>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"=\A1-\1F\C2\A7\88`d\90\F4\B5\BEE}x", [16 x i8]* @"type_info::<*const TypeInfo>::name", i32 64, i8 8, i8 0 } +@"type_info::<*const *mut core::void>::name" = private unnamed_addr constant [23 x i8] c"*const *mut core::void\00" +@"type_info::<*const *mut core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\C5fO\BD\84\DF\06\BFd+\B1\9Abv\CE\00", [23 x i8]* @"type_info::<*const *mut core::void>::name", i32 64, i8 8, i8 0 } +@"type_info::<*const core::void>::name" = private unnamed_addr constant [18 x i8] c"*const core::void\00" +@"type_info::<*const core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\EF\D3\E0ac~\5C\D4\EF\AE\B1}\CA\BE\DA\16", [18 x i8]* @"type_info::<*const core::void>::name", i32 64, i8 8, i8 0 } +@"type_info::<*mut core::void>::name" = private unnamed_addr constant [16 x i8] c"*mut core::void\00" +@"type_info::<*mut core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\F0Y\22\FC\95\9E\7F\CE\08T\B1\A2\CD\A7\FAz", [16 x i8]* @"type_info::<*mut core::void>::name", i32 64, i8 8, i8 0 } +@global_type_table = global [6 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const TypeInfo>", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const *mut core::void>", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const core::void>", %struct.MunTypeInfo addrspace(4)* @"type_info::<*mut core::void>"] +@dispatchTable = global %DispatchTable zeroinitializer +@allocatorHandle = unnamed_addr global i8* null + diff --git a/crates/mun_codegen/src/snapshots/test__if_statement.snap b/crates/mun_codegen/src/snapshots/test__if_statement_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__if_statement.snap rename to crates/mun_codegen/src/snapshots/test__if_statement_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__if_statement_group_ir.snap b/crates/mun_codegen/src/snapshots/test__if_statement_group_ir.snap new file mode 100644 index 000000000..79b237803 --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__if_statement_group_ir.snap @@ -0,0 +1,7 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn foo(a:int):int {\n let b = if a > 3 {\n let c = if a > 4 {\n a+1\n } else {\n a+3\n }\n c\n } else {\n a-1\n }\n b\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + diff --git a/crates/mun_codegen/src/snapshots/test__invalid_binary_ops.snap b/crates/mun_codegen/src/snapshots/test__invalid_binary_ops_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__invalid_binary_ops.snap rename to crates/mun_codegen/src/snapshots/test__invalid_binary_ops_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__invalid_binary_ops_group_ir.snap b/crates/mun_codegen/src/snapshots/test__invalid_binary_ops_group_ir.snap new file mode 100644 index 000000000..fdac363fb --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__invalid_binary_ops_group_ir.snap @@ -0,0 +1,6 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn main() {\n let a = 3+3.0;\n let b = 3.0+3;\n}" +--- +error 2:13: mismatched type +error 3:15: mismatched type diff --git a/crates/mun_codegen/src/snapshots/test__let_statement.snap b/crates/mun_codegen/src/snapshots/test__let_statement_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__let_statement.snap rename to crates/mun_codegen/src/snapshots/test__let_statement_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__let_statement_group_ir.snap b/crates/mun_codegen/src/snapshots/test__let_statement_group_ir.snap new file mode 100644 index 000000000..654144d00 --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__let_statement_group_ir.snap @@ -0,0 +1,7 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn main(a:int):int {\n let b = a+1\n b\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + diff --git a/crates/mun_codegen/src/snapshots/test__loop_break_expr.snap b/crates/mun_codegen/src/snapshots/test__loop_break_expr_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__loop_break_expr.snap rename to crates/mun_codegen/src/snapshots/test__loop_break_expr_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__loop_break_expr_group_ir.snap b/crates/mun_codegen/src/snapshots/test__loop_break_expr_group_ir.snap new file mode 100644 index 000000000..06e7530ad --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__loop_break_expr_group_ir.snap @@ -0,0 +1,7 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn foo(n:int):int {\n loop {\n if n > 5 {\n break n;\n }\n if n > 10 {\n break 10;\n }\n n += 1;\n }\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + diff --git a/crates/mun_codegen/src/snapshots/test__loop_expr.snap b/crates/mun_codegen/src/snapshots/test__loop_expr_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__loop_expr.snap rename to crates/mun_codegen/src/snapshots/test__loop_expr_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__loop_expr_group_ir.snap b/crates/mun_codegen/src/snapshots/test__loop_expr_group_ir.snap new file mode 100644 index 000000000..ebae389cd --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__loop_expr_group_ir.snap @@ -0,0 +1,7 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn foo() {\n loop {}\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + diff --git a/crates/mun_codegen/src/snapshots/test__never_conditional_return_expr.snap b/crates/mun_codegen/src/snapshots/test__never_conditional_return_expr_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__never_conditional_return_expr.snap rename to crates/mun_codegen/src/snapshots/test__never_conditional_return_expr_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__never_conditional_return_expr_group_ir.snap b/crates/mun_codegen/src/snapshots/test__never_conditional_return_expr_group_ir.snap new file mode 100644 index 000000000..b629d7bfa --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__never_conditional_return_expr_group_ir.snap @@ -0,0 +1,7 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn main(a:int):int {\n if a > 4 {\n return a;\n } else {\n return a - 1;\n }\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + diff --git a/crates/mun_codegen/src/snapshots/test__primitive_types.snap b/crates/mun_codegen/src/snapshots/test__primitive_types_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__primitive_types.snap rename to crates/mun_codegen/src/snapshots/test__primitive_types_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__primitive_types_group_ir.snap b/crates/mun_codegen/src/snapshots/test__primitive_types_group_ir.snap new file mode 100644 index 000000000..abc6a41b1 --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__primitive_types_group_ir.snap @@ -0,0 +1,7 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn add(a: u8, b: u8): u8 { a+b }\n fn less(a: u16, b: u16): bool { ab }\n fn equal(a: u64, b: u64): bool { a==b }\n fn greater_equal(a: usize, b: usize): bool { a>=b }\n fn less_equal(a: uint, b: uint): bool { a<=b }\n\n fn iadd(a: i8, b: i8): i8 { a+b }\n fn iless(a: i16, b: i16): bool { ab }\n fn iequal(a: i64, b: i64): bool { a==b }\n fn igreater_equal(a: isize, b: isize): bool { a>=b }\n fn iless_equal(a: int, b: int): bool { a<=b }" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + diff --git a/crates/mun_codegen/src/snapshots/test__return_expr.snap b/crates/mun_codegen/src/snapshots/test__return_expr_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__return_expr.snap rename to crates/mun_codegen/src/snapshots/test__return_expr_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__return_expr_group_ir.snap b/crates/mun_codegen/src/snapshots/test__return_expr_group_ir.snap new file mode 100644 index 000000000..4f0975976 --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__return_expr_group_ir.snap @@ -0,0 +1,7 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn main():int {\n return 5;\n let a = 3; // Nothing regarding this statement should be in the IR\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + diff --git a/crates/mun_codegen/src/snapshots/test__return_type.snap b/crates/mun_codegen/src/snapshots/test__return_type_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__return_type.snap rename to crates/mun_codegen/src/snapshots/test__return_type_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__return_type_group_ir.snap b/crates/mun_codegen/src/snapshots/test__return_type_group_ir.snap new file mode 100644 index 000000000..3a12b5bdd --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__return_type_group_ir.snap @@ -0,0 +1,7 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn main():int {\n 0\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + diff --git a/crates/mun_codegen/src/snapshots/test__shadowing.snap b/crates/mun_codegen/src/snapshots/test__shadowing_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__shadowing.snap rename to crates/mun_codegen/src/snapshots/test__shadowing_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__shadowing_group_ir.snap b/crates/mun_codegen/src/snapshots/test__shadowing_group_ir.snap new file mode 100644 index 000000000..9d6e9002d --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__shadowing_group_ir.snap @@ -0,0 +1,7 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn foo(a:int):int {\n let a = a+1;\n {\n let a = a+2;\n }\n a+3\n}\n\nfn bar(a:int):int {\n let a = a+1;\n let a = {\n let a = a+2;\n a\n }\n a+3\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + diff --git a/crates/mun_codegen/src/snapshots/test__struct_test.snap b/crates/mun_codegen/src/snapshots/test__struct_test_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__struct_test.snap rename to crates/mun_codegen/src/snapshots/test__struct_test_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__struct_test_group_ir.snap b/crates/mun_codegen/src/snapshots/test__struct_test_group_ir.snap new file mode 100644 index 000000000..e4050515c --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__struct_test_group_ir.snap @@ -0,0 +1,49 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "struct(value) Bar(float, int, bool, Foo);\nstruct(value) Foo { a: int };\nstruct(value) Baz;\nfn foo() {\n let a: Foo = Foo { a: 5 };\n let b: Bar = Bar(1.23, a.a, true, a);\n let c: Baz = Baz;\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + +%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 } +%struct.MunStructInfo = type { i8 addrspace(4)*, i8 addrspace(4)* addrspace(4)*, %struct.MunTypeInfo addrspace(4)* addrspace(4)*, i16 addrspace(4)*, i16, i8 } +%DispatchTable = type { i8* addrspace(4)* (i8 addrspace(4)*, i8*)*, i8* addrspace(4)* (i8 addrspace(4)*, i8*)* } + +@"type_info::::name" = private unnamed_addr constant [4 x i8] c"Foo\00" +@"struct_info::::name" = private unnamed_addr constant [4 x i8] c"Foo\00" +@"struct_info::::field_names" = private unnamed_addr constant [2 x i8] c"a\00" +@0 = private unnamed_addr constant [1 x i8 addrspace(4)*] [i8 addrspace(4)* @"struct_info::::field_names"] +@"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::i64\00" +@"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"G\13;t\97j8\18\D7M\83`\1D\C8\19%", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } +@"struct_info::::field_types" = private unnamed_addr constant [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::"] +@"struct_info::::field_offsets" = private unnamed_addr constant [1 x i16] zeroinitializer +@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"\13V\C6}z\D1c\8D\81k\FB\82-\D2\C2]", [4 x i8]* @"type_info::::name", i32 64, i8 8, i8 1 }, %struct.MunStructInfo { [4 x i8]* @"struct_info::::name", [1 x i8 addrspace(4)*]* @0, [1 x %struct.MunTypeInfo addrspace(4)*]* @"struct_info::::field_types", [1 x i16]* @"struct_info::::field_offsets", i16 1, i8 1 } } +@"type_info::<*const TypeInfo>::name" = private unnamed_addr constant [16 x i8] c"*const TypeInfo\00" +@"type_info::<*const TypeInfo>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"=\A1-\1F\C2\A7\88`d\90\F4\B5\BEE}x", [16 x i8]* @"type_info::<*const TypeInfo>::name", i32 64, i8 8, i8 0 } +@"type_info::::name" = private unnamed_addr constant [10 x i8] c"core::f64\00" +@"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"`\DBF\9C?YJ%G\AD4\9F\D5\92%A", [10 x i8]* @"type_info::::name", i32 64, i8 8, i8 0 } +@"type_info::::name" = private unnamed_addr constant [11 x i8] c"core::bool\00" +@"type_info::" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"x\82\81m t7\03\CB\F8k\81-;\C9\84", [11 x i8]* @"type_info::::name", i32 1, i8 1, i8 0 } +@"type_info::<*const *mut core::void>::name" = private unnamed_addr constant [23 x i8] c"*const *mut core::void\00" +@"type_info::<*const *mut core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\C5fO\BD\84\DF\06\BFd+\B1\9Abv\CE\00", [23 x i8]* @"type_info::<*const *mut core::void>::name", i32 64, i8 8, i8 0 } +@"type_info::::name" = private unnamed_addr constant [4 x i8] c"Bar\00" +@"struct_info::::name" = private unnamed_addr constant [4 x i8] c"Bar\00" +@"struct_info::::field_names" = private unnamed_addr constant [2 x i8] c"0\00" +@"struct_info::::field_names.1" = private unnamed_addr constant [2 x i8] c"1\00" +@"struct_info::::field_names.2" = private unnamed_addr constant [2 x i8] c"2\00" +@"struct_info::::field_names.3" = private unnamed_addr constant [2 x i8] c"3\00" +@1 = private unnamed_addr constant [4 x i8 addrspace(4)*] [i8 addrspace(4)* @"struct_info::::field_names", i8 addrspace(4)* @"struct_info::::field_names.1", i8 addrspace(4)* @"struct_info::::field_names.2", i8 addrspace(4)* @"struct_info::::field_names.3"] +@"struct_info::::field_types" = private unnamed_addr constant [4 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@"struct_info::::field_offsets" = private unnamed_addr constant [4 x i16] [i16 0, i16 8, i16 16, i16 24] +@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"\DD\C3_\88\FAq\B6\EF\14*\E6\1F56FS", [4 x i8]* @"type_info::::name", i32 256, i8 8, i8 1 }, %struct.MunStructInfo { [4 x i8]* @"struct_info::::name", [4 x i8 addrspace(4)*]* @1, [4 x %struct.MunTypeInfo addrspace(4)*]* @"struct_info::::field_types", [4 x i16]* @"struct_info::::field_offsets", i16 4, i8 1 } } +@"type_info::<*const core::void>::name" = private unnamed_addr constant [18 x i8] c"*const core::void\00" +@"type_info::<*const core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\EF\D3\E0ac~\5C\D4\EF\AE\B1}\CA\BE\DA\16", [18 x i8]* @"type_info::<*const core::void>::name", i32 64, i8 8, i8 0 } +@"type_info::<*mut core::void>::name" = private unnamed_addr constant [16 x i8] c"*mut core::void\00" +@"type_info::<*mut core::void>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\F0Y\22\FC\95\9E\7F\CE\08T\B1\A2\CD\A7\FAz", [16 x i8]* @"type_info::<*mut core::void>::name", i32 64, i8 8, i8 0 } +@"type_info::::name" = private unnamed_addr constant [4 x i8] c"Baz\00" +@"struct_info::::name" = private unnamed_addr constant [4 x i8] c"Baz\00" +@"type_info::" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"\F8\DC\E6\7F,\948\82\82\ED?\A7\97\96\8A|", [4 x i8]* @"type_info::::name", i32 0, i8 1, i8 1 }, %struct.MunStructInfo { [4 x i8]* @"struct_info::::name", i8 addrspace(4)* addrspace(4)* null, %struct.MunTypeInfo addrspace(4)* addrspace(4)* null, i16 addrspace(4)* null, i16 0, i8 1 } } +@global_type_table = global [10 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const TypeInfo>", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const *mut core::void>", %struct.MunTypeInfo addrspace(4)* @"type_info::", %struct.MunTypeInfo addrspace(4)* @"type_info::<*const core::void>", %struct.MunTypeInfo addrspace(4)* @"type_info::<*mut core::void>", %struct.MunTypeInfo addrspace(4)* @"type_info::"] +@dispatchTable = global %DispatchTable zeroinitializer +@allocatorHandle = unnamed_addr global i8* null + diff --git a/crates/mun_codegen/src/snapshots/test__true_is_true.snap b/crates/mun_codegen/src/snapshots/test__true_is_true_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__true_is_true.snap rename to crates/mun_codegen/src/snapshots/test__true_is_true_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__true_is_true_group_ir.snap b/crates/mun_codegen/src/snapshots/test__true_is_true_group_ir.snap new file mode 100644 index 000000000..1849235c5 --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__true_is_true_group_ir.snap @@ -0,0 +1,7 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn test_true():bool {\n true\n}\n\nfn test_false():bool {\n false\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + diff --git a/crates/mun_codegen/src/snapshots/test__update_operators.snap b/crates/mun_codegen/src/snapshots/test__update_operators_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__update_operators.snap rename to crates/mun_codegen/src/snapshots/test__update_operators_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__update_operators_group_ir.snap b/crates/mun_codegen/src/snapshots/test__update_operators_group_ir.snap new file mode 100644 index 000000000..608dfdf02 --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__update_operators_group_ir.snap @@ -0,0 +1,7 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn add(a:int, b:int):int {\n let result = a\n result += b\n result\n}\n\nfn subtract(a:int, b:int):int {\n let result = a\n result -= b\n result\n}\n\nfn multiply(a:int, b:int):int {\n let result = a\n result *= b\n result\n}\n\nfn divide(a:int, b:int):int {\n let result = a\n result /= b\n result\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + diff --git a/crates/mun_codegen/src/snapshots/test__update_parameter.snap b/crates/mun_codegen/src/snapshots/test__update_parameter_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__update_parameter.snap rename to crates/mun_codegen/src/snapshots/test__update_parameter_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__update_parameter_group_ir.snap b/crates/mun_codegen/src/snapshots/test__update_parameter_group_ir.snap new file mode 100644 index 000000000..5aabe801e --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__update_parameter_group_ir.snap @@ -0,0 +1,7 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn add_three(a:int):int {\n a += 3;\n a\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + diff --git a/crates/mun_codegen/src/snapshots/test__void_return.snap b/crates/mun_codegen/src/snapshots/test__void_return_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__void_return.snap rename to crates/mun_codegen/src/snapshots/test__void_return_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__void_return_group_ir.snap b/crates/mun_codegen/src/snapshots/test__void_return_group_ir.snap new file mode 100644 index 000000000..ff75282c6 --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__void_return_group_ir.snap @@ -0,0 +1,13 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn bar() {\n let a = 3;\n}\nfn foo(a:int) {\n let c = bar()\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + +%DispatchTable = type { void ()* } + +@dispatchTable = global %DispatchTable { void ()* @bar } + +declare void @bar() + diff --git a/crates/mun_codegen/src/snapshots/test__while_expr.snap b/crates/mun_codegen/src/snapshots/test__while_expr_file_ir.snap similarity index 100% rename from crates/mun_codegen/src/snapshots/test__while_expr.snap rename to crates/mun_codegen/src/snapshots/test__while_expr_file_ir.snap diff --git a/crates/mun_codegen/src/snapshots/test__while_expr_group_ir.snap b/crates/mun_codegen/src/snapshots/test__while_expr_group_ir.snap new file mode 100644 index 000000000..bbc3b88f1 --- /dev/null +++ b/crates/mun_codegen/src/snapshots/test__while_expr_group_ir.snap @@ -0,0 +1,7 @@ +--- +source: crates/mun_codegen/src/test.rs +expression: "fn foo(n:int) {\n while n<3 {\n n += 1;\n };\n\n // This will be completely optimized out\n while n<4 {\n break;\n };\n}" +--- +; ModuleID = 'group_name' +source_filename = "group_name" + diff --git a/crates/mun_codegen/src/test.rs b/crates/mun_codegen/src/test.rs index 319b429de..494b3179d 100644 --- a/crates/mun_codegen/src/test.rs +++ b/crates/mun_codegen/src/test.rs @@ -509,19 +509,37 @@ fn test_snapshot_with_optimization(text: &str, opt: OptimizationLevel) { drop(sink); let messages = messages.into_inner(); - let name = if !messages.is_empty() { + let _module_builder = + ModuleBuilder::new(&mut db, file_id).expect("Failed to initialize module builder"); + + // The thread is named after the test case, so we can use it to name our snapshots. + let thread_name = std::thread::current() + .name() + .expect("The current thread does not have a name.") + .replace("test::", ""); + + let group_ir_value = if !messages.is_empty() { + messages.join("\n") + } else { + format!( + "{}", + db.group_ir(file_id) + .llvm_module + .print_to_string() + .to_string() + ) + }; + insta::assert_snapshot!(format!("{}_group_ir", thread_name), group_ir_value, &text); + let file_ir_value = if !messages.is_empty() { messages.join("\n") } else { - let _module_builder = - ModuleBuilder::new(&mut db, file_id).expect("Failed to initialize module builder"); - format!( "{}", - db.module_ir(file_id) + db.file_ir(file_id) .llvm_module .print_to_string() .to_string() ) }; - insta::assert_snapshot!(insta::_macro_support::AutoName, name, &text); + insta::assert_snapshot!(format!("{}_file_ir", thread_name), file_ir_value, &text); }