Constant evaluation support for initializing expressions. (#3624)

The constant value we associate with an initializing representation is
the object representation that the initializing expression will store to
its destination.

Also include the type in the profile of an instruction. This is now
necessary for array values, which are represented as tuple_value
instructions with array type, to avoid instructions with different types
being merged by constant canonicalization.
This commit is contained in:
Richard Smith
2024-01-19 23:28:53 +00:00
committed by GitHub
parent a1d03b1f56
commit 87ecb34f6b
54 changed files with 588 additions and 398 deletions
+77
View File
@@ -0,0 +1,77 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
fn G() {
// These should have two different constant values.
var a: [i32; 3] = (1, 2, 3);
var b: (i32, i32, i32) = (1, 2, 3);
}
// CHECK:STDOUT: --- array_vs_tuple.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: i32 = int_literal 3 [template]
// CHECK:STDOUT: %.2: type = array_type %.1, i32 [template]
// CHECK:STDOUT: %.3: type = ptr_type [i32; 3] [template]
// CHECK:STDOUT: %.4: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.5: i32 = int_literal 2 [template]
// CHECK:STDOUT: %.6: type = tuple_type (i32, i32, i32) [template]
// CHECK:STDOUT: %.7: i32 = int_literal 0 [template]
// CHECK:STDOUT: %.8: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.9: i32 = int_literal 2 [template]
// CHECK:STDOUT: %.10: [i32; 3] = tuple_value (%.4, %.5, %.1) [template]
// CHECK:STDOUT: %.11: type = tuple_type (type, type, type) [template]
// CHECK:STDOUT: %.12: type = ptr_type (i32, i32, i32) [template]
// CHECK:STDOUT: %.13: (i32, i32, i32) = tuple_value (%.4, %.5, %.1) [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace package, {.G = %G} [template]
// CHECK:STDOUT: %G: <function> = fn_decl @G [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @G() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %.loc9_16: i32 = int_literal 3 [template = constants.%.1]
// CHECK:STDOUT: %.loc9_17: type = array_type %.loc9_16, i32 [template = constants.%.2]
// CHECK:STDOUT: %a.var: ref [i32; 3] = var a
// CHECK:STDOUT: %a: ref [i32; 3] = bind_name a, %a.var
// CHECK:STDOUT: %.loc9_22: i32 = int_literal 1 [template = constants.%.4]
// CHECK:STDOUT: %.loc9_25: i32 = int_literal 2 [template = constants.%.5]
// CHECK:STDOUT: %.loc9_28: i32 = int_literal 3 [template = constants.%.1]
// CHECK:STDOUT: %.loc9_29.1: (i32, i32, i32) = tuple_literal (%.loc9_22, %.loc9_25, %.loc9_28)
// CHECK:STDOUT: %.loc9_29.2: i32 = int_literal 0 [template = constants.%.7]
// CHECK:STDOUT: %.loc9_29.3: ref i32 = array_index %a.var, %.loc9_29.2
// CHECK:STDOUT: %.loc9_29.4: init i32 = initialize_from %.loc9_22 to %.loc9_29.3 [template = constants.%.4]
// CHECK:STDOUT: %.loc9_29.5: i32 = int_literal 1 [template = constants.%.8]
// CHECK:STDOUT: %.loc9_29.6: ref i32 = array_index %a.var, %.loc9_29.5
// CHECK:STDOUT: %.loc9_29.7: init i32 = initialize_from %.loc9_25 to %.loc9_29.6 [template = constants.%.5]
// CHECK:STDOUT: %.loc9_29.8: i32 = int_literal 2 [template = constants.%.9]
// CHECK:STDOUT: %.loc9_29.9: ref i32 = array_index %a.var, %.loc9_29.8
// CHECK:STDOUT: %.loc9_29.10: init i32 = initialize_from %.loc9_28 to %.loc9_29.9 [template = constants.%.1]
// CHECK:STDOUT: %.loc9_29.11: init [i32; 3] = array_init (%.loc9_29.4, %.loc9_29.7, %.loc9_29.10) to %a.var [template = constants.%.10]
// CHECK:STDOUT: %.loc9_29.12: init [i32; 3] = converted %.loc9_29.1, %.loc9_29.11 [template = constants.%.10]
// CHECK:STDOUT: assign %a.var, %.loc9_29.12
// CHECK:STDOUT: %.loc10_24.1: (type, type, type) = tuple_literal (i32, i32, i32)
// CHECK:STDOUT: %.loc10_24.2: type = converted %.loc10_24.1, constants.%.6 [template = constants.%.6]
// CHECK:STDOUT: %b.var: ref (i32, i32, i32) = var b
// CHECK:STDOUT: %b: ref (i32, i32, i32) = bind_name b, %b.var
// CHECK:STDOUT: %.loc10_29: i32 = int_literal 1 [template = constants.%.4]
// CHECK:STDOUT: %.loc10_32: i32 = int_literal 2 [template = constants.%.5]
// CHECK:STDOUT: %.loc10_35: i32 = int_literal 3 [template = constants.%.1]
// CHECK:STDOUT: %.loc10_36.1: (i32, i32, i32) = tuple_literal (%.loc10_29, %.loc10_32, %.loc10_35)
// CHECK:STDOUT: %.loc10_36.2: ref i32 = tuple_access %b.var, element0
// CHECK:STDOUT: %.loc10_36.3: init i32 = initialize_from %.loc10_29 to %.loc10_36.2 [template = constants.%.4]
// CHECK:STDOUT: %.loc10_36.4: ref i32 = tuple_access %b.var, element1
// CHECK:STDOUT: %.loc10_36.5: init i32 = initialize_from %.loc10_32 to %.loc10_36.4 [template = constants.%.5]
// CHECK:STDOUT: %.loc10_36.6: ref i32 = tuple_access %b.var, element2
// CHECK:STDOUT: %.loc10_36.7: init i32 = initialize_from %.loc10_35 to %.loc10_36.6 [template = constants.%.1]
// CHECK:STDOUT: %.loc10_36.8: init (i32, i32, i32) = tuple_init (%.loc10_36.3, %.loc10_36.5, %.loc10_36.7) to %b.var [template = constants.%.13]
// CHECK:STDOUT: %.loc10_36.9: init (i32, i32, i32) = converted %.loc10_36.1, %.loc10_36.8 [template = constants.%.13]
// CHECK:STDOUT: assign %b.var, %.loc10_36.9
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
+15 -14
View File
@@ -16,11 +16,12 @@ var b: [i32; 3] = a;
// CHECK:STDOUT: %.4: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.5: i32 = int_literal 2 [template]
// CHECK:STDOUT: %.6: i32 = int_literal 3 [template]
// CHECK:STDOUT: %.7: type = array_type %.6, i32 [template]
// CHECK:STDOUT: %.8: type = ptr_type [i32; 3] [template]
// CHECK:STDOUT: %.9: i32 = int_literal 0 [template]
// CHECK:STDOUT: %.10: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.11: i32 = int_literal 2 [template]
// CHECK:STDOUT: %.7: (i32, i32, i32) = tuple_value (%.4, %.5, %.6) [template]
// CHECK:STDOUT: %.8: type = array_type %.6, i32 [template]
// CHECK:STDOUT: %.9: type = ptr_type [i32; 3] [template]
// CHECK:STDOUT: %.10: i32 = int_literal 0 [template]
// CHECK:STDOUT: %.11: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.12: i32 = int_literal 2 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
@@ -34,32 +35,32 @@ var b: [i32; 3] = a;
// CHECK:STDOUT: %.loc7_33: i32 = int_literal 3 [template = constants.%.6]
// CHECK:STDOUT: %.loc7_34.1: (i32, i32, i32) = tuple_literal (%.loc7_27, %.loc7_30, %.loc7_33)
// CHECK:STDOUT: %.loc7_34.2: ref i32 = tuple_access %a.var, element0
// CHECK:STDOUT: %.loc7_34.3: init i32 = initialize_from %.loc7_27 to %.loc7_34.2
// CHECK:STDOUT: %.loc7_34.3: init i32 = initialize_from %.loc7_27 to %.loc7_34.2 [template = constants.%.4]
// CHECK:STDOUT: %.loc7_34.4: ref i32 = tuple_access %a.var, element1
// CHECK:STDOUT: %.loc7_34.5: init i32 = initialize_from %.loc7_30 to %.loc7_34.4
// CHECK:STDOUT: %.loc7_34.5: init i32 = initialize_from %.loc7_30 to %.loc7_34.4 [template = constants.%.5]
// CHECK:STDOUT: %.loc7_34.6: ref i32 = tuple_access %a.var, element2
// CHECK:STDOUT: %.loc7_34.7: init i32 = initialize_from %.loc7_33 to %.loc7_34.6
// CHECK:STDOUT: %.loc7_34.8: init (i32, i32, i32) = tuple_init (%.loc7_34.3, %.loc7_34.5, %.loc7_34.7) to %a.var
// CHECK:STDOUT: %.loc7_34.9: init (i32, i32, i32) = converted %.loc7_34.1, %.loc7_34.8
// CHECK:STDOUT: %.loc7_34.7: init i32 = initialize_from %.loc7_33 to %.loc7_34.6 [template = constants.%.6]
// CHECK:STDOUT: %.loc7_34.8: init (i32, i32, i32) = tuple_init (%.loc7_34.3, %.loc7_34.5, %.loc7_34.7) to %a.var [template = constants.%.7]
// CHECK:STDOUT: %.loc7_34.9: init (i32, i32, i32) = converted %.loc7_34.1, %.loc7_34.8 [template = constants.%.7]
// CHECK:STDOUT: assign %a.var, %.loc7_34.9
// CHECK:STDOUT: %.loc8_14: i32 = int_literal 3 [template = constants.%.6]
// CHECK:STDOUT: %.loc8_15: type = array_type %.loc8_14, i32 [template = constants.%.7]
// CHECK:STDOUT: %.loc8_15: type = array_type %.loc8_14, i32 [template = constants.%.8]
// CHECK:STDOUT: %b.var: ref [i32; 3] = var b
// CHECK:STDOUT: %b: ref [i32; 3] = bind_name b, %b.var
// CHECK:STDOUT: %a.ref: ref (i32, i32, i32) = name_ref a, %a
// CHECK:STDOUT: %.loc8_19.1: ref i32 = tuple_access %a.ref, element0
// CHECK:STDOUT: %.loc8_19.2: i32 = bind_value %.loc8_19.1
// CHECK:STDOUT: %.loc8_19.3: i32 = int_literal 0 [template = constants.%.9]
// CHECK:STDOUT: %.loc8_19.3: i32 = int_literal 0 [template = constants.%.10]
// CHECK:STDOUT: %.loc8_19.4: ref i32 = array_index %b.var, %.loc8_19.3
// CHECK:STDOUT: %.loc8_19.5: init i32 = initialize_from %.loc8_19.2 to %.loc8_19.4
// CHECK:STDOUT: %.loc8_19.6: ref i32 = tuple_access %a.ref, element1
// CHECK:STDOUT: %.loc8_19.7: i32 = bind_value %.loc8_19.6
// CHECK:STDOUT: %.loc8_19.8: i32 = int_literal 1 [template = constants.%.10]
// CHECK:STDOUT: %.loc8_19.8: i32 = int_literal 1 [template = constants.%.11]
// CHECK:STDOUT: %.loc8_19.9: ref i32 = array_index %b.var, %.loc8_19.8
// CHECK:STDOUT: %.loc8_19.10: init i32 = initialize_from %.loc8_19.7 to %.loc8_19.9
// CHECK:STDOUT: %.loc8_19.11: ref i32 = tuple_access %a.ref, element2
// CHECK:STDOUT: %.loc8_19.12: i32 = bind_value %.loc8_19.11
// CHECK:STDOUT: %.loc8_19.13: i32 = int_literal 2 [template = constants.%.11]
// CHECK:STDOUT: %.loc8_19.13: i32 = int_literal 2 [template = constants.%.12]
// CHECK:STDOUT: %.loc8_19.14: ref i32 = array_index %b.var, %.loc8_19.13
// CHECK:STDOUT: %.loc8_19.15: init i32 = initialize_from %.loc8_19.12 to %.loc8_19.14
// CHECK:STDOUT: %.loc8_19.16: init [i32; 3] = array_init (%.loc8_19.5, %.loc8_19.10, %.loc8_19.15) to %b.var
+50 -46
View File
@@ -16,21 +16,25 @@ var c: [(); 5] = ((), (), (), (), (),);
// CHECK:STDOUT: %.3: type = ptr_type [i32; 1] [template]
// CHECK:STDOUT: %.4: type = tuple_type (i32) [template]
// CHECK:STDOUT: %.5: i32 = int_literal 0 [template]
// CHECK:STDOUT: %.6: i32 = int_literal 2 [template]
// CHECK:STDOUT: %.7: type = array_type %.6, f64 [template]
// CHECK:STDOUT: %.8: type = ptr_type [f64; 2] [template]
// CHECK:STDOUT: %.9: f64 = real_literal 111e-1 [template]
// CHECK:STDOUT: %.10: f64 = real_literal 22e-1 [template]
// CHECK:STDOUT: %.11: type = tuple_type (f64, f64) [template]
// CHECK:STDOUT: %.12: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.13: type = tuple_type () [template]
// CHECK:STDOUT: %.14: i32 = int_literal 5 [template]
// CHECK:STDOUT: %.15: type = array_type %.14, () [template]
// CHECK:STDOUT: %.16: type = ptr_type [(); 5] [template]
// CHECK:STDOUT: %.17: type = tuple_type ((), (), (), (), ()) [template]
// CHECK:STDOUT: %.18: i32 = int_literal 2 [template]
// CHECK:STDOUT: %.19: i32 = int_literal 3 [template]
// CHECK:STDOUT: %.20: i32 = int_literal 4 [template]
// CHECK:STDOUT: %.6: [i32; 1] = tuple_value (%.1) [template]
// CHECK:STDOUT: %.7: i32 = int_literal 2 [template]
// CHECK:STDOUT: %.8: type = array_type %.7, f64 [template]
// CHECK:STDOUT: %.9: type = ptr_type [f64; 2] [template]
// CHECK:STDOUT: %.10: f64 = real_literal 111e-1 [template]
// CHECK:STDOUT: %.11: f64 = real_literal 22e-1 [template]
// CHECK:STDOUT: %.12: type = tuple_type (f64, f64) [template]
// CHECK:STDOUT: %.13: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.14: [f64; 2] = tuple_value (%.10, %.11) [template]
// CHECK:STDOUT: %.15: type = tuple_type () [template]
// CHECK:STDOUT: %.16: i32 = int_literal 5 [template]
// CHECK:STDOUT: %.17: type = array_type %.16, () [template]
// CHECK:STDOUT: %.18: type = ptr_type [(); 5] [template]
// CHECK:STDOUT: %.19: type = tuple_type ((), (), (), (), ()) [template]
// CHECK:STDOUT: %.20: () = tuple_value () [template]
// CHECK:STDOUT: %.21: i32 = int_literal 2 [template]
// CHECK:STDOUT: %.22: i32 = int_literal 3 [template]
// CHECK:STDOUT: %.23: i32 = int_literal 4 [template]
// CHECK:STDOUT: %.24: [(); 5] = tuple_value (%.20, %.20, %.20, %.20, %.20) [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
@@ -43,30 +47,30 @@ var c: [(); 5] = ((), (), (), (), (),);
// CHECK:STDOUT: %.loc7_22.1: (i32,) = tuple_literal (%.loc7_20)
// CHECK:STDOUT: %.loc7_22.2: i32 = int_literal 0 [template = constants.%.5]
// CHECK:STDOUT: %.loc7_22.3: ref i32 = array_index %a.var, %.loc7_22.2
// CHECK:STDOUT: %.loc7_22.4: init i32 = initialize_from %.loc7_20 to %.loc7_22.3
// CHECK:STDOUT: %.loc7_22.5: init [i32; 1] = array_init (%.loc7_22.4) to %a.var
// CHECK:STDOUT: %.loc7_22.6: init [i32; 1] = converted %.loc7_22.1, %.loc7_22.5
// CHECK:STDOUT: %.loc7_22.4: init i32 = initialize_from %.loc7_20 to %.loc7_22.3 [template = constants.%.1]
// CHECK:STDOUT: %.loc7_22.5: init [i32; 1] = array_init (%.loc7_22.4) to %a.var [template = constants.%.6]
// CHECK:STDOUT: %.loc7_22.6: init [i32; 1] = converted %.loc7_22.1, %.loc7_22.5 [template = constants.%.6]
// CHECK:STDOUT: assign %a.var, %.loc7_22.6
// CHECK:STDOUT: %.loc8_14: i32 = int_literal 2 [template = constants.%.6]
// CHECK:STDOUT: %.loc8_15: type = array_type %.loc8_14, f64 [template = constants.%.7]
// CHECK:STDOUT: %.loc8_14: i32 = int_literal 2 [template = constants.%.7]
// CHECK:STDOUT: %.loc8_15: type = array_type %.loc8_14, f64 [template = constants.%.8]
// CHECK:STDOUT: %b.var: ref [f64; 2] = var b
// CHECK:STDOUT: %b: ref [f64; 2] = bind_name b, %b.var
// CHECK:STDOUT: %.loc8_20: f64 = real_literal 111e-1 [template = constants.%.9]
// CHECK:STDOUT: %.loc8_26: f64 = real_literal 22e-1 [template = constants.%.10]
// CHECK:STDOUT: %.loc8_20: f64 = real_literal 111e-1 [template = constants.%.10]
// CHECK:STDOUT: %.loc8_26: f64 = real_literal 22e-1 [template = constants.%.11]
// CHECK:STDOUT: %.loc8_30.1: (f64, f64) = tuple_literal (%.loc8_20, %.loc8_26)
// CHECK:STDOUT: %.loc8_30.2: i32 = int_literal 0 [template = constants.%.5]
// CHECK:STDOUT: %.loc8_30.3: ref f64 = array_index %b.var, %.loc8_30.2
// CHECK:STDOUT: %.loc8_30.4: init f64 = initialize_from %.loc8_20 to %.loc8_30.3
// CHECK:STDOUT: %.loc8_30.5: i32 = int_literal 1 [template = constants.%.12]
// CHECK:STDOUT: %.loc8_30.4: init f64 = initialize_from %.loc8_20 to %.loc8_30.3 [template = constants.%.10]
// CHECK:STDOUT: %.loc8_30.5: i32 = int_literal 1 [template = constants.%.13]
// CHECK:STDOUT: %.loc8_30.6: ref f64 = array_index %b.var, %.loc8_30.5
// CHECK:STDOUT: %.loc8_30.7: init f64 = initialize_from %.loc8_26 to %.loc8_30.6
// CHECK:STDOUT: %.loc8_30.8: init [f64; 2] = array_init (%.loc8_30.4, %.loc8_30.7) to %b.var
// CHECK:STDOUT: %.loc8_30.9: init [f64; 2] = converted %.loc8_30.1, %.loc8_30.8
// CHECK:STDOUT: %.loc8_30.7: init f64 = initialize_from %.loc8_26 to %.loc8_30.6 [template = constants.%.11]
// CHECK:STDOUT: %.loc8_30.8: init [f64; 2] = array_init (%.loc8_30.4, %.loc8_30.7) to %b.var [template = constants.%.14]
// CHECK:STDOUT: %.loc8_30.9: init [f64; 2] = converted %.loc8_30.1, %.loc8_30.8 [template = constants.%.14]
// CHECK:STDOUT: assign %b.var, %.loc8_30.9
// CHECK:STDOUT: %.loc9_10.1: () = tuple_literal ()
// CHECK:STDOUT: %.loc9_13: i32 = int_literal 5 [template = constants.%.14]
// CHECK:STDOUT: %.loc9_10.2: type = converted %.loc9_10.1, constants.%.13 [template = constants.%.13]
// CHECK:STDOUT: %.loc9_14: type = array_type %.loc9_13, () [template = constants.%.15]
// CHECK:STDOUT: %.loc9_13: i32 = int_literal 5 [template = constants.%.16]
// CHECK:STDOUT: %.loc9_10.2: type = converted %.loc9_10.1, constants.%.15 [template = constants.%.15]
// CHECK:STDOUT: %.loc9_14: type = array_type %.loc9_13, () [template = constants.%.17]
// CHECK:STDOUT: %c.var: ref [(); 5] = var c
// CHECK:STDOUT: %c: ref [(); 5] = bind_name c, %c.var
// CHECK:STDOUT: %.loc9_20.1: () = tuple_literal ()
@@ -77,26 +81,26 @@ var c: [(); 5] = ((), (), (), (), (),);
// CHECK:STDOUT: %.loc9_38.1: ((), (), (), (), ()) = tuple_literal (%.loc9_20.1, %.loc9_24.1, %.loc9_28.1, %.loc9_32.1, %.loc9_36.1)
// CHECK:STDOUT: %.loc9_38.2: i32 = int_literal 0 [template = constants.%.5]
// CHECK:STDOUT: %.loc9_38.3: ref () = array_index %c.var, %.loc9_38.2
// CHECK:STDOUT: %.loc9_20.2: init () = tuple_init () to %.loc9_38.3
// CHECK:STDOUT: %.loc9_20.3: init () = converted %.loc9_20.1, %.loc9_20.2
// CHECK:STDOUT: %.loc9_38.4: i32 = int_literal 1 [template = constants.%.12]
// CHECK:STDOUT: %.loc9_20.2: init () = tuple_init () to %.loc9_38.3 [template = constants.%.20]
// CHECK:STDOUT: %.loc9_20.3: init () = converted %.loc9_20.1, %.loc9_20.2 [template = constants.%.20]
// CHECK:STDOUT: %.loc9_38.4: i32 = int_literal 1 [template = constants.%.13]
// CHECK:STDOUT: %.loc9_38.5: ref () = array_index %c.var, %.loc9_38.4
// CHECK:STDOUT: %.loc9_24.2: init () = tuple_init () to %.loc9_38.5
// CHECK:STDOUT: %.loc9_24.3: init () = converted %.loc9_24.1, %.loc9_24.2
// CHECK:STDOUT: %.loc9_38.6: i32 = int_literal 2 [template = constants.%.18]
// CHECK:STDOUT: %.loc9_24.2: init () = tuple_init () to %.loc9_38.5 [template = constants.%.20]
// CHECK:STDOUT: %.loc9_24.3: init () = converted %.loc9_24.1, %.loc9_24.2 [template = constants.%.20]
// CHECK:STDOUT: %.loc9_38.6: i32 = int_literal 2 [template = constants.%.21]
// CHECK:STDOUT: %.loc9_38.7: ref () = array_index %c.var, %.loc9_38.6
// CHECK:STDOUT: %.loc9_28.2: init () = tuple_init () to %.loc9_38.7
// CHECK:STDOUT: %.loc9_28.3: init () = converted %.loc9_28.1, %.loc9_28.2
// CHECK:STDOUT: %.loc9_38.8: i32 = int_literal 3 [template = constants.%.19]
// CHECK:STDOUT: %.loc9_28.2: init () = tuple_init () to %.loc9_38.7 [template = constants.%.20]
// CHECK:STDOUT: %.loc9_28.3: init () = converted %.loc9_28.1, %.loc9_28.2 [template = constants.%.20]
// CHECK:STDOUT: %.loc9_38.8: i32 = int_literal 3 [template = constants.%.22]
// CHECK:STDOUT: %.loc9_38.9: ref () = array_index %c.var, %.loc9_38.8
// CHECK:STDOUT: %.loc9_32.2: init () = tuple_init () to %.loc9_38.9
// CHECK:STDOUT: %.loc9_32.3: init () = converted %.loc9_32.1, %.loc9_32.2
// CHECK:STDOUT: %.loc9_38.10: i32 = int_literal 4 [template = constants.%.20]
// CHECK:STDOUT: %.loc9_32.2: init () = tuple_init () to %.loc9_38.9 [template = constants.%.20]
// CHECK:STDOUT: %.loc9_32.3: init () = converted %.loc9_32.1, %.loc9_32.2 [template = constants.%.20]
// CHECK:STDOUT: %.loc9_38.10: i32 = int_literal 4 [template = constants.%.23]
// CHECK:STDOUT: %.loc9_38.11: ref () = array_index %c.var, %.loc9_38.10
// CHECK:STDOUT: %.loc9_36.2: init () = tuple_init () to %.loc9_38.11
// CHECK:STDOUT: %.loc9_36.3: init () = converted %.loc9_36.1, %.loc9_36.2
// CHECK:STDOUT: %.loc9_38.12: init [(); 5] = array_init (%.loc9_20.3, %.loc9_24.3, %.loc9_28.3, %.loc9_32.3, %.loc9_36.3) to %c.var
// CHECK:STDOUT: %.loc9_38.13: init [(); 5] = converted %.loc9_38.1, %.loc9_38.12
// CHECK:STDOUT: %.loc9_36.2: init () = tuple_init () to %.loc9_38.11 [template = constants.%.20]
// CHECK:STDOUT: %.loc9_36.3: init () = converted %.loc9_36.1, %.loc9_36.2 [template = constants.%.20]
// CHECK:STDOUT: %.loc9_38.12: init [(); 5] = array_init (%.loc9_20.3, %.loc9_24.3, %.loc9_28.3, %.loc9_32.3, %.loc9_36.3) to %c.var [template = constants.%.24]
// CHECK:STDOUT: %.loc9_38.13: init [(); 5] = converted %.loc9_38.1, %.loc9_38.12 [template = constants.%.24]
// CHECK:STDOUT: assign %c.var, %.loc9_38.13
// CHECK:STDOUT: }
// CHECK:STDOUT:
+1 -1
View File
@@ -60,7 +60,7 @@ var d: [i32; 3] = t2;
// CHECK:STDOUT: %.loc10_39.1: (i32, String, String) = tuple_literal (%.loc10_20, %.loc10_23, %.loc10_32)
// CHECK:STDOUT: %.loc10_39.2: i32 = int_literal 0 [template = constants.%.9]
// CHECK:STDOUT: %.loc10_39.3: ref i32 = array_index %a.var, %.loc10_39.2
// CHECK:STDOUT: %.loc10_39.4: init i32 = initialize_from %.loc10_20 to %.loc10_39.3
// CHECK:STDOUT: %.loc10_39.4: init i32 = initialize_from %.loc10_20 to %.loc10_39.3 [template = constants.%.4]
// CHECK:STDOUT: assign %a.var, <error>
// CHECK:STDOUT: %.loc12_29.1: (type, type, type) = tuple_literal (i32, String, String)
// CHECK:STDOUT: %.loc12_29.2: type = converted %.loc12_29.1, constants.%.8 [template = constants.%.8]
+6 -5
View File
@@ -24,6 +24,7 @@ fn G() -> i32 {
// CHECK:STDOUT: %.7: i32 = int_literal 0 [template]
// CHECK:STDOUT: %.8: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.9: i32 = int_literal 2 [template]
// CHECK:STDOUT: %.10: [i32; 3] = tuple_value (%.4, %.5, %.1) [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
@@ -53,15 +54,15 @@ fn G() -> i32 {
// CHECK:STDOUT: %.loc12_20.2: ref [i32; 3] = temporary_storage
// CHECK:STDOUT: %.loc12_20.3: i32 = int_literal 0 [template = constants.%.7]
// CHECK:STDOUT: %.loc12_20.4: ref i32 = array_index %.loc12_20.2, %.loc12_20.3
// CHECK:STDOUT: %.loc12_20.5: init i32 = initialize_from %.loc12_13 to %.loc12_20.4
// CHECK:STDOUT: %.loc12_20.5: init i32 = initialize_from %.loc12_13 to %.loc12_20.4 [template = constants.%.4]
// CHECK:STDOUT: %.loc12_20.6: i32 = int_literal 1 [template = constants.%.8]
// CHECK:STDOUT: %.loc12_20.7: ref i32 = array_index %.loc12_20.2, %.loc12_20.6
// CHECK:STDOUT: %.loc12_20.8: init i32 = initialize_from %.loc12_16 to %.loc12_20.7
// CHECK:STDOUT: %.loc12_20.8: init i32 = initialize_from %.loc12_16 to %.loc12_20.7 [template = constants.%.5]
// CHECK:STDOUT: %.loc12_20.9: i32 = int_literal 2 [template = constants.%.9]
// CHECK:STDOUT: %.loc12_20.10: ref i32 = array_index %.loc12_20.2, %.loc12_20.9
// CHECK:STDOUT: %.loc12_20.11: init i32 = initialize_from %.loc12_19 to %.loc12_20.10
// CHECK:STDOUT: %.loc12_20.12: init [i32; 3] = array_init (%.loc12_20.5, %.loc12_20.8, %.loc12_20.11) to %.loc12_20.2
// CHECK:STDOUT: %.loc12_20.13: init [i32; 3] = converted %.loc12_20.1, %.loc12_20.12
// CHECK:STDOUT: %.loc12_20.11: init i32 = initialize_from %.loc12_19 to %.loc12_20.10 [template = constants.%.1]
// CHECK:STDOUT: %.loc12_20.12: init [i32; 3] = array_init (%.loc12_20.5, %.loc12_20.8, %.loc12_20.11) to %.loc12_20.2 [template = constants.%.10]
// CHECK:STDOUT: %.loc12_20.13: init [i32; 3] = converted %.loc12_20.1, %.loc12_20.12 [template = constants.%.10]
// CHECK:STDOUT: %.loc12_20.14: ref [i32; 3] = temporary %.loc12_20.2, %.loc12_20.13
// CHECK:STDOUT: %.loc12_20.15: [i32; 3] = bind_value %.loc12_20.14
// CHECK:STDOUT: %.loc12_11.1: init i32 = call %F.ref(%.loc12_20.15, %.loc12_23)
+12 -11
View File
@@ -30,6 +30,7 @@ var a: [i32; 9] = (1, 2, 3, 4, 5, 6, 7, 8, 9);
// CHECK:STDOUT: %.19: i32 = int_literal 6 [template]
// CHECK:STDOUT: %.20: i32 = int_literal 7 [template]
// CHECK:STDOUT: %.21: i32 = int_literal 8 [template]
// CHECK:STDOUT: %.22: [i32; 9] = tuple_value (%.4, %.5, %.6, %.7, %.8, %.9, %.10, %.11, %.1) [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
@@ -50,33 +51,33 @@ var a: [i32; 9] = (1, 2, 3, 4, 5, 6, 7, 8, 9);
// CHECK:STDOUT: %.loc7_45.1: (i32, i32, i32, i32, i32, i32, i32, i32, i32) = tuple_literal (%.loc7_20, %.loc7_23, %.loc7_26, %.loc7_29, %.loc7_32, %.loc7_35, %.loc7_38, %.loc7_41, %.loc7_44)
// CHECK:STDOUT: %.loc7_45.2: i32 = int_literal 0 [template = constants.%.13]
// CHECK:STDOUT: %.loc7_45.3: ref i32 = array_index %a.var, %.loc7_45.2
// CHECK:STDOUT: %.loc7_45.4: init i32 = initialize_from %.loc7_20 to %.loc7_45.3
// CHECK:STDOUT: %.loc7_45.4: init i32 = initialize_from %.loc7_20 to %.loc7_45.3 [template = constants.%.4]
// CHECK:STDOUT: %.loc7_45.5: i32 = int_literal 1 [template = constants.%.14]
// CHECK:STDOUT: %.loc7_45.6: ref i32 = array_index %a.var, %.loc7_45.5
// CHECK:STDOUT: %.loc7_45.7: init i32 = initialize_from %.loc7_23 to %.loc7_45.6
// CHECK:STDOUT: %.loc7_45.7: init i32 = initialize_from %.loc7_23 to %.loc7_45.6 [template = constants.%.5]
// CHECK:STDOUT: %.loc7_45.8: i32 = int_literal 2 [template = constants.%.15]
// CHECK:STDOUT: %.loc7_45.9: ref i32 = array_index %a.var, %.loc7_45.8
// CHECK:STDOUT: %.loc7_45.10: init i32 = initialize_from %.loc7_26 to %.loc7_45.9
// CHECK:STDOUT: %.loc7_45.10: init i32 = initialize_from %.loc7_26 to %.loc7_45.9 [template = constants.%.6]
// CHECK:STDOUT: %.loc7_45.11: i32 = int_literal 3 [template = constants.%.16]
// CHECK:STDOUT: %.loc7_45.12: ref i32 = array_index %a.var, %.loc7_45.11
// CHECK:STDOUT: %.loc7_45.13: init i32 = initialize_from %.loc7_29 to %.loc7_45.12
// CHECK:STDOUT: %.loc7_45.13: init i32 = initialize_from %.loc7_29 to %.loc7_45.12 [template = constants.%.7]
// CHECK:STDOUT: %.loc7_45.14: i32 = int_literal 4 [template = constants.%.17]
// CHECK:STDOUT: %.loc7_45.15: ref i32 = array_index %a.var, %.loc7_45.14
// CHECK:STDOUT: %.loc7_45.16: init i32 = initialize_from %.loc7_32 to %.loc7_45.15
// CHECK:STDOUT: %.loc7_45.16: init i32 = initialize_from %.loc7_32 to %.loc7_45.15 [template = constants.%.8]
// CHECK:STDOUT: %.loc7_45.17: i32 = int_literal 5 [template = constants.%.18]
// CHECK:STDOUT: %.loc7_45.18: ref i32 = array_index %a.var, %.loc7_45.17
// CHECK:STDOUT: %.loc7_45.19: init i32 = initialize_from %.loc7_35 to %.loc7_45.18
// CHECK:STDOUT: %.loc7_45.19: init i32 = initialize_from %.loc7_35 to %.loc7_45.18 [template = constants.%.9]
// CHECK:STDOUT: %.loc7_45.20: i32 = int_literal 6 [template = constants.%.19]
// CHECK:STDOUT: %.loc7_45.21: ref i32 = array_index %a.var, %.loc7_45.20
// CHECK:STDOUT: %.loc7_45.22: init i32 = initialize_from %.loc7_38 to %.loc7_45.21
// CHECK:STDOUT: %.loc7_45.22: init i32 = initialize_from %.loc7_38 to %.loc7_45.21 [template = constants.%.10]
// CHECK:STDOUT: %.loc7_45.23: i32 = int_literal 7 [template = constants.%.20]
// CHECK:STDOUT: %.loc7_45.24: ref i32 = array_index %a.var, %.loc7_45.23
// CHECK:STDOUT: %.loc7_45.25: init i32 = initialize_from %.loc7_41 to %.loc7_45.24
// CHECK:STDOUT: %.loc7_45.25: init i32 = initialize_from %.loc7_41 to %.loc7_45.24 [template = constants.%.11]
// CHECK:STDOUT: %.loc7_45.26: i32 = int_literal 8 [template = constants.%.21]
// CHECK:STDOUT: %.loc7_45.27: ref i32 = array_index %a.var, %.loc7_45.26
// CHECK:STDOUT: %.loc7_45.28: init i32 = initialize_from %.loc7_44 to %.loc7_45.27
// CHECK:STDOUT: %.loc7_45.29: init [i32; 9] = array_init (%.loc7_45.4, %.loc7_45.7, %.loc7_45.10, %.loc7_45.13, %.loc7_45.16, %.loc7_45.19, %.loc7_45.22, %.loc7_45.25, %.loc7_45.28) to %a.var
// CHECK:STDOUT: %.loc7_45.30: init [i32; 9] = converted %.loc7_45.1, %.loc7_45.29
// CHECK:STDOUT: %.loc7_45.28: init i32 = initialize_from %.loc7_44 to %.loc7_45.27 [template = constants.%.1]
// CHECK:STDOUT: %.loc7_45.29: init [i32; 9] = array_init (%.loc7_45.4, %.loc7_45.7, %.loc7_45.10, %.loc7_45.13, %.loc7_45.16, %.loc7_45.19, %.loc7_45.22, %.loc7_45.25, %.loc7_45.28) to %a.var [template = constants.%.22]
// CHECK:STDOUT: %.loc7_45.30: init [i32; 9] = converted %.loc7_45.1, %.loc7_45.29 [template = constants.%.22]
// CHECK:STDOUT: assign %a.var, %.loc7_45.30
// CHECK:STDOUT: }
// CHECK:STDOUT: