Unify instruction naming between SemIR and LLVM IR (#3898)

Factor out `SemIR::InstNamer` and also use it when lowering to LLVM IR.
Automatically name all instructions created with our `IRBuilder` based
on the name computed by the `InstNamer`, and likewise name basic blocks
using the label generated by the `InstNamer`.

Move some of the existing naming logic out from lower into `InstNamer`
so that it's also used in SemIR. In particular, we now name call
instructions after their callee, or after the builtin name for calls to
builtins.

Computing and adding these names isn't completely free. This instruction
naming is designed to be optional, so that we can turn it off for builds
where the LLVM IR will only be converted to assembly and won't be seen
by a human, but so far it's enabled unconditionally. We can tune that
later as needed.
This commit is contained in:
Richard Smith
2024-04-19 02:19:30 +00:00
committed by GitHub
parent 5964795f34
commit 3776c068de
225 changed files with 2835 additions and 2455 deletions
+2 -2
View File
@@ -35,8 +35,8 @@ var arr: [i32; Add(1, 2)];
// CHECK:STDOUT: %Add.ref: <function> = name_ref Add, %Add [template = %Add]
// CHECK:STDOUT: %.loc9_20: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %.loc9_23: i32 = int_literal 2 [template = constants.%.2]
// CHECK:STDOUT: %.loc9_19: init i32 = call %Add.ref(%.loc9_20, %.loc9_23) [template = constants.%.3]
// CHECK:STDOUT: %.loc9_25: type = array_type %.loc9_19, i32 [template = constants.%.4]
// CHECK:STDOUT: %int.sadd: init i32 = call %Add.ref(%.loc9_20, %.loc9_23) [template = constants.%.3]
// CHECK:STDOUT: %.loc9_25: type = array_type %int.sadd, i32 [template = constants.%.4]
// CHECK:STDOUT: %arr.var: ref [i32; 3] = var arr
// CHECK:STDOUT: %arr: ref [i32; 3] = bind_name arr, %arr.var
// CHECK:STDOUT: }
@@ -108,9 +108,9 @@ var arr: [i32; 1 + 2] = (3, 4, 3 + 4);
// CHECK:STDOUT: %import_ref.5: type = import_ref ir3, inst+1, loc_36 [template = constants.%.1]
// CHECK:STDOUT: %import_ref.6 = import_ref ir3, inst+18, unloaded
// CHECK:STDOUT: %.1: <function> = interface_witness_access @impl.%.1, element0 [template = @impl.%Op]
// CHECK:STDOUT: %.loc10_18.1: <bound method> = bound_method %.loc10_16, %.1 [template = constants.%.7]
// CHECK:STDOUT: %.loc10_18.2: init i32 = call %.loc10_18.1(%.loc10_16, %.loc10_20) [template = constants.%.8]
// CHECK:STDOUT: %.loc10_21: type = array_type %.loc10_18.2, i32 [template = constants.%.9]
// CHECK:STDOUT: %.loc10_18: <bound method> = bound_method %.loc10_16, %.1 [template = constants.%.7]
// CHECK:STDOUT: %int.sadd: init i32 = call %.loc10_18(%.loc10_16, %.loc10_20) [template = constants.%.8]
// CHECK:STDOUT: %.loc10_21: type = array_type %int.sadd, i32 [template = constants.%.9]
// CHECK:STDOUT: %arr.var: ref [i32; 3] = var arr
// CHECK:STDOUT: %arr: ref [i32; 3] = bind_name arr, %arr.var
// CHECK:STDOUT: %import_ref.7: type = import_ref ir3, inst+1, loc_47 [template = constants.%.1]
@@ -152,9 +152,9 @@ var arr: [i32; 1 + 2] = (3, 4, 3 + 4);
// CHECK:STDOUT: %.loc10_32: i32 = int_literal 3 [template = constants.%.8]
// CHECK:STDOUT: %.loc10_36: i32 = int_literal 4 [template = constants.%.11]
// CHECK:STDOUT: %.1: <function> = interface_witness_access @impl.%.1, element0 [template = @impl.%Op]
// CHECK:STDOUT: %.loc10_34.1: <bound method> = bound_method %.loc10_32, %.1 [template = constants.%.12]
// CHECK:STDOUT: %.loc10_34.2: init i32 = call %.loc10_34.1(%.loc10_32, %.loc10_36) [template = constants.%.13]
// CHECK:STDOUT: %.loc10_37.1: (i32, i32, i32) = tuple_literal (%.loc10_26, %.loc10_29, %.loc10_34.2)
// CHECK:STDOUT: %.loc10_34: <bound method> = bound_method %.loc10_32, %.1 [template = constants.%.12]
// CHECK:STDOUT: %int.sadd: init i32 = call %.loc10_34(%.loc10_32, %.loc10_36) [template = constants.%.13]
// CHECK:STDOUT: %.loc10_37.1: (i32, i32, i32) = tuple_literal (%.loc10_26, %.loc10_29, %int.sadd)
// CHECK:STDOUT: %.loc10_37.2: i32 = int_literal 0 [template = constants.%.15]
// CHECK:STDOUT: %.loc10_37.3: ref i32 = array_index file.%arr.var, %.loc10_37.2
// CHECK:STDOUT: %.loc10_37.4: init i32 = initialize_from %.loc10_26 to %.loc10_37.3 [template = constants.%.8]
@@ -163,7 +163,7 @@ var arr: [i32; 1 + 2] = (3, 4, 3 + 4);
// CHECK:STDOUT: %.loc10_37.7: init i32 = initialize_from %.loc10_29 to %.loc10_37.6 [template = constants.%.11]
// CHECK:STDOUT: %.loc10_37.8: i32 = int_literal 2 [template = constants.%.4]
// CHECK:STDOUT: %.loc10_37.9: ref i32 = array_index file.%arr.var, %.loc10_37.8
// CHECK:STDOUT: %.loc10_37.10: init i32 = initialize_from %.loc10_34.2 to %.loc10_37.9 [template = constants.%.13]
// CHECK:STDOUT: %.loc10_37.10: init i32 = initialize_from %int.sadd to %.loc10_37.9 [template = constants.%.13]
// CHECK:STDOUT: %.loc10_37.11: init [i32; 3] = array_init (%.loc10_37.4, %.loc10_37.7, %.loc10_37.10) to file.%arr.var [template = constants.%.16]
// CHECK:STDOUT: %.loc10_38: init [i32; 3] = converted %.loc10_37.1, %.loc10_37.11 [template = constants.%.16]
// CHECK:STDOUT: assign file.%arr.var, %.loc10_38
+2 -2
View File
@@ -59,8 +59,8 @@ var arr: [i32; Core.Add(1, 2)] = (1, 2, 3);
// CHECK:STDOUT: %Add.ref: <function> = name_ref Add, %import_ref [template = imports.%Add]
// CHECK:STDOUT: %.loc4_25: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %.loc4_28: i32 = int_literal 2 [template = constants.%.2]
// CHECK:STDOUT: %.loc4_24: init i32 = call %Add.ref(%.loc4_25, %.loc4_28) [template = constants.%.3]
// CHECK:STDOUT: %.loc4_30: type = array_type %.loc4_24, i32 [template = constants.%.4]
// CHECK:STDOUT: %int.sadd: init i32 = call %Add.ref(%.loc4_25, %.loc4_28) [template = constants.%.3]
// CHECK:STDOUT: %.loc4_30: type = array_type %int.sadd, i32 [template = constants.%.4]
// CHECK:STDOUT: %arr.var: ref [i32; 3] = var arr
// CHECK:STDOUT: %arr: ref [i32; 3] = bind_name arr, %arr.var
// CHECK:STDOUT: }
+2 -2
View File
@@ -46,8 +46,8 @@ var arr: [i32; 1.(I.F)(2)];
// CHECK:STDOUT: %.1: <function> = interface_witness_access @impl.%.1, element0 [template = @impl.%F]
// CHECK:STDOUT: %.loc15_17: <bound method> = bound_method %.loc15_16, %.1 [template = constants.%.6]
// CHECK:STDOUT: %.loc15_24: i32 = int_literal 2 [template = constants.%.7]
// CHECK:STDOUT: %.loc15_23: init i32 = call %.loc15_17(%.loc15_16, %.loc15_24) [template = constants.%.8]
// CHECK:STDOUT: %.loc15_26: type = array_type %.loc15_23, i32 [template = constants.%.9]
// CHECK:STDOUT: %int.sadd: init i32 = call %.loc15_17(%.loc15_16, %.loc15_24) [template = constants.%.8]
// CHECK:STDOUT: %.loc15_26: type = array_type %int.sadd, i32 [template = constants.%.9]
// CHECK:STDOUT: %arr.var: ref [i32; 3] = var arr
// CHECK:STDOUT: %arr: ref [i32; 3] = bind_name arr, %arr.var
// CHECK:STDOUT: }
+2 -2
View File
@@ -45,8 +45,8 @@ fn Main() {
// CHECK:STDOUT: %b.var: ref i32 = var b
// CHECK:STDOUT: %b: ref i32 = bind_name b, %b.var
// CHECK:STDOUT: %B.ref: <function> = name_ref B, file.%B [template = file.%A]
// CHECK:STDOUT: %.loc12: init i32 = call %B.ref()
// CHECK:STDOUT: assign %b.var, %.loc12
// CHECK:STDOUT: %A.call: init i32 = call %B.ref()
// CHECK:STDOUT: assign %b.var, %A.call
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
+2 -2
View File
@@ -50,8 +50,8 @@ fn Main() {
// CHECK:STDOUT: %Echo.ref: <function> = name_ref Echo, file.%Echo [template = file.%Echo]
// CHECK:STDOUT: %.loc12_9.1: {} = struct_literal ()
// CHECK:STDOUT: %.loc12_9.2: {} = struct_value () [template = constants.%.3]
// CHECK:STDOUT: %.loc12_7.1: {} = converted %.loc12_9.1, %.loc12_9.2 [template = constants.%.3]
// CHECK:STDOUT: %.loc12_7.2: init {} = call %Echo.ref(%.loc12_7.1)
// CHECK:STDOUT: %.loc12_7: {} = converted %.loc12_9.1, %.loc12_9.2 [template = constants.%.3]
// CHECK:STDOUT: %Echo.call: init {} = call %Echo.ref(%.loc12_7)
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
+2 -2
View File
@@ -49,8 +49,8 @@ fn Main() {
// CHECK:STDOUT: %Echo.ref: <function> = name_ref Echo, file.%Echo [template = file.%Echo]
// CHECK:STDOUT: %.loc12_9.1: () = tuple_literal ()
// CHECK:STDOUT: %.loc12_9.2: () = tuple_value () [template = constants.%.2]
// CHECK:STDOUT: %.loc12_7.1: () = converted %.loc12_9.1, %.loc12_9.2 [template = constants.%.2]
// CHECK:STDOUT: %.loc12_7.2: init () = call %Echo.ref(%.loc12_7.1)
// CHECK:STDOUT: %.loc12_7: () = converted %.loc12_9.1, %.loc12_9.2 [template = constants.%.2]
// CHECK:STDOUT: %Echo.call: init () = call %Echo.ref(%.loc12_7)
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -109,23 +109,23 @@ fn Main() {
// CHECK:STDOUT: fn @Main() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %Run0.ref.loc19: <function> = name_ref Run0, file.%Run0 [template = file.%Run0]
// CHECK:STDOUT: %.loc19_8: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %.loc19_7: init () = call %Run0.ref.loc19(<invalid>) [template = <error>]
// CHECK:STDOUT: %.loc19: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %Run0.call.loc19: init () = call %Run0.ref.loc19(<invalid>) [template = <error>]
// CHECK:STDOUT: %Run0.ref.loc27: <function> = name_ref Run0, file.%Run0 [template = file.%Run0]
// CHECK:STDOUT: %.loc27_8: i32 = int_literal 0 [template = constants.%.3]
// CHECK:STDOUT: %.loc27_11: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %.loc27_7: init () = call %Run0.ref.loc27(<invalid>) [template = <error>]
// CHECK:STDOUT: %Run0.call.loc27: init () = call %Run0.ref.loc27(<invalid>) [template = <error>]
// CHECK:STDOUT: %Run1.ref.loc36: <function> = name_ref Run1, file.%Run1 [template = file.%Run1]
// CHECK:STDOUT: %.loc36: init () = call %Run1.ref.loc36(<invalid>) [template = <error>]
// CHECK:STDOUT: %Run1.call.loc36: init () = call %Run1.ref.loc36(<invalid>) [template = <error>]
// CHECK:STDOUT: %Run1.ref.loc44: <function> = name_ref Run1, file.%Run1 [template = file.%Run1]
// CHECK:STDOUT: %.loc44_8: i32 = int_literal 0 [template = constants.%.3]
// CHECK:STDOUT: %.loc44_11: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %.loc44_7: init () = call %Run1.ref.loc44(<invalid>) [template = <error>]
// CHECK:STDOUT: %Run1.call.loc44: init () = call %Run1.ref.loc44(<invalid>) [template = <error>]
// CHECK:STDOUT: %Run2.ref.loc53: <function> = name_ref Run2, file.%Run2 [template = file.%Run2]
// CHECK:STDOUT: %.loc53: init () = call %Run2.ref.loc53(<invalid>) [template = <error>]
// CHECK:STDOUT: %Run2.call.loc53: init () = call %Run2.ref.loc53(<invalid>) [template = <error>]
// CHECK:STDOUT: %Run2.ref.loc60: <function> = name_ref Run2, file.%Run2 [template = file.%Run2]
// CHECK:STDOUT: %.loc60_8: i32 = int_literal 0 [template = constants.%.3]
// CHECK:STDOUT: %.loc60_7: init () = call %Run2.ref.loc60(<invalid>) [template = <error>]
// CHECK:STDOUT: %.loc60: i32 = int_literal 0 [template = constants.%.3]
// CHECK:STDOUT: %Run2.call.loc60: init () = call %Run2.ref.loc60(<invalid>) [template = <error>]
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -45,8 +45,8 @@ fn F() {
// CHECK:STDOUT: fn @F() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %G.ref: <function> = name_ref G, file.%G [template = file.%G]
// CHECK:STDOUT: %.loc16_5: f64 = real_literal 10e-1 [template = constants.%.1]
// CHECK:STDOUT: %.loc16_4: init () = call %G.ref(<invalid>) [template = <error>]
// CHECK:STDOUT: %.loc16: f64 = real_literal 10e-1 [template = constants.%.1]
// CHECK:STDOUT: %G.call: init () = call %G.ref(<invalid>) [template = <error>]
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -43,7 +43,7 @@ fn Run() {
// CHECK:STDOUT: %x.var: ref i32 = var x
// CHECK:STDOUT: %x: ref i32 = bind_name x, %x.var
// CHECK:STDOUT: %Foo.ref: <function> = name_ref Foo, file.%Foo [template = file.%Foo]
// CHECK:STDOUT: %.loc13: init f64 = call %Foo.ref()
// CHECK:STDOUT: %Foo.call: init f64 = call %Foo.ref()
// CHECK:STDOUT: assign %x.var, <error>
// CHECK:STDOUT: return
// CHECK:STDOUT: }
+3 -3
View File
@@ -44,9 +44,9 @@ fn Main() {
// CHECK:STDOUT: %b.var: ref i32 = var b
// CHECK:STDOUT: %b: ref i32 = bind_name b, %b.var
// CHECK:STDOUT: %Echo.ref: <function> = name_ref Echo, file.%Echo [template = file.%Echo]
// CHECK:STDOUT: %.loc12_21: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %.loc12_20: init i32 = call %Echo.ref(%.loc12_21)
// CHECK:STDOUT: assign %b.var, %.loc12_20
// CHECK:STDOUT: %.loc12: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %Echo.call: init i32 = call %Echo.ref(%.loc12)
// CHECK:STDOUT: assign %b.var, %Echo.call
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -62,7 +62,7 @@ fn Main() {
// CHECK:STDOUT: %.loc12_10.1: ref i32 = tuple_index %x.ref, %.loc12_9
// CHECK:STDOUT: %.loc12_13: i32 = int_literal 6 [template = constants.%.6]
// CHECK:STDOUT: %.loc12_10.2: i32 = bind_value %.loc12_10.1
// CHECK:STDOUT: %.loc12_6: init () = call %Foo.ref(%.loc12_10.2, %.loc12_13)
// CHECK:STDOUT: %Foo.call: init () = call %Foo.ref(%.loc12_10.2, %.loc12_13)
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
+2 -2
View File
@@ -39,8 +39,8 @@ fn Main() {
// CHECK:STDOUT: fn @Main() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %Foo.ref: <function> = name_ref Foo, file.%Foo [template = file.%Foo]
// CHECK:STDOUT: %.loc10_7: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %.loc10_6: init () = call %Foo.ref(%.loc10_7)
// CHECK:STDOUT: %.loc10: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %Foo.call: init () = call %Foo.ref(%.loc10)
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -40,11 +40,11 @@ fn Main() {
// CHECK:STDOUT: fn @Main() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %Foo.ref.loc10: <function> = name_ref Foo, file.%Foo [template = file.%Foo]
// CHECK:STDOUT: %.loc10_7: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %.loc10_6: init () = call %Foo.ref.loc10(%.loc10_7)
// CHECK:STDOUT: %.loc10: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %Foo.call.loc10: init () = call %Foo.ref.loc10(%.loc10)
// CHECK:STDOUT: %Foo.ref.loc11: <function> = name_ref Foo, file.%Foo [template = file.%Foo]
// CHECK:STDOUT: %.loc11_7: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %.loc11_6: init () = call %Foo.ref.loc11(%.loc11_7)
// CHECK:STDOUT: %.loc11: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %Foo.call.loc11: init () = call %Foo.ref.loc11(%.loc11)
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
+1 -1
View File
@@ -44,7 +44,7 @@ fn Main() {
// CHECK:STDOUT: %Foo.ref: <function> = name_ref Foo, file.%Foo [template = file.%Foo]
// CHECK:STDOUT: %.loc10_7: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %.loc10_10: i32 = int_literal 2 [template = constants.%.2]
// CHECK:STDOUT: %.loc10_6: init () = call %Foo.ref(%.loc10_7, %.loc10_10)
// CHECK:STDOUT: %Foo.call: init () = call %Foo.ref(%.loc10_7, %.loc10_10)
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -45,11 +45,11 @@ fn Main() {
// CHECK:STDOUT: %Foo.ref.loc10: <function> = name_ref Foo, file.%Foo [template = file.%Foo]
// CHECK:STDOUT: %.loc10_7: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %.loc10_10: i32 = int_literal 2 [template = constants.%.2]
// CHECK:STDOUT: %.loc10_6: init () = call %Foo.ref.loc10(%.loc10_7, %.loc10_10)
// CHECK:STDOUT: %Foo.call.loc10: init () = call %Foo.ref.loc10(%.loc10_7, %.loc10_10)
// CHECK:STDOUT: %Foo.ref.loc11: <function> = name_ref Foo, file.%Foo [template = file.%Foo]
// CHECK:STDOUT: %.loc11_7: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %.loc11_10: i32 = int_literal 2 [template = constants.%.2]
// CHECK:STDOUT: %.loc11_6: init () = call %Foo.ref.loc11(%.loc11_7, %.loc11_10)
// CHECK:STDOUT: %Foo.call.loc11: init () = call %Foo.ref.loc11(%.loc11_7, %.loc11_10)
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
+1 -1
View File
@@ -35,7 +35,7 @@ fn Main() {
// CHECK:STDOUT: fn @Main() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %Foo.ref: <function> = name_ref Foo, file.%Foo [template = file.%Foo]
// CHECK:STDOUT: %.loc10: init () = call %Foo.ref()
// CHECK:STDOUT: %Foo.call: init () = call %Foo.ref()
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -40,8 +40,8 @@ fn Main() {
// CHECK:STDOUT: %b.var: ref () = var b
// CHECK:STDOUT: %b: ref () = bind_name b, %b.var
// CHECK:STDOUT: %MakeImplicitEmptyTuple.ref: <function> = name_ref MakeImplicitEmptyTuple, file.%MakeImplicitEmptyTuple [template = file.%MakeImplicitEmptyTuple]
// CHECK:STDOUT: %.loc11_37: init () = call %MakeImplicitEmptyTuple.ref()
// CHECK:STDOUT: assign %b.var, %.loc11_37
// CHECK:STDOUT: %MakeImplicitEmptyTuple.call: init () = call %MakeImplicitEmptyTuple.ref()
// CHECK:STDOUT: assign %b.var, %MakeImplicitEmptyTuple.call
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -131,9 +131,9 @@ fn CallFAndGIncomplete() {
// CHECK:STDOUT: fn @Call() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %ReturnCUsed.ref: <function> = name_ref ReturnCUsed, file.%ReturnCUsed [template = file.%ReturnCUsed]
// CHECK:STDOUT: %.loc23: init <error> = call %ReturnCUsed.ref()
// CHECK:STDOUT: %ReturnCUsed.call: init <error> = call %ReturnCUsed.ref()
// CHECK:STDOUT: %ReturnDUsed.ref: <function> = name_ref ReturnDUsed, file.%ReturnDUsed [template = file.%ReturnDUsed]
// CHECK:STDOUT: %.loc34: init <error> = call %ReturnDUsed.ref()
// CHECK:STDOUT: %ReturnDUsed.call: init <error> = call %ReturnDUsed.ref()
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -182,16 +182,16 @@ fn CallFAndGIncomplete() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %C.decl: invalid = class_decl @C [template = constants.%C] {}
// CHECK:STDOUT: %ReturnCUnused.ref: <function> = name_ref ReturnCUnused, file.%import_ref.3 [template = imports.%ReturnCUnused]
// CHECK:STDOUT: %.loc22: init <error> = call %ReturnCUnused.ref()
// CHECK:STDOUT: %ReturnCUnused.call: init <error> = call %ReturnCUnused.ref()
// CHECK:STDOUT: %ReturnCUsed.ref: <function> = name_ref ReturnCUsed, file.%import_ref.4 [template = imports.%ReturnCUsed]
// CHECK:STDOUT: %.loc23: init <error> = call %ReturnCUsed.ref()
// CHECK:STDOUT: %ReturnCUsed.call: init <error> = call %ReturnCUsed.ref()
// CHECK:STDOUT: %D.decl: invalid = class_decl @D [template = constants.%D] {}
// CHECK:STDOUT: %ReturnDUnused.ref: <function> = name_ref ReturnDUnused, file.%import_ref.5 [template = imports.%ReturnDUnused]
// CHECK:STDOUT: %.loc24_16.1: ref D = temporary_storage
// CHECK:STDOUT: %.loc24_16.2: init D = call %ReturnDUnused.ref() to %.loc24_16.1
// CHECK:STDOUT: %.loc24_16.3: ref D = temporary %.loc24_16.1, %.loc24_16.2
// CHECK:STDOUT: %ReturnDUnused.call: init D = call %ReturnDUnused.ref() to %.loc24_16.1
// CHECK:STDOUT: %.loc24_16.2: ref D = temporary %.loc24_16.1, %ReturnDUnused.call
// CHECK:STDOUT: %ReturnDUsed.ref: <function> = name_ref ReturnDUsed, file.%import_ref.6 [template = imports.%ReturnDUsed]
// CHECK:STDOUT: %.loc25: init <error> = call %ReturnDUsed.ref()
// CHECK:STDOUT: %ReturnDUsed.call: init <error> = call %ReturnDUsed.ref()
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
+66 -66
View File
@@ -353,26 +353,26 @@ import library "extern_api";
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %A.ref: <function> = name_ref A, file.%import_ref.1 [template = imports.%A]
// CHECK:STDOUT: %.loc6: init () = call %A.ref()
// CHECK:STDOUT: assign file.%a.var, %.loc6
// CHECK:STDOUT: %A.call: init () = call %A.ref()
// CHECK:STDOUT: assign file.%a.var, %A.call
// CHECK:STDOUT: %B.ref: <function> = name_ref B, file.%import_ref.2 [template = imports.%B]
// CHECK:STDOUT: %.loc7_16: i32 = int_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %.loc7_15: init i32 = call %B.ref(%.loc7_16)
// CHECK:STDOUT: assign file.%b.var, %.loc7_15
// CHECK:STDOUT: %.loc7: i32 = int_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %B.call: init i32 = call %B.ref(%.loc7)
// CHECK:STDOUT: assign file.%b.var, %B.call
// CHECK:STDOUT: %C.ref: <function> = name_ref C, file.%import_ref.3 [template = imports.%C]
// CHECK:STDOUT: %.loc8_23: i32 = int_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %.loc8_25.1: (i32,) = tuple_literal (%.loc8_23)
// CHECK:STDOUT: %.loc8_25.2: (i32,) = tuple_value (%.loc8_23) [template = constants.%.5]
// CHECK:STDOUT: %.loc8_21.1: (i32,) = converted %.loc8_25.1, %.loc8_25.2 [template = constants.%.5]
// CHECK:STDOUT: %.loc8_21.2: init {.c: i32} = call %C.ref(%.loc8_21.1)
// CHECK:STDOUT: assign file.%c.var, %.loc8_21.2
// CHECK:STDOUT: %.loc8_21: (i32,) = converted %.loc8_25.1, %.loc8_25.2 [template = constants.%.5]
// CHECK:STDOUT: %C.call: init {.c: i32} = call %C.ref(%.loc8_21)
// CHECK:STDOUT: assign file.%c.var, %C.call
// CHECK:STDOUT: %D.ref: <function> = name_ref D, file.%import_ref.4 [template = imports.%D]
// CHECK:STDOUT: %.loc9: init () = call %D.ref()
// CHECK:STDOUT: assign file.%d.var, %.loc9
// CHECK:STDOUT: %D.call: init () = call %D.ref()
// CHECK:STDOUT: assign file.%d.var, %D.call
// CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, file.%NS [template = file.%NS]
// CHECK:STDOUT: %E.ref: <function> = name_ref E, file.%import_ref.6 [template = imports.%E]
// CHECK:STDOUT: %.loc10: init () = call %E.ref()
// CHECK:STDOUT: assign file.%e.var, %.loc10
// CHECK:STDOUT: %E.call: init () = call %E.ref()
// CHECK:STDOUT: assign file.%e.var, %E.call
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -459,26 +459,26 @@ import library "extern_api";
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %A.ref: <function> = name_ref A, file.%A [template = file.%A]
// CHECK:STDOUT: %.loc12: init () = call %A.ref()
// CHECK:STDOUT: assign file.%a.var, %.loc12
// CHECK:STDOUT: %A.call: init () = call %A.ref()
// CHECK:STDOUT: assign file.%a.var, %A.call
// CHECK:STDOUT: %B.ref: <function> = name_ref B, file.%B [template = file.%B]
// CHECK:STDOUT: %.loc13_16: i32 = int_literal 1 [template = constants.%.5]
// CHECK:STDOUT: %.loc13_15: init i32 = call %B.ref(%.loc13_16)
// CHECK:STDOUT: assign file.%b.var, %.loc13_15
// CHECK:STDOUT: %.loc13: i32 = int_literal 1 [template = constants.%.5]
// CHECK:STDOUT: %B.call: init i32 = call %B.ref(%.loc13)
// CHECK:STDOUT: assign file.%b.var, %B.call
// CHECK:STDOUT: %C.ref: <function> = name_ref C, file.%C [template = file.%C]
// CHECK:STDOUT: %.loc14_23: i32 = int_literal 1 [template = constants.%.5]
// CHECK:STDOUT: %.loc14_25.1: (i32,) = tuple_literal (%.loc14_23)
// CHECK:STDOUT: %.loc14_25.2: (i32,) = tuple_value (%.loc14_23) [template = constants.%.6]
// CHECK:STDOUT: %.loc14_21.1: (i32,) = converted %.loc14_25.1, %.loc14_25.2 [template = constants.%.6]
// CHECK:STDOUT: %.loc14_21.2: init {.c: i32} = call %C.ref(%.loc14_21.1)
// CHECK:STDOUT: assign file.%c.var, %.loc14_21.2
// CHECK:STDOUT: %.loc14_21: (i32,) = converted %.loc14_25.1, %.loc14_25.2 [template = constants.%.6]
// CHECK:STDOUT: %C.call: init {.c: i32} = call %C.ref(%.loc14_21)
// CHECK:STDOUT: assign file.%c.var, %C.call
// CHECK:STDOUT: %D.ref: <function> = name_ref D, file.%D [template = file.%D]
// CHECK:STDOUT: %.loc15: init () = call %D.ref()
// CHECK:STDOUT: assign file.%d.var, %.loc15
// CHECK:STDOUT: %D.call: init () = call %D.ref()
// CHECK:STDOUT: assign file.%d.var, %D.call
// CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, file.%NS [template = file.%NS]
// CHECK:STDOUT: %E.ref: <function> = name_ref E, file.%E [template = file.%E]
// CHECK:STDOUT: %.loc16: init () = call %E.ref()
// CHECK:STDOUT: assign file.%e.var, %.loc16
// CHECK:STDOUT: %E.call: init () = call %E.ref()
// CHECK:STDOUT: assign file.%e.var, %E.call
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -565,26 +565,26 @@ import library "extern_api";
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %A.ref: <function> = name_ref A, file.%A [template = file.%A]
// CHECK:STDOUT: %.loc12: init () = call %A.ref()
// CHECK:STDOUT: assign file.%a.var, %.loc12
// CHECK:STDOUT: %A.call: init () = call %A.ref()
// CHECK:STDOUT: assign file.%a.var, %A.call
// CHECK:STDOUT: %B.ref: <function> = name_ref B, file.%B [template = file.%B]
// CHECK:STDOUT: %.loc13_16: i32 = int_literal 1 [template = constants.%.5]
// CHECK:STDOUT: %.loc13_15: init i32 = call %B.ref(%.loc13_16)
// CHECK:STDOUT: assign file.%b.var, %.loc13_15
// CHECK:STDOUT: %.loc13: i32 = int_literal 1 [template = constants.%.5]
// CHECK:STDOUT: %B.call: init i32 = call %B.ref(%.loc13)
// CHECK:STDOUT: assign file.%b.var, %B.call
// CHECK:STDOUT: %C.ref: <function> = name_ref C, file.%C [template = file.%C]
// CHECK:STDOUT: %.loc14_23: i32 = int_literal 1 [template = constants.%.5]
// CHECK:STDOUT: %.loc14_25.1: (i32,) = tuple_literal (%.loc14_23)
// CHECK:STDOUT: %.loc14_25.2: (i32,) = tuple_value (%.loc14_23) [template = constants.%.6]
// CHECK:STDOUT: %.loc14_21.1: (i32,) = converted %.loc14_25.1, %.loc14_25.2 [template = constants.%.6]
// CHECK:STDOUT: %.loc14_21.2: init {.c: i32} = call %C.ref(%.loc14_21.1)
// CHECK:STDOUT: assign file.%c.var, %.loc14_21.2
// CHECK:STDOUT: %.loc14_21: (i32,) = converted %.loc14_25.1, %.loc14_25.2 [template = constants.%.6]
// CHECK:STDOUT: %C.call: init {.c: i32} = call %C.ref(%.loc14_21)
// CHECK:STDOUT: assign file.%c.var, %C.call
// CHECK:STDOUT: %D.ref: <function> = name_ref D, file.%D [template = file.%D]
// CHECK:STDOUT: %.loc15: init () = call %D.ref()
// CHECK:STDOUT: assign file.%d.var, %.loc15
// CHECK:STDOUT: %D.call: init () = call %D.ref()
// CHECK:STDOUT: assign file.%d.var, %D.call
// CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, file.%NS [template = file.%NS]
// CHECK:STDOUT: %E.ref: <function> = name_ref E, file.%E [template = file.%E]
// CHECK:STDOUT: %.loc16: init () = call %E.ref()
// CHECK:STDOUT: assign file.%e.var, %.loc16
// CHECK:STDOUT: %E.call: init () = call %E.ref()
// CHECK:STDOUT: assign file.%e.var, %E.call
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -669,26 +669,26 @@ import library "extern_api";
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %A.ref: <function> = name_ref A, file.%import_ref.1 [template = imports.%A.1]
// CHECK:STDOUT: %.loc7: init () = call %A.ref()
// CHECK:STDOUT: assign file.%a.var, %.loc7
// CHECK:STDOUT: %A.call: init () = call %A.ref()
// CHECK:STDOUT: assign file.%a.var, %A.call
// CHECK:STDOUT: %B.ref: <function> = name_ref B, file.%import_ref.2 [template = imports.%B.1]
// CHECK:STDOUT: %.loc8_16: i32 = int_literal 1 [template = constants.%.4]
// CHECK:STDOUT: %.loc8_15: init i32 = call %B.ref(%.loc8_16)
// CHECK:STDOUT: assign file.%b.var, %.loc8_15
// CHECK:STDOUT: %.loc8: i32 = int_literal 1 [template = constants.%.4]
// CHECK:STDOUT: %B.call: init i32 = call %B.ref(%.loc8)
// CHECK:STDOUT: assign file.%b.var, %B.call
// CHECK:STDOUT: %C.ref: <function> = name_ref C, file.%import_ref.3 [template = imports.%C.1]
// CHECK:STDOUT: %.loc9_23: i32 = int_literal 1 [template = constants.%.4]
// CHECK:STDOUT: %.loc9_25.1: (i32,) = tuple_literal (%.loc9_23)
// CHECK:STDOUT: %.loc9_25.2: (i32,) = tuple_value (%.loc9_23) [template = constants.%.5]
// CHECK:STDOUT: %.loc9_21.1: (i32,) = converted %.loc9_25.1, %.loc9_25.2 [template = constants.%.5]
// CHECK:STDOUT: %.loc9_21.2: init {.c: i32} = call %C.ref(%.loc9_21.1)
// CHECK:STDOUT: assign file.%c.var, %.loc9_21.2
// CHECK:STDOUT: %.loc9_21: (i32,) = converted %.loc9_25.1, %.loc9_25.2 [template = constants.%.5]
// CHECK:STDOUT: %C.call: init {.c: i32} = call %C.ref(%.loc9_21)
// CHECK:STDOUT: assign file.%c.var, %C.call
// CHECK:STDOUT: %D.ref: <function> = name_ref D, file.%import_ref.4 [template = imports.%D.1]
// CHECK:STDOUT: %.loc10: init () = call %D.ref()
// CHECK:STDOUT: assign file.%d.var, %.loc10
// CHECK:STDOUT: %D.call: init () = call %D.ref()
// CHECK:STDOUT: assign file.%d.var, %D.call
// CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, file.%NS [template = file.%NS]
// CHECK:STDOUT: %E.ref: <function> = name_ref E, file.%import_ref.6 [template = imports.%E.1]
// CHECK:STDOUT: %.loc11: init () = call %E.ref()
// CHECK:STDOUT: assign file.%e.var, %.loc11
// CHECK:STDOUT: %E.call: init () = call %E.ref()
// CHECK:STDOUT: assign file.%e.var, %E.call
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -773,26 +773,26 @@ import library "extern_api";
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %A.ref: <function> = name_ref A, imports.%A.2 [template = imports.%A.2]
// CHECK:STDOUT: %.loc7: init () = call %A.ref()
// CHECK:STDOUT: assign file.%a.var, %.loc7
// CHECK:STDOUT: %A.call: init () = call %A.ref()
// CHECK:STDOUT: assign file.%a.var, %A.call
// CHECK:STDOUT: %B.ref: <function> = name_ref B, imports.%B.2 [template = imports.%B.2]
// CHECK:STDOUT: %.loc8_16: i32 = int_literal 1 [template = constants.%.4]
// CHECK:STDOUT: %.loc8_15: init i32 = call %B.ref(%.loc8_16)
// CHECK:STDOUT: assign file.%b.var, %.loc8_15
// CHECK:STDOUT: %.loc8: i32 = int_literal 1 [template = constants.%.4]
// CHECK:STDOUT: %B.call: init i32 = call %B.ref(%.loc8)
// CHECK:STDOUT: assign file.%b.var, %B.call
// CHECK:STDOUT: %C.ref: <function> = name_ref C, imports.%C.2 [template = imports.%C.2]
// CHECK:STDOUT: %.loc9_23: i32 = int_literal 1 [template = constants.%.4]
// CHECK:STDOUT: %.loc9_25.1: (i32,) = tuple_literal (%.loc9_23)
// CHECK:STDOUT: %.loc9_25.2: (i32,) = tuple_value (%.loc9_23) [template = constants.%.5]
// CHECK:STDOUT: %.loc9_21.1: (i32,) = converted %.loc9_25.1, %.loc9_25.2 [template = constants.%.5]
// CHECK:STDOUT: %.loc9_21.2: init {.c: i32} = call %C.ref(%.loc9_21.1)
// CHECK:STDOUT: assign file.%c.var, %.loc9_21.2
// CHECK:STDOUT: %.loc9_21: (i32,) = converted %.loc9_25.1, %.loc9_25.2 [template = constants.%.5]
// CHECK:STDOUT: %C.call: init {.c: i32} = call %C.ref(%.loc9_21)
// CHECK:STDOUT: assign file.%c.var, %C.call
// CHECK:STDOUT: %D.ref: <function> = name_ref D, file.%import_ref.4 [template = imports.%D.1]
// CHECK:STDOUT: %.loc10: init () = call %D.ref()
// CHECK:STDOUT: assign file.%d.var, %.loc10
// CHECK:STDOUT: %D.call: init () = call %D.ref()
// CHECK:STDOUT: assign file.%d.var, %D.call
// CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, file.%NS [template = file.%NS]
// CHECK:STDOUT: %E.ref: <function> = name_ref E, imports.%E.2 [template = imports.%E.2]
// CHECK:STDOUT: %.loc11: init () = call %E.ref()
// CHECK:STDOUT: assign file.%e.var, %.loc11
// CHECK:STDOUT: %E.call: init () = call %E.ref()
// CHECK:STDOUT: assign file.%e.var, %E.call
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -834,8 +834,8 @@ import library "extern_api";
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %A.ref: <function> = name_ref A, file.%import_ref.1 [template = imports.%A]
// CHECK:STDOUT: %.loc6: init () = call %A.ref()
// CHECK:STDOUT: assign file.%a.var, %.loc6
// CHECK:STDOUT: %A.call: init () = call %A.ref()
// CHECK:STDOUT: assign file.%a.var, %A.call
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -881,8 +881,8 @@ import library "extern_api";
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %A.ref: <function> = name_ref A, file.%import_ref.1 [template = imports.%A]
// CHECK:STDOUT: %.loc6: init () = call %A.ref()
// CHECK:STDOUT: assign file.%a.var, %.loc6
// CHECK:STDOUT: %A.call: init () = call %A.ref()
// CHECK:STDOUT: assign file.%a.var, %A.call
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -924,8 +924,8 @@ import library "extern_api";
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %A.ref: <function> = name_ref A, file.%import_ref.1 [template = imports.%A]
// CHECK:STDOUT: %.loc6: init () = call %A.ref()
// CHECK:STDOUT: assign file.%a.var, %.loc6
// CHECK:STDOUT: %A.call: init () = call %A.ref()
// CHECK:STDOUT: assign file.%a.var, %A.call
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -30,7 +30,7 @@ fn G() { F(); }
// CHECK:STDOUT: fn @G() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %F.ref: <function> = name_ref F, file.%F [template = file.%F]
// CHECK:STDOUT: %.loc9: init () = call %F.ref()
// CHECK:STDOUT: %F.call: init () = call %F.ref()
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
+8 -8
View File
@@ -208,19 +208,19 @@ fn D() {}
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %A.ref: <function> = name_ref A, file.%import_ref.1 [template = imports.%A]
// CHECK:STDOUT: %.loc6: init () = call %A.ref()
// CHECK:STDOUT: assign file.%a.var, %.loc6
// CHECK:STDOUT: %A.call: init () = call %A.ref()
// CHECK:STDOUT: assign file.%a.var, %A.call
// CHECK:STDOUT: %B.ref: <function> = name_ref B, file.%import_ref.2 [template = imports.%B]
// CHECK:STDOUT: %.loc7_16: i32 = int_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %.loc7_15: init i32 = call %B.ref(%.loc7_16)
// CHECK:STDOUT: assign file.%b.var, %.loc7_15
// CHECK:STDOUT: %.loc7: i32 = int_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %B.call: init i32 = call %B.ref(%.loc7)
// CHECK:STDOUT: assign file.%b.var, %B.call
// CHECK:STDOUT: %C.ref: <function> = name_ref C, file.%import_ref.3 [template = imports.%C]
// CHECK:STDOUT: %.loc8_23: i32 = int_literal 1 [template = constants.%.2]
// CHECK:STDOUT: %.loc8_25.1: (i32,) = tuple_literal (%.loc8_23)
// CHECK:STDOUT: %.loc8_25.2: (i32,) = tuple_value (%.loc8_23) [template = constants.%.5]
// CHECK:STDOUT: %.loc8_21.1: (i32,) = converted %.loc8_25.1, %.loc8_25.2 [template = constants.%.5]
// CHECK:STDOUT: %.loc8_21.2: init {.c: i32} = call %C.ref(%.loc8_21.1)
// CHECK:STDOUT: assign file.%c.var, %.loc8_21.2
// CHECK:STDOUT: %.loc8_21: (i32,) = converted %.loc8_25.1, %.loc8_25.2 [template = constants.%.5]
// CHECK:STDOUT: %C.call: init {.c: i32} = call %C.ref(%.loc8_21)
// CHECK:STDOUT: assign file.%c.var, %C.call
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT: