Deduplicate and canonicalize all constants. (#3611)

Rather than producing multiple constants with the same value, fold all
instances of a given constant to the same constant instruction.

A future PR will use this to replace the current type canonicalization
system.
This commit is contained in:
Richard Smith
2024-01-18 21:42:19 +00:00
committed by GitHub
parent 62db3e9ad0
commit 29c294880d
142 changed files with 1603 additions and 1185 deletions
+3 -2
View File
@@ -12,12 +12,13 @@ var x: {.a: i32} = {};
// CHECK:STDOUT: --- fail_assign_empty.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %.1: type = struct_type {.a: i32} [template]
// CHECK:STDOUT: %.2: type = struct_type {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace package, {.x = %x} [template]
// CHECK:STDOUT: %.loc10_16: type = struct_type {.a: i32} [template]
// CHECK:STDOUT: %.loc10_16: type = struct_type {.a: i32} [template = constants.%.1]
// CHECK:STDOUT: %x.var: ref {.a: i32} = var x
// CHECK:STDOUT: %x: ref {.a: i32} = bind_name x, %x.var
// CHECK:STDOUT: %.loc10_21: {} = struct_literal ()
+5 -4
View File
@@ -13,16 +13,17 @@ var x: {.a: {}} = {.b = {}};
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %.2: type = tuple_type () [template]
// CHECK:STDOUT: %.3: type = struct_type {.a: ()} [template]
// CHECK:STDOUT: %.4: type = struct_type {.b: {}} [template]
// CHECK:STDOUT: %.2: type = struct_type {.a: {}} [template]
// CHECK:STDOUT: %.3: type = tuple_type () [template]
// CHECK:STDOUT: %.4: type = struct_type {.a: ()} [template]
// CHECK:STDOUT: %.5: type = struct_type {.b: {}} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace package, {.x = %x} [template]
// CHECK:STDOUT: %.loc10_14.1: {} = struct_literal ()
// CHECK:STDOUT: %.loc10_14.2: type = converted %.loc10_14.1, constants.%.1 [template = constants.%.1]
// CHECK:STDOUT: %.loc10_15: type = struct_type {.a: {}} [template]
// CHECK:STDOUT: %.loc10_15: type = struct_type {.a: {}} [template = constants.%.2]
// CHECK:STDOUT: %x.var: ref {.a: {}} = var x
// CHECK:STDOUT: %x: ref {.a: {}} = bind_name x, %x.var
// CHECK:STDOUT: %.loc10_26: {} = struct_literal ()
+14 -15
View File
@@ -49,13 +49,12 @@ var y: {.b: i32, .c: i32} = {.b = 3, .b = 4};
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.2: type = struct_type {.a: i32} [template]
// CHECK:STDOUT: %.3: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.4: i32 = int_literal 2 [template]
// CHECK:STDOUT: %.5: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.6: i32 = int_literal 2 [template]
// CHECK:STDOUT: %.7: type = ptr_type {.b: i32, .c: i32} [template]
// CHECK:STDOUT: %.8: i32 = int_literal 3 [template]
// CHECK:STDOUT: %.9: i32 = int_literal 4 [template]
// CHECK:STDOUT: %.3: i32 = int_literal 2 [template]
// CHECK:STDOUT: %.4: type = struct_type {.a: i32} [template]
// CHECK:STDOUT: %.5: type = struct_type {.b: i32, .c: i32} [template]
// CHECK:STDOUT: %.6: type = ptr_type {.b: i32, .c: i32} [template]
// CHECK:STDOUT: %.7: i32 = int_literal 3 [template]
// CHECK:STDOUT: %.8: i32 = int_literal 4 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
@@ -64,20 +63,20 @@ var y: {.b: i32, .c: i32} = {.b = 3, .b = 4};
// CHECK:STDOUT: %.loc21_35: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %.loc21_36: {.a: i32} = struct_literal (%.loc21_35)
// CHECK:STDOUT: %v: <error> = bind_name v, <error>
// CHECK:STDOUT: %.loc29_22: i32 = int_literal 1 [template = constants.%.3]
// CHECK:STDOUT: %.loc29_32: i32 = int_literal 2 [template = constants.%.4]
// CHECK:STDOUT: %.loc29_22: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %.loc29_32: i32 = int_literal 2 [template = constants.%.3]
// CHECK:STDOUT: %w: i32 = bind_name w, <error>
// CHECK:STDOUT: %.loc37_16: type = struct_type {.a: i32} [template]
// CHECK:STDOUT: %.loc37_16: type = struct_type {.a: i32} [template = constants.%.4]
// CHECK:STDOUT: %x.var: ref {.a: i32} = var x
// CHECK:STDOUT: %x: ref {.a: i32} = bind_name x, %x.var
// CHECK:STDOUT: %.loc37_26: i32 = int_literal 1 [template = constants.%.5]
// CHECK:STDOUT: %.loc37_34: i32 = int_literal 2 [template = constants.%.6]
// CHECK:STDOUT: %.loc37_26: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %.loc37_34: i32 = int_literal 2 [template = constants.%.3]
// CHECK:STDOUT: assign %x.var, <error>
// CHECK:STDOUT: %.loc45_25: type = struct_type {.b: i32, .c: i32} [template]
// CHECK:STDOUT: %.loc45_25: type = struct_type {.b: i32, .c: i32} [template = constants.%.5]
// CHECK:STDOUT: %y.var: ref {.b: i32, .c: i32} = var y
// CHECK:STDOUT: %y: ref {.b: i32, .c: i32} = bind_name y, %y.var
// CHECK:STDOUT: %.loc45_35: i32 = int_literal 3 [template = constants.%.8]
// CHECK:STDOUT: %.loc45_43: i32 = int_literal 4 [template = constants.%.9]
// CHECK:STDOUT: %.loc45_35: i32 = int_literal 3 [template = constants.%.7]
// CHECK:STDOUT: %.loc45_43: i32 = int_literal 4 [template = constants.%.8]
// CHECK:STDOUT: assign %y.var, <error>
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -17,19 +17,21 @@ var y: {.b: i32} = x;
// CHECK:STDOUT: --- fail_field_name_mismatch.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.2: type = struct_type {.b: i32} [template]
// CHECK:STDOUT: %.1: type = struct_type {.a: i32} [template]
// CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.3: type = struct_type {.b: i32} [template]
// CHECK:STDOUT: %.4: type = struct_type {.b: i32} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace package, {.x = %x, .y = %y} [template]
// CHECK:STDOUT: %.loc10_16: type = struct_type {.a: i32} [template]
// CHECK:STDOUT: %.loc10_16: type = struct_type {.a: i32} [template = constants.%.1]
// CHECK:STDOUT: %x.var: ref {.a: i32} = var x
// CHECK:STDOUT: %x: ref {.a: i32} = bind_name x, %x.var
// CHECK:STDOUT: %.loc10_26: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %.loc10_26: i32 = int_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %.loc10_27: {.b: i32} = struct_literal (%.loc10_26)
// CHECK:STDOUT: assign %x.var, <error>
// CHECK:STDOUT: %.loc15: type = struct_type {.b: i32} [template]
// CHECK:STDOUT: %.loc15: type = struct_type {.b: i32} [template = constants.%.4]
// CHECK:STDOUT: %y.var: ref {.b: i32} = var y
// CHECK:STDOUT: %y: ref {.b: i32} = bind_name y, %y.var
// CHECK:STDOUT: %x.ref: ref {.a: i32} = name_ref x, %x
@@ -12,16 +12,17 @@ var x: {.a: i32} = {.b = 1.0};
// CHECK:STDOUT: --- fail_field_type_mismatch.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: f64 = real_literal 10e-1 [template]
// CHECK:STDOUT: %.2: type = struct_type {.b: f64} [template]
// CHECK:STDOUT: %.1: type = struct_type {.a: i32} [template]
// CHECK:STDOUT: %.2: f64 = real_literal 10e-1 [template]
// CHECK:STDOUT: %.3: type = struct_type {.b: f64} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace package, {.x = %x} [template]
// CHECK:STDOUT: %.loc10_16: type = struct_type {.a: i32} [template]
// CHECK:STDOUT: %.loc10_16: type = struct_type {.a: i32} [template = constants.%.1]
// CHECK:STDOUT: %x.var: ref {.a: i32} = var x
// CHECK:STDOUT: %x: ref {.a: i32} = bind_name x, %x.var
// CHECK:STDOUT: %.loc10_26: f64 = real_literal 10e-1 [template = constants.%.1]
// CHECK:STDOUT: %.loc10_26: f64 = real_literal 10e-1 [template = constants.%.2]
// CHECK:STDOUT: %.loc10_29: {.b: f64} = struct_literal (%.loc10_26)
// CHECK:STDOUT: assign %x.var, <error>
// CHECK:STDOUT: }
@@ -13,15 +13,16 @@ var y: i32 = x.b;
// CHECK:STDOUT: --- fail_member_access_type.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: f64 = real_literal 40e-1 [template]
// CHECK:STDOUT: %.1: type = struct_type {.a: f64} [template]
// CHECK:STDOUT: %.2: f64 = real_literal 40e-1 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace package, {.x = %x, .y = %y} [template]
// CHECK:STDOUT: %.loc7_16: type = struct_type {.a: f64} [template]
// CHECK:STDOUT: %.loc7_16: type = struct_type {.a: f64} [template = constants.%.1]
// CHECK:STDOUT: %x.var: ref {.a: f64} = var x
// CHECK:STDOUT: %x: ref {.a: f64} = bind_name x, %x.var
// CHECK:STDOUT: %.loc7_26: f64 = real_literal 40e-1 [template = constants.%.1]
// CHECK:STDOUT: %.loc7_26: f64 = real_literal 40e-1 [template = constants.%.2]
// CHECK:STDOUT: %.loc7_29.1: {.a: f64} = struct_literal (%.loc7_26)
// CHECK:STDOUT: %.loc7_29.2: init {.a: f64} = struct_init (%.loc7_26) to %x.var
// CHECK:STDOUT: %.loc7_29.3: init {.a: f64} = converted %.loc7_29.1, %.loc7_29.2
@@ -22,19 +22,22 @@ var p: Incomplete* = &s.a;
// CHECK:STDOUT: --- fail_nested_incomplete.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: type = ptr_type <error> [template]
// CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [template]
// CHECK:STDOUT: %.1: type = struct_type {.a: Incomplete} [template]
// CHECK:STDOUT: %.2: type = ptr_type Incomplete [template]
// CHECK:STDOUT: %.3: type = ptr_type <error> [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace package, {.Incomplete = %Incomplete.decl, .s = %s, .p = %p} [template]
// CHECK:STDOUT: %Incomplete.decl = class_decl @Incomplete, ()
// CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [template]
// CHECK:STDOUT: %Incomplete.ref.loc15: type = name_ref Incomplete, %Incomplete [template = %Incomplete]
// CHECK:STDOUT: %.loc15: type = struct_type {.a: Incomplete} [template]
// CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [template = constants.%Incomplete]
// CHECK:STDOUT: %Incomplete.ref.loc15: type = name_ref Incomplete, %Incomplete [template = constants.%Incomplete]
// CHECK:STDOUT: %.loc15: type = struct_type {.a: Incomplete} [template = constants.%.1]
// CHECK:STDOUT: %s.var: ref <error> = var s
// CHECK:STDOUT: %s: ref <error> = bind_name s, %s.var
// CHECK:STDOUT: %Incomplete.ref.loc20: type = name_ref Incomplete, %Incomplete [template = %Incomplete]
// CHECK:STDOUT: %.loc20_18: type = ptr_type Incomplete [template]
// CHECK:STDOUT: %Incomplete.ref.loc20: type = name_ref Incomplete, %Incomplete [template = constants.%Incomplete]
// CHECK:STDOUT: %.loc20_18: type = ptr_type Incomplete [template = constants.%.2]
// CHECK:STDOUT: %p.var: ref Incomplete* = var p
// CHECK:STDOUT: %p: ref Incomplete* = bind_name p, %p.var
// CHECK:STDOUT: %s.ref: ref <error> = name_ref s, %s
@@ -13,15 +13,16 @@ var y: i32 = x.b;
// CHECK:STDOUT: --- fail_non_member_access.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: i32 = int_literal 4 [template]
// CHECK:STDOUT: %.1: type = struct_type {.a: i32} [template]
// CHECK:STDOUT: %.2: i32 = int_literal 4 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace package, {.x = %x, .y = %y} [template]
// CHECK:STDOUT: %.loc7_16: type = struct_type {.a: i32} [template]
// CHECK:STDOUT: %.loc7_16: type = struct_type {.a: i32} [template = constants.%.1]
// CHECK:STDOUT: %x.var: ref {.a: i32} = var x
// CHECK:STDOUT: %x: ref {.a: i32} = bind_name x, %x.var
// CHECK:STDOUT: %.loc7_26: i32 = int_literal 4 [template = constants.%.1]
// CHECK:STDOUT: %.loc7_26: i32 = int_literal 4 [template = constants.%.2]
// CHECK:STDOUT: %.loc7_27.1: {.a: i32} = struct_literal (%.loc7_26)
// CHECK:STDOUT: %.loc7_27.2: init {.a: i32} = struct_init (%.loc7_26) to %x.var
// CHECK:STDOUT: %.loc7_27.3: init {.a: i32} = converted %.loc7_27.1, %.loc7_27.2
+6 -5
View File
@@ -12,17 +12,18 @@ var x: {.a: i32, .b: i32} = {.a = 1};
// CHECK:STDOUT: --- fail_too_few_values.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: type = ptr_type {.a: i32, .b: i32} [template]
// CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.3: type = struct_type {.a: i32} [template]
// CHECK:STDOUT: %.1: type = struct_type {.a: i32, .b: i32} [template]
// CHECK:STDOUT: %.2: type = ptr_type {.a: i32, .b: i32} [template]
// CHECK:STDOUT: %.3: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.4: type = struct_type {.a: i32} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace package, {.x = %x} [template]
// CHECK:STDOUT: %.loc10_25: type = struct_type {.a: i32, .b: i32} [template]
// CHECK:STDOUT: %.loc10_25: type = struct_type {.a: i32, .b: i32} [template = constants.%.1]
// CHECK:STDOUT: %x.var: ref {.a: i32, .b: i32} = var x
// CHECK:STDOUT: %x: ref {.a: i32, .b: i32} = bind_name x, %x.var
// CHECK:STDOUT: %.loc10_35: i32 = int_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %.loc10_35: i32 = int_literal 1 [template = constants.%.3]
// CHECK:STDOUT: %.loc10_36: {.a: i32} = struct_literal (%.loc10_35)
// CHECK:STDOUT: assign %x.var, <error>
// CHECK:STDOUT: }
+6 -2
View File
@@ -11,12 +11,16 @@ var x: {.a: i32} = {.a: i32};
// CHECK:STDOUT: --- fail_type_assign.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: type = struct_type {.a: i32} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace package, {.x = %x} [template]
// CHECK:STDOUT: %.loc10_16: type = struct_type {.a: i32} [template]
// CHECK:STDOUT: %.loc10_16: type = struct_type {.a: i32} [template = constants.%.1]
// CHECK:STDOUT: %x.var: ref {.a: i32} = var x
// CHECK:STDOUT: %x: ref {.a: i32} = bind_name x, %x.var
// CHECK:STDOUT: %.loc10_28: type = struct_type {.a: i32} [template]
// CHECK:STDOUT: %.loc10_28: type = struct_type {.a: i32} [template = constants.%.1]
// CHECK:STDOUT: assign %x.var, <error>
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -13,12 +13,13 @@ fn F() -> i32 {
// CHECK:STDOUT: --- literal_member_access.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: type = ptr_type {.x: i32, .y: i32, .z: i32} [template]
// CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.3: i32 = int_literal 3 [template]
// CHECK:STDOUT: %.4: type = struct_type {.a: i32, .b: {.x: i32, .y: i32, .z: i32}, .c: i32} [template]
// CHECK:STDOUT: %.5: type = struct_type {.a: i32, .b: {.x: i32, .y: i32, .z: i32}*, .c: i32} [template]
// CHECK:STDOUT: %.6: type = ptr_type {.a: i32, .b: {.x: i32, .y: i32, .z: i32}*, .c: i32} [template]
// CHECK:STDOUT: %.1: type = struct_type {.x: i32, .y: i32, .z: i32} [template]
// CHECK:STDOUT: %.2: type = ptr_type {.x: i32, .y: i32, .z: i32} [template]
// CHECK:STDOUT: %.3: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.4: i32 = int_literal 3 [template]
// CHECK:STDOUT: %.5: type = struct_type {.a: i32, .b: {.x: i32, .y: i32, .z: i32}, .c: i32} [template]
// CHECK:STDOUT: %.6: type = struct_type {.a: i32, .b: {.x: i32, .y: i32, .z: i32}*, .c: i32} [template]
// CHECK:STDOUT: %.7: type = ptr_type {.a: i32, .b: {.x: i32, .y: i32, .z: i32}*, .c: i32} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
@@ -31,11 +32,11 @@ fn F() -> i32 {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F() -> i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %.loc10_16: i32 = int_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %.loc10_16: i32 = int_literal 1 [template = constants.%.3]
// CHECK:STDOUT: %G.ref: <function> = name_ref G, file.%G [template = file.%G]
// CHECK:STDOUT: %.loc10_25.1: ref {.x: i32, .y: i32, .z: i32} = temporary_storage
// CHECK:STDOUT: %.loc10_25.2: init {.x: i32, .y: i32, .z: i32} = call %G.ref() to %.loc10_25.1
// CHECK:STDOUT: %.loc10_34: i32 = int_literal 3 [template = constants.%.3]
// CHECK:STDOUT: %.loc10_34: i32 = int_literal 3 [template = constants.%.4]
// CHECK:STDOUT: %.loc10_35.1: {.a: i32, .b: {.x: i32, .y: i32, .z: i32}, .c: i32} = struct_literal (%.loc10_16, %.loc10_25.2, %.loc10_34)
// CHECK:STDOUT: %.loc10_25.3: ref {.x: i32, .y: i32, .z: i32} = temporary %.loc10_25.1, %.loc10_25.2
// CHECK:STDOUT: %.loc10_25.4: ref i32 = struct_access %.loc10_25.3, element0
+7 -6
View File
@@ -11,18 +11,19 @@ var z: i32 = y;
// CHECK:STDOUT: --- member_access.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: type = ptr_type {.a: f64, .b: i32} [template]
// CHECK:STDOUT: %.2: f64 = real_literal 0e-1 [template]
// CHECK:STDOUT: %.3: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.1: type = struct_type {.a: f64, .b: i32} [template]
// CHECK:STDOUT: %.2: type = ptr_type {.a: f64, .b: i32} [template]
// CHECK:STDOUT: %.3: f64 = real_literal 0e-1 [template]
// CHECK:STDOUT: %.4: i32 = int_literal 1 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace package, {.x = %x, .y = %y, .z = %z} [template]
// CHECK:STDOUT: %.loc7_25: type = struct_type {.a: f64, .b: i32} [template]
// CHECK:STDOUT: %.loc7_25: type = struct_type {.a: f64, .b: i32} [template = constants.%.1]
// CHECK:STDOUT: %x.var: ref {.a: f64, .b: i32} = var x
// CHECK:STDOUT: %x: ref {.a: f64, .b: i32} = bind_name x, %x.var
// CHECK:STDOUT: %.loc7_35: f64 = real_literal 0e-1 [template = constants.%.2]
// CHECK:STDOUT: %.loc7_45: i32 = int_literal 1 [template = constants.%.3]
// CHECK:STDOUT: %.loc7_35: f64 = real_literal 0e-1 [template = constants.%.3]
// CHECK:STDOUT: %.loc7_45: i32 = int_literal 1 [template = constants.%.4]
// CHECK:STDOUT: %.loc7_46.1: {.a: f64, .b: i32} = struct_literal (%.loc7_35, %.loc7_45)
// CHECK:STDOUT: %.loc7_46.2: ref f64 = struct_access %x.var, element0
// CHECK:STDOUT: %.loc7_46.3: init f64 = initialize_from %.loc7_35 to %.loc7_46.2
@@ -16,8 +16,9 @@ fn G() {
// CHECK:STDOUT: %.1: type = tuple_type (type, type, type) [template]
// CHECK:STDOUT: %.2: type = tuple_type (i32, i32, i32) [template]
// CHECK:STDOUT: %.3: type = ptr_type (i32, i32, i32) [template]
// CHECK:STDOUT: %.4: type = struct_type {.a: (i32, i32, i32)*, .b: (i32, i32, i32)*} [template]
// CHECK:STDOUT: %.5: type = ptr_type {.a: (i32, i32, i32)*, .b: (i32, i32, i32)*} [template]
// CHECK:STDOUT: %.4: type = struct_type {.a: (i32, i32, i32), .b: (i32, i32, i32)} [template]
// CHECK:STDOUT: %.5: type = struct_type {.a: (i32, i32, i32)*, .b: (i32, i32, i32)*} [template]
// CHECK:STDOUT: %.6: type = ptr_type {.a: (i32, i32, i32)*, .b: (i32, i32, i32)*} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
@@ -34,7 +35,7 @@ fn G() {
// CHECK:STDOUT: %.loc10_29.2: type = converted %.loc10_29.1, constants.%.2 [template = constants.%.2]
// CHECK:STDOUT: %.loc10_50.1: (type, type, type) = tuple_literal (i32, i32, i32)
// CHECK:STDOUT: %.loc10_50.2: type = converted %.loc10_50.1, constants.%.2 [template = constants.%.2]
// CHECK:STDOUT: %.loc10_51: type = struct_type {.a: (i32, i32, i32), .b: (i32, i32, i32)} [template]
// CHECK:STDOUT: %.loc10_51: type = struct_type {.a: (i32, i32, i32), .b: (i32, i32, i32)} [template = constants.%.4]
// CHECK:STDOUT: %v.var: ref {.a: (i32, i32, i32), .b: (i32, i32, i32)} = var v
// CHECK:STDOUT: %v: ref {.a: (i32, i32, i32), .b: (i32, i32, i32)} = bind_name v, %v.var
// CHECK:STDOUT: %F.ref.loc10_61: <function> = name_ref F, file.%F [template = file.%F]
+5 -4
View File
@@ -10,20 +10,21 @@ var y: {.a: i32} = x;
// CHECK:STDOUT: --- one_entry.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: i32 = int_literal 4 [template]
// CHECK:STDOUT: %.1: type = struct_type {.a: i32} [template]
// CHECK:STDOUT: %.2: i32 = int_literal 4 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace package, {.x = %x, .y = %y} [template]
// CHECK:STDOUT: %.loc7_16: type = struct_type {.a: i32} [template]
// CHECK:STDOUT: %.loc7_16: type = struct_type {.a: i32} [template = constants.%.1]
// CHECK:STDOUT: %x.var: ref {.a: i32} = var x
// CHECK:STDOUT: %x: ref {.a: i32} = bind_name x, %x.var
// CHECK:STDOUT: %.loc7_26: i32 = int_literal 4 [template = constants.%.1]
// CHECK:STDOUT: %.loc7_26: i32 = int_literal 4 [template = constants.%.2]
// CHECK:STDOUT: %.loc7_27.1: {.a: i32} = struct_literal (%.loc7_26)
// CHECK:STDOUT: %.loc7_27.2: init {.a: i32} = struct_init (%.loc7_26) to %x.var
// CHECK:STDOUT: %.loc7_27.3: init {.a: i32} = converted %.loc7_27.1, %.loc7_27.2
// CHECK:STDOUT: assign %x.var, %.loc7_27.3
// CHECK:STDOUT: %.loc8_16: type = struct_type {.a: i32} [template]
// CHECK:STDOUT: %.loc8_16: type = struct_type {.a: i32} [template = constants.%.1]
// CHECK:STDOUT: %y.var: ref {.a: i32} = var y
// CHECK:STDOUT: %y: ref {.a: i32} = bind_name y, %y.var
// CHECK:STDOUT: %x.ref: ref {.a: i32} = name_ref x, %x
+7 -5
View File
@@ -16,9 +16,11 @@ fn F() -> {.a: i32, .b: f64} {
// CHECK:STDOUT: --- reorder_fields.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: type = ptr_type {.a: i32, .b: f64} [template]
// CHECK:STDOUT: %.2: type = struct_type {.b: f64, .a: i32} [template]
// CHECK:STDOUT: %.3: type = ptr_type {.b: f64, .a: i32} [template]
// CHECK:STDOUT: %.1: type = struct_type {.a: i32, .b: f64} [template]
// CHECK:STDOUT: %.2: type = ptr_type {.a: i32, .b: f64} [template]
// CHECK:STDOUT: %.3: type = struct_type {.b: f64, .a: i32} [template]
// CHECK:STDOUT: %.4: type = struct_type {.b: f64, .a: i32} [template]
// CHECK:STDOUT: %.5: type = ptr_type {.b: f64, .a: i32} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
@@ -34,7 +36,7 @@ fn F() -> {.a: i32, .b: f64} {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F() -> %return: {.a: i32, .b: f64} {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %.loc11_27: type = struct_type {.a: i32, .b: f64} [template]
// CHECK:STDOUT: %.loc11_27: type = struct_type {.a: i32, .b: f64} [template = constants.%.1]
// CHECK:STDOUT: %MakeF64.ref: <function> = name_ref MakeF64, file.%MakeF64 [template = file.%MakeF64]
// CHECK:STDOUT: %.loc11_44.1: init f64 = call %MakeF64.ref()
// CHECK:STDOUT: %MakeI32.ref: <function> = name_ref MakeI32, file.%MakeI32 [template = file.%MakeI32]
@@ -47,7 +49,7 @@ fn F() -> {.a: i32, .b: f64} {
// CHECK:STDOUT: %.loc11_62.4: {.a: i32, .b: f64} = struct_value (%.loc11_60.2, %.loc11_44.2)
// CHECK:STDOUT: %.loc11_62.5: {.a: i32, .b: f64} = converted %.loc11_62.1, %.loc11_62.4
// CHECK:STDOUT: %x: {.a: i32, .b: f64} = bind_name x, %.loc11_62.5
// CHECK:STDOUT: %.loc12_27: type = struct_type {.b: f64, .a: i32} [template]
// CHECK:STDOUT: %.loc12_27: type = struct_type {.b: f64, .a: i32} [template = constants.%.4]
// CHECK:STDOUT: %x.ref: {.a: i32, .b: f64} = name_ref x, %x
// CHECK:STDOUT: %.loc12_31.1: f64 = struct_access %x.ref, element1
// CHECK:STDOUT: %.loc12_31.2: i32 = struct_access %x.ref, element0
+8 -7
View File
@@ -12,20 +12,21 @@ var y: {.a: i32, .b: (i32,)} = x;
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: type = tuple_type (type) [template]
// CHECK:STDOUT: %.2: type = tuple_type (i32) [template]
// CHECK:STDOUT: %.3: type = ptr_type {.a: i32, .b: (i32,)} [template]
// CHECK:STDOUT: %.4: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.5: i32 = int_literal 2 [template]
// CHECK:STDOUT: %.3: type = struct_type {.a: i32, .b: (i32,)} [template]
// CHECK:STDOUT: %.4: type = ptr_type {.a: i32, .b: (i32,)} [template]
// CHECK:STDOUT: %.5: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.6: i32 = int_literal 2 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace package, {.x = %x, .y = %y} [template]
// CHECK:STDOUT: %.loc7_27.1: (type,) = tuple_literal (i32)
// CHECK:STDOUT: %.loc7_27.2: type = converted %.loc7_27.1, constants.%.2 [template = constants.%.2]
// CHECK:STDOUT: %.loc7_28: type = struct_type {.a: i32, .b: (i32,)} [template]
// CHECK:STDOUT: %.loc7_28: type = struct_type {.a: i32, .b: (i32,)} [template = constants.%.3]
// CHECK:STDOUT: %x.var: ref {.a: i32, .b: (i32,)} = var x
// CHECK:STDOUT: %x: ref {.a: i32, .b: (i32,)} = bind_name x, %x.var
// CHECK:STDOUT: %.loc7_38: i32 = int_literal 1 [template = constants.%.4]
// CHECK:STDOUT: %.loc7_47: i32 = int_literal 2 [template = constants.%.5]
// CHECK:STDOUT: %.loc7_38: i32 = int_literal 1 [template = constants.%.5]
// CHECK:STDOUT: %.loc7_47: i32 = int_literal 2 [template = constants.%.6]
// CHECK:STDOUT: %.loc7_49.1: (i32,) = tuple_literal (%.loc7_47)
// CHECK:STDOUT: %.loc7_50.1: {.a: i32, .b: (i32,)} = struct_literal (%.loc7_38, %.loc7_49.1)
// CHECK:STDOUT: %.loc7_50.2: ref i32 = struct_access %x.var, element0
@@ -39,7 +40,7 @@ var y: {.a: i32, .b: (i32,)} = x;
// CHECK:STDOUT: assign %x.var, %.loc7_50.7
// CHECK:STDOUT: %.loc8_27.1: (type,) = tuple_literal (i32)
// CHECK:STDOUT: %.loc8_27.2: type = converted %.loc8_27.1, constants.%.2 [template = constants.%.2]
// CHECK:STDOUT: %.loc8_28: type = struct_type {.a: i32, .b: (i32,)} [template]
// CHECK:STDOUT: %.loc8_28: type = struct_type {.a: i32, .b: (i32,)} [template = constants.%.3]
// CHECK:STDOUT: %y.var: ref {.a: i32, .b: (i32,)} = var y
// CHECK:STDOUT: %y: ref {.a: i32, .b: (i32,)} = bind_name y, %y.var
// CHECK:STDOUT: %x.ref: ref {.a: i32, .b: (i32,)} = name_ref x, %x
+18 -19
View File
@@ -13,31 +13,30 @@ var y: {.a: i32, .b: i32} = x;
// CHECK:STDOUT: --- two_entries.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: type = ptr_type {.a: i32, .b: i32} [template]
// CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.3: i32 = int_literal 2 [template]
// CHECK:STDOUT: %.4: {.a: i32, .b: i32} = struct_value (%.2, %.3) [template]
// CHECK:STDOUT: %.5: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.6: i32 = int_literal 2 [template]
// CHECK:STDOUT: %.1: type = struct_type {.a: i32, .b: i32} [template]
// CHECK:STDOUT: %.2: type = ptr_type {.a: i32, .b: i32} [template]
// CHECK:STDOUT: %.3: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.4: i32 = int_literal 2 [template]
// CHECK:STDOUT: %.5: {.a: i32, .b: i32} = struct_value (%.3, %.4) [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace package, {.x = %x, .y = %y} [template]
// CHECK:STDOUT: %.loc7_25: type = struct_type {.a: i32, .b: i32} [template]
// CHECK:STDOUT: %.loc7_35: i32 = int_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %.loc7_43: i32 = int_literal 2 [template = constants.%.3]
// CHECK:STDOUT: %.loc7_25: type = struct_type {.a: i32, .b: i32} [template = constants.%.1]
// CHECK:STDOUT: %.loc7_35: i32 = int_literal 1 [template = constants.%.3]
// CHECK:STDOUT: %.loc7_43: i32 = int_literal 2 [template = constants.%.4]
// CHECK:STDOUT: %.loc7_44.1: {.a: i32, .b: i32} = struct_literal (%.loc7_35, %.loc7_43)
// CHECK:STDOUT: %.loc7_44.2: {.a: i32, .b: i32} = struct_value (%.loc7_35, %.loc7_43) [template = constants.%.4]
// CHECK:STDOUT: %.loc7_44.3: {.a: i32, .b: i32} = converted %.loc7_44.1, %.loc7_44.2 [template = constants.%.4]
// CHECK:STDOUT: %v: {.a: i32, .b: i32} = bind_name v, %.loc7_44.3 [template = constants.%.4]
// CHECK:STDOUT: %.loc8: type = struct_type {.a: i32, .b: i32} [template]
// CHECK:STDOUT: %v.ref: {.a: i32, .b: i32} = name_ref v, %v [template = constants.%.4]
// CHECK:STDOUT: %w: {.a: i32, .b: i32} = bind_name w, %v.ref [template = constants.%.4]
// CHECK:STDOUT: %.loc10_25: type = struct_type {.a: i32, .b: i32} [template]
// CHECK:STDOUT: %.loc7_44.2: {.a: i32, .b: i32} = struct_value (%.loc7_35, %.loc7_43) [template = constants.%.5]
// CHECK:STDOUT: %.loc7_44.3: {.a: i32, .b: i32} = converted %.loc7_44.1, %.loc7_44.2 [template = constants.%.5]
// CHECK:STDOUT: %v: {.a: i32, .b: i32} = bind_name v, %.loc7_44.3 [template = constants.%.5]
// CHECK:STDOUT: %.loc8: type = struct_type {.a: i32, .b: i32} [template = constants.%.1]
// CHECK:STDOUT: %v.ref: {.a: i32, .b: i32} = name_ref v, %v [template = constants.%.5]
// CHECK:STDOUT: %w: {.a: i32, .b: i32} = bind_name w, %v.ref [template = constants.%.5]
// CHECK:STDOUT: %.loc10_25: type = struct_type {.a: i32, .b: i32} [template = constants.%.1]
// CHECK:STDOUT: %x.var: ref {.a: i32, .b: i32} = var x
// CHECK:STDOUT: %x: ref {.a: i32, .b: i32} = bind_name x, %x.var
// CHECK:STDOUT: %.loc10_35: i32 = int_literal 1 [template = constants.%.5]
// CHECK:STDOUT: %.loc10_43: i32 = int_literal 2 [template = constants.%.6]
// CHECK:STDOUT: %.loc10_35: i32 = int_literal 1 [template = constants.%.3]
// CHECK:STDOUT: %.loc10_43: i32 = int_literal 2 [template = constants.%.4]
// CHECK:STDOUT: %.loc10_44.1: {.a: i32, .b: i32} = struct_literal (%.loc10_35, %.loc10_43)
// CHECK:STDOUT: %.loc10_44.2: ref i32 = struct_access %x.var, element0
// CHECK:STDOUT: %.loc10_44.3: init i32 = initialize_from %.loc10_35 to %.loc10_44.2
@@ -46,7 +45,7 @@ var y: {.a: i32, .b: i32} = x;
// CHECK:STDOUT: %.loc10_44.6: init {.a: i32, .b: i32} = struct_init (%.loc10_44.3, %.loc10_44.5) to %x.var
// CHECK:STDOUT: %.loc10_44.7: init {.a: i32, .b: i32} = converted %.loc10_44.1, %.loc10_44.6
// CHECK:STDOUT: assign %x.var, %.loc10_44.7
// CHECK:STDOUT: %.loc11_25: type = struct_type {.a: i32, .b: i32} [template]
// CHECK:STDOUT: %.loc11_25: type = struct_type {.a: i32, .b: i32} [template = constants.%.1]
// CHECK:STDOUT: %y.var: ref {.a: i32, .b: i32} = var y
// CHECK:STDOUT: %y: ref {.a: i32, .b: i32} = bind_name y, %y.var
// CHECK:STDOUT: %x.ref: ref {.a: i32, .b: i32} = name_ref x, %x