Format the decl block for a declaration as a trailing block. (#3731)

Previously we used the default inst block formatting, which writes out a
parenthesized list of references, which would always be 'unexpected
instref's because nothing else prints the instructions in the decl
block.

In addition, track the decl block for function declarations like we do
for other kinds of declaration. This means that the parameter
declarations for a function are now properly rendered into the formatted
IR. Note that this adds a lot of verbosity to `function_decl`, but it
does accurately reflect the IR, and we'll probably want this information
to be printed once we start supporting more complex generic function
declarations.

This removes almost all the 'unexpected instref's in our formatted
output. There are remaining cases when a declarative scope contains
multiple blocks, where we only track one of those blocks. That happens
when there is control flow within declarative scopes, and for error
recovery when a class or interface or similar is defined more than once.

As requested in #3730.
This commit is contained in:
Richard Smith
2024-02-28 21:28:59 +00:00
committed by GitHub
parent 33c1e9ca95
commit 5f4e6c768a
285 changed files with 2152 additions and 828 deletions
+4 -2
View File
@@ -20,10 +20,12 @@ fn Main() {
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.A = %A, .B = %B, .Main = %Main} [template]
// CHECK:STDOUT: %A: <function> = fn_decl @A [template]
// CHECK:STDOUT: %A: <function> = fn_decl @A {
// CHECK:STDOUT: %return.var: ref i32 = var <return slot>
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: %A.ref: <function> = name_ref A, %A [template = %A]
// CHECK:STDOUT: %B: <function> = bind_alias B, %A [template = %A]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @A() -> i32 {
+10 -2
View File
@@ -22,8 +22,16 @@ fn Main() {
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Echo = %Echo, .Main = %Main} [template]
// CHECK:STDOUT: %Echo: <function> = fn_decl @Echo [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main [template]
// CHECK:STDOUT: %Echo: <function> = fn_decl @Echo {
// CHECK:STDOUT: %.loc7_13.1: {} = struct_literal ()
// CHECK:STDOUT: %.loc7_13.2: type = converted %.loc7_13.1, constants.%.1 [template = constants.%.1]
// CHECK:STDOUT: %a.loc7_9.1: {} = param a
// CHECK:STDOUT: @Echo.%a: {} = bind_name a, %a.loc7_9.1
// CHECK:STDOUT: %.loc7_20.1: {} = struct_literal ()
// CHECK:STDOUT: %.loc7_20.2: type = converted %.loc7_20.1, constants.%.1 [template = constants.%.1]
// CHECK:STDOUT: %return.var: ref {} = var <return slot>
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Echo(%a: {}) -> {} {
+10 -2
View File
@@ -21,8 +21,16 @@ fn Main() {
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Echo = %Echo, .Main = %Main} [template]
// CHECK:STDOUT: %Echo: <function> = fn_decl @Echo [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main [template]
// CHECK:STDOUT: %Echo: <function> = fn_decl @Echo {
// CHECK:STDOUT: %.loc7_13.1: () = tuple_literal ()
// CHECK:STDOUT: %.loc7_13.2: type = converted %.loc7_13.1, constants.%.1 [template = constants.%.1]
// CHECK:STDOUT: %a.loc7_9.1: () = param a
// CHECK:STDOUT: @Echo.%a: () = bind_name a, %a.loc7_9.1
// CHECK:STDOUT: %.loc7_20.1: () = tuple_literal ()
// CHECK:STDOUT: %.loc7_20.2: type = converted %.loc7_20.1, constants.%.1 [template = constants.%.1]
// CHECK:STDOUT: %return.var: ref () = var <return slot>
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Echo(%a: ()) -> () {
@@ -20,7 +20,7 @@ fn Run() {
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Run = %Run} [template]
// CHECK:STDOUT: %Run: <function> = fn_decl @Run [template]
// CHECK:STDOUT: %Run: <function> = fn_decl @Run {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Run() {
@@ -65,10 +65,18 @@ fn Main() {
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Run0 = %Run0, .Run1 = %Run1, .Run2 = %Run2, .Main = %Main} [template]
// CHECK:STDOUT: %Run0: <function> = fn_decl @Run0 [template]
// CHECK:STDOUT: %Run1: <function> = fn_decl @Run1 [template]
// CHECK:STDOUT: %Run2: <function> = fn_decl @Run2 [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main [template]
// CHECK:STDOUT: %Run0: <function> = fn_decl @Run0 {} [template]
// CHECK:STDOUT: %Run1: <function> = fn_decl @Run1 {
// CHECK:STDOUT: %a.loc8_9.1: i32 = param a
// CHECK:STDOUT: @Run1.%a: i32 = bind_name a, %a.loc8_9.1
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: %Run2: <function> = fn_decl @Run2 {
// CHECK:STDOUT: %a.loc9_9.1: i32 = param a
// CHECK:STDOUT: @Run2.%a: i32 = bind_name a, %a.loc9_9.1
// CHECK:STDOUT: %b.loc9_17.1: i32 = param b
// CHECK:STDOUT: @Run2.%b: i32 = bind_name b, %b.loc9_17.1
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Run0() {
@@ -25,8 +25,11 @@ fn F() {
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.G = %G, .F = %F} [template]
// CHECK:STDOUT: %G: <function> = fn_decl @G [template]
// CHECK:STDOUT: %F: <function> = fn_decl @F [template]
// CHECK:STDOUT: %G: <function> = fn_decl @G {
// CHECK:STDOUT: %a.loc7_6.1: i32 = param a
// CHECK:STDOUT: @G.%a: i32 = bind_name a, %a.loc7_6.1
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: %F: <function> = fn_decl @F {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @G(%a: i32) {
@@ -21,8 +21,10 @@ fn Run() {
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Foo = %Foo, .Run = %Run} [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo [template]
// CHECK:STDOUT: %Run: <function> = fn_decl @Run [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo {
// CHECK:STDOUT: %return.var: ref f64 = var <return slot>
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: %Run: <function> = fn_decl @Run {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo() -> f64 {
+6 -2
View File
@@ -20,8 +20,12 @@ fn Main() {
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Echo = %Echo, .Main = %Main} [template]
// CHECK:STDOUT: %Echo: <function> = fn_decl @Echo [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main [template]
// CHECK:STDOUT: %Echo: <function> = fn_decl @Echo {
// CHECK:STDOUT: %a.loc7_9.1: i32 = param a
// CHECK:STDOUT: @Echo.%a: i32 = bind_name a, %a.loc7_9.1
// CHECK:STDOUT: %return.var: ref i32 = var <return slot>
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Echo(%a: i32) -> i32 {
@@ -26,8 +26,13 @@ fn Main() {
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Foo = %Foo, .Main = %Main} [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo {
// CHECK:STDOUT: %a.loc7_8.1: i32 = param a
// CHECK:STDOUT: @Foo.%a: i32 = bind_name a, %a.loc7_8.1
// CHECK:STDOUT: %b.loc7_16.1: i32 = param b
// CHECK:STDOUT: @Foo.%b: i32 = bind_name b, %b.loc7_16.1
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: i32, %b: i32) {
+5 -2
View File
@@ -19,8 +19,11 @@ fn Main() {
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Foo = %Foo, .Main = %Main} [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo {
// CHECK:STDOUT: %a.loc7_8.1: i32 = param a
// CHECK:STDOUT: @Foo.%a: i32 = bind_name a, %a.loc7_8.1
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: i32) {
@@ -20,8 +20,11 @@ fn Main() {
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Foo = %Foo, .Main = %Main} [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo {
// CHECK:STDOUT: %a.loc7_8.1: i32 = param a
// CHECK:STDOUT: @Foo.%a: i32 = bind_name a, %a.loc7_8.1
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: i32) {
+7 -2
View File
@@ -20,8 +20,13 @@ fn Main() {
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Foo = %Foo, .Main = %Main} [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo {
// CHECK:STDOUT: %a.loc7_8.1: i32 = param a
// CHECK:STDOUT: @Foo.%a: i32 = bind_name a, %a.loc7_8.1
// CHECK:STDOUT: %b.loc7_16.1: i32 = param b
// CHECK:STDOUT: @Foo.%b: i32 = bind_name b, %b.loc7_16.1
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: i32, %b: i32) {
@@ -21,8 +21,13 @@ fn Main() {
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Foo = %Foo, .Main = %Main} [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo {
// CHECK:STDOUT: %a.loc7_8.1: i32 = param a
// CHECK:STDOUT: @Foo.%a: i32 = bind_name a, %a.loc7_8.1
// CHECK:STDOUT: %b.loc7_16.1: i32 = param b
// CHECK:STDOUT: @Foo.%b: i32 = bind_name b, %b.loc7_16.1
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: i32, %b: i32) {
+2 -2
View File
@@ -18,8 +18,8 @@ fn Main() {
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Foo = %Foo, .Main = %Main} [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo {} [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo() {
@@ -19,8 +19,8 @@ fn Main() {
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.MakeImplicitEmptyTuple = %MakeImplicitEmptyTuple, .Main = %Main} [template]
// CHECK:STDOUT: %MakeImplicitEmptyTuple: <function> = fn_decl @MakeImplicitEmptyTuple [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main [template]
// CHECK:STDOUT: %MakeImplicitEmptyTuple: <function> = fn_decl @MakeImplicitEmptyTuple {} [template]
// CHECK:STDOUT: %Main: <function> = fn_decl @Main {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @MakeImplicitEmptyTuple() {
@@ -74,12 +74,12 @@ default final virtual fn ModifiersConflict2() {}
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.WrongOrder = %WrongOrder, .DuplicateVirtual = %DuplicateVirtual, .TwoAccess = %TwoAccess, .ModifiersConflict = %ModifiersConflict, .InvalidModifier = %InvalidModifier, .ModifiersConflict2 = %ModifiersConflict2} [template]
// CHECK:STDOUT: %WrongOrder: <function> = fn_decl @WrongOrder [template]
// CHECK:STDOUT: %DuplicateVirtual: <function> = fn_decl @DuplicateVirtual [template]
// CHECK:STDOUT: %TwoAccess: <function> = fn_decl @TwoAccess [template]
// CHECK:STDOUT: %ModifiersConflict: <function> = fn_decl @ModifiersConflict [template]
// CHECK:STDOUT: %InvalidModifier: <function> = fn_decl @InvalidModifier [template]
// CHECK:STDOUT: %ModifiersConflict2: <function> = fn_decl @ModifiersConflict2 [template]
// CHECK:STDOUT: %WrongOrder: <function> = fn_decl @WrongOrder {} [template]
// CHECK:STDOUT: %DuplicateVirtual: <function> = fn_decl @DuplicateVirtual {} [template]
// CHECK:STDOUT: %TwoAccess: <function> = fn_decl @TwoAccess {} [template]
// CHECK:STDOUT: %ModifiersConflict: <function> = fn_decl @ModifiersConflict {} [template]
// CHECK:STDOUT: %InvalidModifier: <function> = fn_decl @InvalidModifier {} [template]
// CHECK:STDOUT: %ModifiersConflict2: <function> = fn_decl @ModifiersConflict2 {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @WrongOrder();
@@ -13,7 +13,14 @@ fn F(n: i32, a: [i32; n]*);
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.F = %F} [template]
// CHECK:STDOUT: %F: <function> = fn_decl @F [template]
// CHECK:STDOUT: %F: <function> = fn_decl @F {
// CHECK:STDOUT: %n.loc10_6.1: i32 = param n
// CHECK:STDOUT: @F.%n: i32 = bind_name n, %n.loc10_6.1
// CHECK:STDOUT: %n.ref: i32 = name_ref n, @F.%n
// CHECK:STDOUT: %.loc10: type = ptr_type <error> [template = <error>]
// CHECK:STDOUT: %a.loc10_14.1: <error> = param a
// CHECK:STDOUT: @F.%a: <error> = bind_name a, %a.loc10_14.1
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F(%n: i32, %a: <error>);
@@ -16,7 +16,12 @@ fn F(n: i32, n: i32);
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.F = %F} [template]
// CHECK:STDOUT: %F: <function> = fn_decl @F [template]
// CHECK:STDOUT: %F: <function> = fn_decl @F {
// CHECK:STDOUT: %n.loc13_6.1: i32 = param n
// CHECK:STDOUT: @F.%n.loc13_6: i32 = bind_name n, %n.loc13_6.1
// CHECK:STDOUT: %n.loc13_14.1: i32 = param n
// CHECK:STDOUT: @F.%n.loc13_14: i32 = bind_name n, %n.loc13_14.1
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F(%n.loc13_6: i32, %n.loc13_14: i32);
@@ -13,7 +13,7 @@ private fn F();
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.F = %F} [template]
// CHECK:STDOUT: %F: <function> = fn_decl @F [template]
// CHECK:STDOUT: %F: <function> = fn_decl @F {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F();
+14 -3
View File
@@ -32,9 +32,20 @@ var c: {.c: i32} = C((1,));
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.A = %A, .B = %B, .C = %C} [template]
// CHECK:STDOUT: %A: <function> = fn_decl @A [template]
// CHECK:STDOUT: %B: <function> = fn_decl @B [template]
// CHECK:STDOUT: %C: <function> = fn_decl @C [template]
// CHECK:STDOUT: %A: <function> = fn_decl @A {} [template]
// CHECK:STDOUT: %B: <function> = fn_decl @B {
// CHECK:STDOUT: %b.loc5_6.1: i32 = param b
// CHECK:STDOUT: @B.%b: i32 = bind_name b, %b.loc5_6.1
// CHECK:STDOUT: %return.var.loc5: ref i32 = var <return slot>
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: %C: <function> = fn_decl @C {
// CHECK:STDOUT: %.loc6_14.1: (type,) = tuple_literal (i32)
// CHECK:STDOUT: %.loc6_14.2: type = converted %.loc6_14.1, constants.%.2 [template = constants.%.2]
// CHECK:STDOUT: %c.loc6_6.1: (i32,) = param c
// CHECK:STDOUT: @C.%c: (i32,) = bind_name c, %c.loc6_6.1
// CHECK:STDOUT: %.loc6_28: type = struct_type {.c: i32} [template = constants.%.3]
// CHECK:STDOUT: %return.var.loc6: ref {.c: i32} = var <return slot>
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @A();
@@ -12,8 +12,14 @@ fn G(a: i32);
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.F = %F, .G = %G} [template]
// CHECK:STDOUT: %F: <function> = fn_decl @F [template]
// CHECK:STDOUT: %G: <function> = fn_decl @G [template]
// CHECK:STDOUT: %F: <function> = fn_decl @F {
// CHECK:STDOUT: %a.loc7_6.1: i32 = param a
// CHECK:STDOUT: @F.%a: i32 = bind_name a, %a.loc7_6.1
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: %G: <function> = fn_decl @G {
// CHECK:STDOUT: %a.loc9_6.1: i32 = param a
// CHECK:STDOUT: @G.%a: i32 = bind_name a, %a.loc9_6.1
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F(%a: i32);
@@ -16,8 +16,8 @@ fn G() { F(); }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.F = %F, .G = %G} [template]
// CHECK:STDOUT: %F: <function> = fn_decl @F [template]
// CHECK:STDOUT: %G: <function> = fn_decl @G [template]
// CHECK:STDOUT: %F: <function> = fn_decl @F {} [template]
// CHECK:STDOUT: %G: <function> = fn_decl @G {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F();
@@ -30,7 +30,7 @@ fn Foo() {}
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Foo = %Foo} [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo();
@@ -40,7 +40,7 @@ fn Foo() {}
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Foo = %import_ref} [template]
// CHECK:STDOUT: %import_ref: <function> = import_ref ir1, inst+1, used [template = imports.%Foo]
// CHECK:STDOUT: %.loc14: <function> = fn_decl @.1 [template]
// CHECK:STDOUT: %.loc14: <function> = fn_decl @.1 {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo();
@@ -12,8 +12,8 @@ fn Foo() {}
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Foo = %Foo.loc7} [template]
// CHECK:STDOUT: %Foo.loc7: <function> = fn_decl @Foo [template]
// CHECK:STDOUT: %Foo.loc9: <function> = fn_decl @Foo [template]
// CHECK:STDOUT: %Foo.loc7: <function> = fn_decl @Foo {} [template]
// CHECK:STDOUT: %Foo.loc9: <function> = fn_decl @Foo {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo() {
+14 -3
View File
@@ -33,9 +33,20 @@ var c: {.c: i32} = C((1,));
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.A = %A, .B = %B, .C = %C} [template]
// CHECK:STDOUT: %A: <function> = fn_decl @A [template]
// CHECK:STDOUT: %B: <function> = fn_decl @B [template]
// CHECK:STDOUT: %C: <function> = fn_decl @C [template]
// CHECK:STDOUT: %A: <function> = fn_decl @A {} [template]
// CHECK:STDOUT: %B: <function> = fn_decl @B {
// CHECK:STDOUT: %b.loc5_6.1: i32 = param b
// CHECK:STDOUT: @B.%b: i32 = bind_name b, %b.loc5_6.1
// CHECK:STDOUT: %return.var.loc5: ref i32 = var <return slot>
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: %C: <function> = fn_decl @C {
// CHECK:STDOUT: %.loc6_14.1: (type,) = tuple_literal (i32)
// CHECK:STDOUT: %.loc6_14.2: type = converted %.loc6_14.1, constants.%.2 [template = constants.%.2]
// CHECK:STDOUT: %c.loc6_6.1: (i32,) = param c
// CHECK:STDOUT: @C.%c: (i32,) = bind_name c, %c.loc6_6.1
// CHECK:STDOUT: %.loc6_28: type = struct_type {.c: i32} [template = constants.%.3]
// CHECK:STDOUT: %return.var.loc6: ref {.c: i32} = var <return slot>
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @A() {
+3 -3
View File
@@ -12,9 +12,9 @@ fn Baz() {}
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Foo = %Foo, .Bar = %Bar, .Baz = %Baz} [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo [template]
// CHECK:STDOUT: %Bar: <function> = fn_decl @Bar [template]
// CHECK:STDOUT: %Baz: <function> = fn_decl @Baz [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo {} [template]
// CHECK:STDOUT: %Bar: <function> = fn_decl @Bar {} [template]
// CHECK:STDOUT: %Baz: <function> = fn_decl @Baz {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo() {
@@ -10,7 +10,10 @@ fn Foo(a: i32) {}
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Foo = %Foo} [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo {
// CHECK:STDOUT: %a.loc7_8.1: i32 = param a
// CHECK:STDOUT: @Foo.%a: i32 = bind_name a, %a.loc7_8.1
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: i32) {
@@ -10,7 +10,10 @@ fn Foo(a: i32,) {}
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Foo = %Foo} [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo {
// CHECK:STDOUT: %a.loc7_8.1: i32 = param a
// CHECK:STDOUT: @Foo.%a: i32 = bind_name a, %a.loc7_8.1
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: i32) {
@@ -10,7 +10,12 @@ fn Foo(a: i32, b: i32) {}
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Foo = %Foo} [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo {
// CHECK:STDOUT: %a.loc7_8.1: i32 = param a
// CHECK:STDOUT: @Foo.%a: i32 = bind_name a, %a.loc7_8.1
// CHECK:STDOUT: %b.loc7_16.1: i32 = param b
// CHECK:STDOUT: @Foo.%b: i32 = bind_name b, %b.loc7_16.1
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: i32, %b: i32) {
@@ -10,7 +10,12 @@ fn Foo(a: i32, b: i32,) {}
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Foo = %Foo} [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo {
// CHECK:STDOUT: %a.loc7_8.1: i32 = param a
// CHECK:STDOUT: @Foo.%a: i32 = bind_name a, %a.loc7_8.1
// CHECK:STDOUT: %b.loc7_16.1: i32 = param b
// CHECK:STDOUT: @Foo.%b: i32 = bind_name b, %b.loc7_16.1
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo(%a: i32, %b: i32) {
@@ -10,7 +10,7 @@ fn Foo() {}
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Foo = %Foo} [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo [template]
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Foo() {
@@ -13,7 +13,15 @@ fn F(N:! i32, a: [i32; N]*);
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.F = %F} [template]
// CHECK:STDOUT: %F: <function> = fn_decl @F [template]
// CHECK:STDOUT: %F: <function> = fn_decl @F {
// CHECK:STDOUT: %N.loc10_6.1: i32 = param N
// CHECK:STDOUT: @F.%N: i32 = bind_symbolic_name N, %N.loc10_6.1 [symbolic]
// CHECK:STDOUT: %N.ref: i32 = name_ref N, @F.%N [symbolic = @F.%N]
// CHECK:STDOUT: %.loc10_25: type = array_type %N.ref, i32 [template = <error>]
// CHECK:STDOUT: %.loc10_26: type = ptr_type <error> [template = <error>]
// CHECK:STDOUT: %a.loc10_15.1: <error> = param a
// CHECK:STDOUT: @F.%a: <error> = bind_name a, %a.loc10_15.1
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F(%N: i32, %a: <error>);
@@ -20,7 +20,12 @@ fn F(T:! type, U:! type) {
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.F = %F} [template]
// CHECK:STDOUT: %F: <function> = fn_decl @F [template]
// CHECK:STDOUT: %F: <function> = fn_decl @F {
// CHECK:STDOUT: %T.loc7_6.1: type = param T
// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T, %T.loc7_6.1 [symbolic]
// CHECK:STDOUT: %U.loc7_16.1: type = param U
// CHECK:STDOUT: @F.%U: type = bind_symbolic_name U, %U.loc7_16.1 [symbolic]
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F(%T: type, %U: type) {
@@ -17,7 +17,10 @@ fn F(T:! type) {
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.F = %F} [template]
// CHECK:STDOUT: %F: <function> = fn_decl @F [template]
// CHECK:STDOUT: %F: <function> = fn_decl @F {
// CHECK:STDOUT: %T.loc7_6.1: type = param T
// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T, %T.loc7_6.1 [symbolic]
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F(%T: type) {
@@ -13,7 +13,15 @@ fn F(T:! type, n: T) -> T {
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.F = %F} [template]
// CHECK:STDOUT: %F: <function> = fn_decl @F [template]
// CHECK:STDOUT: %F: <function> = fn_decl @F {
// CHECK:STDOUT: %T.loc7_6.1: type = param T
// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T, %T.loc7_6.1 [symbolic]
// CHECK:STDOUT: %T.ref.loc7_19: type = name_ref T, @F.%T [symbolic = @F.%T]
// CHECK:STDOUT: %n.loc7_16.1: T = param n
// CHECK:STDOUT: @F.%n: T = bind_name n, %n.loc7_16.1
// CHECK:STDOUT: %T.ref.loc7_25: type = name_ref T, @F.%T [symbolic = @F.%T]
// CHECK:STDOUT: %return.var: ref T = var <return slot>
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F(%T: type, %n: T) -> T {