Skip to content

Commit

Permalink
Name empty tuples distinctly in SemIR. (#4503)
Browse files Browse the repository at this point in the history
Building on #4502, give empty tuple values a distinct name, and also
explicitly name tuple types (previously values but not types were
named).
  • Loading branch information
jonmeow authored Nov 8, 2024
1 parent bbeb66b commit 10e256a
Show file tree
Hide file tree
Showing 585 changed files with 14,353 additions and 14,343 deletions.
2 changes: 1 addition & 1 deletion toolchain/check/testdata/alias/fail_bool_value.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let a_test: bool = a;
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: bool = bool_literal false [template]
// CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
// CHECK:STDOUT: %.2: type = tuple_type () [template]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
// CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
Expand Down
2 changes: 1 addition & 1 deletion toolchain/check/testdata/alias/fail_builtins.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ alias b = bool;
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
// CHECK:STDOUT: %.1: type = tuple_type () [template]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
// CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
// CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
// CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ let d: c = {};
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
// CHECK:STDOUT: %.3: type = tuple_type () [template]
// CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
// CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
// CHECK:STDOUT: %struct: %C = struct_value () [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
Expand Down
18 changes: 9 additions & 9 deletions toolchain/check/testdata/alias/no_prelude/export_name.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ var d: D* = &c;
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
// CHECK:STDOUT: %.3: type = tuple_type () [template]
// CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
// CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
// CHECK:STDOUT: %struct: %C = struct_value () [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
Expand Down Expand Up @@ -224,10 +224,10 @@ var d: D* = &c;
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
// CHECK:STDOUT: %.3: type = tuple_type () [template]
// CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
// CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
// CHECK:STDOUT: %struct: %C = struct_value () [template]
// CHECK:STDOUT: %.5: type = ptr_type %C [template]
// CHECK:STDOUT: %.4: type = ptr_type %C [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
Expand All @@ -248,9 +248,9 @@ var d: D* = &c;
// CHECK:STDOUT: %c.var: ref %C = var c
// CHECK:STDOUT: %c: ref %C = bind_name c, %c.var
// CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.1 [template = constants.%C]
// CHECK:STDOUT: %.loc8: type = ptr_type %C [template = constants.%.5]
// CHECK:STDOUT: %d.var: ref %.5 = var d
// CHECK:STDOUT: %d: ref %.5 = bind_name d, %d.var
// CHECK:STDOUT: %.loc8: type = ptr_type %C [template = constants.%.4]
// CHECK:STDOUT: %d.var: ref %.4 = var d
// CHECK:STDOUT: %d: ref %.4 = bind_name d, %d.var
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @C {
Expand All @@ -265,7 +265,7 @@ var d: D* = &c;
// CHECK:STDOUT: %.loc7_14: init %C = converted %.loc7_13.1, %.loc7_13.2 [template = constants.%struct]
// CHECK:STDOUT: assign file.%c.var, %.loc7_14
// CHECK:STDOUT: %c.ref: ref %C = name_ref c, file.%c
// CHECK:STDOUT: %.loc8: %.5 = addr_of %c.ref
// CHECK:STDOUT: %.loc8: %.4 = addr_of %c.ref
// CHECK:STDOUT: assign file.%d.var, %.loc8
// CHECK:STDOUT: return
// CHECK:STDOUT: }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ let c_var: c = d;
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
// CHECK:STDOUT: %D: type = class_type @D [template]
// CHECK:STDOUT: %.3: type = tuple_type () [template]
// CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
// CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
// CHECK:STDOUT: %struct: %D = struct_value () [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn F() -> {} {
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %F.type: type = fn_type @F [template]
// CHECK:STDOUT: %.2: type = tuple_type () [template]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
// CHECK:STDOUT: %F: %F.type = struct_value () [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ alias b = C;
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
// CHECK:STDOUT: %.3: type = tuple_type () [template]
// CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
// CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
// CHECK:STDOUT: %struct: %C = struct_value () [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
Expand Down
40 changes: 20 additions & 20 deletions toolchain/check/testdata/alias/no_prelude/fail_not_constant.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ fn F() {
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %F.type: type = fn_type @F [template]
// CHECK:STDOUT: %.1: type = tuple_type () [template]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
// CHECK:STDOUT: %F: %F.type = struct_value () [template]
// CHECK:STDOUT: %tuple: %.1 = tuple_value () [template]
// CHECK:STDOUT: %.2: type = ptr_type %.1 [template]
// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
// CHECK:STDOUT: %.1: type = ptr_type %empty_tuple.type [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
Expand All @@ -36,25 +36,25 @@ fn F() {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %.loc12_11.1: %.1 = tuple_literal ()
// CHECK:STDOUT: %.loc12_11.2: type = converted %.loc12_11.1, constants.%.1 [template = constants.%.1]
// CHECK:STDOUT: %a.var: ref %.1 = var a
// CHECK:STDOUT: %a: ref %.1 = bind_name a, %a.var
// CHECK:STDOUT: %.loc12_16.1: %.1 = tuple_literal ()
// CHECK:STDOUT: %.loc12_16.2: init %.1 = tuple_init () to %a.var [template = constants.%tuple]
// CHECK:STDOUT: %.loc12_17: init %.1 = converted %.loc12_16.1, %.loc12_16.2 [template = constants.%tuple]
// CHECK:STDOUT: %.loc12_11.1: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %.loc12_11.2: type = converted %.loc12_11.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
// CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a
// CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var
// CHECK:STDOUT: %.loc12_16.1: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %.loc12_16.2: init %empty_tuple.type = tuple_init () to %a.var [template = constants.%empty_tuple]
// CHECK:STDOUT: %.loc12_17: init %empty_tuple.type = converted %.loc12_16.1, %.loc12_16.2 [template = constants.%empty_tuple]
// CHECK:STDOUT: assign %a.var, %.loc12_17
// CHECK:STDOUT: %.loc13_11: %.1 = tuple_literal ()
// CHECK:STDOUT: %.loc13_12.1: type = converted %.loc13_11, constants.%.1 [template = constants.%.1]
// CHECK:STDOUT: %.loc13_12.2: type = ptr_type %.1 [template = constants.%.2]
// CHECK:STDOUT: %b.var: ref %.2 = var b
// CHECK:STDOUT: %b: ref %.2 = bind_name b, %b.var
// CHECK:STDOUT: %a.ref: ref %.1 = name_ref a, %a
// CHECK:STDOUT: %.loc13_16: %.2 = addr_of %a.ref
// CHECK:STDOUT: %.loc13_11: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %.loc13_12.1: type = converted %.loc13_11, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
// CHECK:STDOUT: %.loc13_12.2: type = ptr_type %empty_tuple.type [template = constants.%.1]
// CHECK:STDOUT: %b.var: ref %.1 = var b
// CHECK:STDOUT: %b: ref %.1 = bind_name b, %b.var
// CHECK:STDOUT: %a.ref: ref %empty_tuple.type = name_ref a, %a
// CHECK:STDOUT: %.loc13_16: %.1 = addr_of %a.ref
// CHECK:STDOUT: assign %b.var, %.loc13_16
// CHECK:STDOUT: %b.ref: ref %.2 = name_ref b, %b
// CHECK:STDOUT: %.loc17_14: %.2 = bind_value %b.ref
// CHECK:STDOUT: %.loc17_13: ref %.1 = deref %.loc17_14
// CHECK:STDOUT: %b.ref: ref %.1 = name_ref b, %b
// CHECK:STDOUT: %.loc17_14: %.1 = bind_value %b.ref
// CHECK:STDOUT: %.loc17_13: ref %empty_tuple.type = deref %.loc17_14
// CHECK:STDOUT: %c: <error> = bind_alias c, <error> [template = <error>]
// CHECK:STDOUT: return
// CHECK:STDOUT: }
Expand Down
66 changes: 33 additions & 33 deletions toolchain/check/testdata/alias/no_prelude/import.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -171,42 +171,42 @@ var c: () = a_alias_alias;
// CHECK:STDOUT: --- var1.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: type = tuple_type () [template]
// CHECK:STDOUT: %tuple: %.1 = tuple_value () [template]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .a = %a
// CHECK:STDOUT: .a_alias = %a_alias
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc4_9.1: %.1 = tuple_literal ()
// CHECK:STDOUT: %.loc4_9.2: type = converted %.loc4_9.1, constants.%.1 [template = constants.%.1]
// CHECK:STDOUT: %a.var: ref %.1 = var a
// CHECK:STDOUT: %a: ref %.1 = bind_name a, %a.var
// CHECK:STDOUT: %a.ref: ref %.1 = name_ref a, %a
// CHECK:STDOUT: %a_alias: ref %.1 = bind_alias a_alias, %a
// CHECK:STDOUT: %.loc4_9.1: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %.loc4_9.2: type = converted %.loc4_9.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
// CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a
// CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var
// CHECK:STDOUT: %a.ref: ref %empty_tuple.type = name_ref a, %a
// CHECK:STDOUT: %a_alias: ref %empty_tuple.type = bind_alias a_alias, %a
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %.loc4_14.1: %.1 = tuple_literal ()
// CHECK:STDOUT: %.loc4_14.2: init %.1 = tuple_init () to file.%a.var [template = constants.%tuple]
// CHECK:STDOUT: %.loc4_15: init %.1 = converted %.loc4_14.1, %.loc4_14.2 [template = constants.%tuple]
// CHECK:STDOUT: %.loc4_14.1: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %.loc4_14.2: init %empty_tuple.type = tuple_init () to file.%a.var [template = constants.%empty_tuple]
// CHECK:STDOUT: %.loc4_15: init %empty_tuple.type = converted %.loc4_14.1, %.loc4_14.2 [template = constants.%empty_tuple]
// CHECK:STDOUT: assign file.%a.var, %.loc4_15
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- var2.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: type = tuple_type () [template]
// CHECK:STDOUT: %tuple: %.1 = tuple_value () [template]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %import_ref.1 = import_ref Main//var1, inst+5, unloaded
// CHECK:STDOUT: %import_ref.2: ref %.1 = import_ref Main//var1, inst+12, loaded
// CHECK:STDOUT: %import_ref.2: ref %empty_tuple.type = import_ref Main//var1, inst+12, loaded
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
Expand All @@ -217,32 +217,32 @@ var c: () = a_alias_alias;
// CHECK:STDOUT: .b = %b
// CHECK:STDOUT: }
// CHECK:STDOUT: %default.import = import <invalid>
// CHECK:STDOUT: %a_alias.ref: ref %.1 = name_ref a_alias, imports.%import_ref.2
// CHECK:STDOUT: %a_alias_alias: ref %.1 = bind_alias a_alias_alias, imports.%import_ref.2
// CHECK:STDOUT: %.loc8_9.1: %.1 = tuple_literal ()
// CHECK:STDOUT: %.loc8_9.2: type = converted %.loc8_9.1, constants.%.1 [template = constants.%.1]
// CHECK:STDOUT: %b.var: ref %.1 = var b
// CHECK:STDOUT: %b: ref %.1 = bind_name b, %b.var
// CHECK:STDOUT: %a_alias.ref: ref %empty_tuple.type = name_ref a_alias, imports.%import_ref.2
// CHECK:STDOUT: %a_alias_alias: ref %empty_tuple.type = bind_alias a_alias_alias, imports.%import_ref.2
// CHECK:STDOUT: %.loc8_9.1: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %.loc8_9.2: type = converted %.loc8_9.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
// CHECK:STDOUT: %b.var: ref %empty_tuple.type = var b
// CHECK:STDOUT: %b: ref %empty_tuple.type = bind_name b, %b.var
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %a_alias.ref: ref %.1 = name_ref a_alias, imports.%import_ref.2
// CHECK:STDOUT: %.loc8_13: init %.1 = tuple_init () to file.%b.var [template = constants.%tuple]
// CHECK:STDOUT: %.loc8_20: init %.1 = converted %a_alias.ref, %.loc8_13 [template = constants.%tuple]
// CHECK:STDOUT: %a_alias.ref: ref %empty_tuple.type = name_ref a_alias, imports.%import_ref.2
// CHECK:STDOUT: %.loc8_13: init %empty_tuple.type = tuple_init () to file.%b.var [template = constants.%empty_tuple]
// CHECK:STDOUT: %.loc8_20: init %empty_tuple.type = converted %a_alias.ref, %.loc8_13 [template = constants.%empty_tuple]
// CHECK:STDOUT: assign file.%b.var, %.loc8_20
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_var3.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: type = tuple_type () [template]
// CHECK:STDOUT: %tuple: %.1 = tuple_value () [template]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %import_ref.1: ref %.1 = import_ref Main//var2, inst+6, loaded [template = <error>]
// CHECK:STDOUT: %import_ref.1: ref %empty_tuple.type = import_ref Main//var2, inst+6, loaded [template = <error>]
// CHECK:STDOUT: %import_ref.2 = import_ref Main//var2, inst+10, unloaded
// CHECK:STDOUT: }
// CHECK:STDOUT:
Expand All @@ -253,17 +253,17 @@ var c: () = a_alias_alias;
// CHECK:STDOUT: .c = %c
// CHECK:STDOUT: }
// CHECK:STDOUT: %default.import = import <invalid>
// CHECK:STDOUT: %.loc10_9.1: %.1 = tuple_literal ()
// CHECK:STDOUT: %.loc10_9.2: type = converted %.loc10_9.1, constants.%.1 [template = constants.%.1]
// CHECK:STDOUT: %c.var: ref %.1 = var c
// CHECK:STDOUT: %c: ref %.1 = bind_name c, %c.var
// CHECK:STDOUT: %.loc10_9.1: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %.loc10_9.2: type = converted %.loc10_9.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
// CHECK:STDOUT: %c.var: ref %empty_tuple.type = var c
// CHECK:STDOUT: %c: ref %empty_tuple.type = bind_name c, %c.var
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %a_alias_alias.ref: ref %.1 = name_ref a_alias_alias, imports.%import_ref.1 [template = <error>]
// CHECK:STDOUT: %.loc10_13: init %.1 = tuple_init () to file.%c.var [template = constants.%tuple]
// CHECK:STDOUT: %.loc10_26: init %.1 = converted %a_alias_alias.ref, %.loc10_13 [template = constants.%tuple]
// CHECK:STDOUT: %a_alias_alias.ref: ref %empty_tuple.type = name_ref a_alias_alias, imports.%import_ref.1 [template = <error>]
// CHECK:STDOUT: %.loc10_13: init %empty_tuple.type = tuple_init () to file.%c.var [template = constants.%empty_tuple]
// CHECK:STDOUT: %.loc10_26: init %empty_tuple.type = converted %a_alias_alias.ref, %.loc10_13 [template = constants.%empty_tuple]
// CHECK:STDOUT: assign file.%c.var, %.loc10_26
// CHECK:STDOUT: return
// CHECK:STDOUT: }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ var inst: Test.A = {};
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %.1: type = struct_type {} [template]
// CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
// CHECK:STDOUT: %.3: type = tuple_type () [template]
// CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
// CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
// CHECK:STDOUT: %struct: %C = struct_value () [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
Expand Down
Loading

0 comments on commit 10e256a

Please sign in to comment.