Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SemIR instruction to track that a conversion was performed. #3363

Merged
merged 7 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions toolchain/check/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ class TypeCompleter {
case SemIR::ClassDeclaration::Kind:
case SemIR::ClassFieldAccess::Kind:
case SemIR::ClassInit::Kind:
case SemIR::Conversion::Kind:
case SemIR::Dereference::Kind:
case SemIR::Field::Kind:
case SemIR::FunctionDeclaration::Kind:
Expand Down Expand Up @@ -1000,6 +1001,9 @@ auto Context::CanonicalizeTypeAndAddInstIfNew(SemIR::Inst inst)
}

auto Context::CanonicalizeType(SemIR::InstId inst_id) -> SemIR::TypeId {
while (auto conversion = insts().Get(inst_id).TryAs<SemIR::Conversion>()) {
inst_id = conversion->converted_id;
}
inst_id = FollowNameReferences(inst_id);

auto it = canonical_types_.find(inst_id);
Expand Down
99 changes: 55 additions & 44 deletions toolchain/check/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,39 @@ namespace Carbon::Check {
static auto FindReturnSlotForInitializer(SemIR::File& sem_ir,
SemIR::InstId init_id)
-> SemIR::InstId {
SemIR::Inst init = sem_ir.insts().Get(init_id);
switch (init.kind()) {
default:
CARBON_FATAL() << "Initialization from unexpected inst " << init;

case SemIR::ClassInit::Kind:
case SemIR::StructInit::Kind:
case SemIR::TupleInit::Kind:
// TODO: Track a return slot for these initializers.
CARBON_FATAL() << init
<< " should be created with its return slot already "
"filled in properly";

case SemIR::InitializeFrom::Kind: {
return init.As<SemIR::InitializeFrom>().dest_id;
}
while (true) {
SemIR::Inst init = sem_ir.insts().Get(init_id);
switch (init.kind()) {
default:
CARBON_FATAL() << "Initialization from unexpected inst " << init;

case SemIR::Call::Kind: {
auto call = init.As<SemIR::Call>();
if (!SemIR::GetInitializingRepresentation(sem_ir, call.type_id)
.has_return_slot()) {
return SemIR::InstId::Invalid;
}
return sem_ir.inst_blocks().Get(call.args_id).back();
}
case SemIR::Conversion::Kind:
init_id = init.As<SemIR::Conversion>().converted_id;
continue;

case SemIR::ArrayInit::Kind:
return init.As<SemIR::ArrayInit>().dest_id;

case SemIR::ClassInit::Kind:
return init.As<SemIR::ClassInit>().dest_id;

case SemIR::StructInit::Kind:
return init.As<SemIR::StructInit>().dest_id;

case SemIR::TupleInit::Kind:
return init.As<SemIR::TupleInit>().dest_id;

case SemIR::ArrayInit::Kind: {
return sem_ir.inst_blocks()
.Get(init.As<SemIR::ArrayInit>().inits_and_return_slot_id)
.back();
case SemIR::InitializeFrom::Kind:
return init.As<SemIR::InitializeFrom>().dest_id;

case SemIR::Call::Kind: {
auto call = init.As<SemIR::Call>();
if (!SemIR::GetInitializingRepresentation(sem_ir, call.type_id)
.has_return_slot()) {
return SemIR::InstId::Invalid;
}
return sem_ir.inst_blocks().Get(call.args_id).back();
}
}
}
}
Expand Down Expand Up @@ -302,14 +305,12 @@ static auto ConvertTupleToArray(Context& context, SemIR::TupleType tuple_type,
inits.push_back(init_id);
}

// The last element of the refs block contains the return slot for the array
// initialization. Flush the temporary here if we didn't insert it earlier.
// Flush the temporary here if we didn't insert it earlier, so we can add a
// reference to the return slot.
target_block->InsertHere();
inits.push_back(return_slot_id);

return context.AddInst(SemIR::ArrayInit{value.parse_node(), target.type_id,
value_id,
sem_ir.inst_blocks().Add(inits)});
sem_ir.inst_blocks().Add(inits),
return_slot_id});
}

// Performs a conversion from a tuple to a tuple type. This function only
Expand Down Expand Up @@ -378,12 +379,14 @@ static auto ConvertTupleToTuple(Context& context, SemIR::TupleType src_type,
new_block.Set(i, init_id);
}

return is_init ? context.AddInst(SemIR::TupleInit{value.parse_node(),
target.type_id, value_id,
new_block.id()})
: context.AddInst(SemIR::TupleValue{value.parse_node(),
target.type_id, value_id,
new_block.id()});
if (is_init) {
target.init_block->InsertHere();
return context.AddInst(SemIR::TupleInit{value.parse_node(), target.type_id,
new_block.id(), target.init_id});
} else {
return context.AddInst(
SemIR::TupleValue{value.parse_node(), target.type_id, new_block.id()});
}
}

// Common implementation for ConvertStructToStruct and ConvertStructToClass.
Expand Down Expand Up @@ -502,16 +505,18 @@ static auto ConvertStructToStructOrClass(Context& context,
}

if (is_class) {
target.init_block->InsertHere();
CARBON_CHECK(is_init)
<< "Converting directly to a class value is not supported";
return context.AddInst(SemIR::ClassInit{value.parse_node(), target.type_id,
value_id, new_block.id()});
new_block.id(), target.init_id});
} else if (is_init) {
target.init_block->InsertHere();
return context.AddInst(SemIR::StructInit{value.parse_node(), target.type_id,
value_id, new_block.id()});
new_block.id(), target.init_id});
} else {
return context.AddInst(SemIR::StructValue{
value.parse_node(), target.type_id, value_id, new_block.id()});
return context.AddInst(
SemIR::StructValue{value.parse_node(), target.type_id, new_block.id()});
}
}

Expand Down Expand Up @@ -827,6 +832,12 @@ auto Convert(Context& context, Parse::Node parse_node, SemIR::InstId expr_id,
return SemIR::InstId::BuiltinError;
}

// Track that we performed a type conversion, if we did so.
if (orig_expr_id != expr_id) {
expr_id = context.AddInst(SemIR::Conversion{
expr.parse_node(), target.type_id, orig_expr_id, expr_id});
}

// For `as`, don't perform any value category conversions. In particular, an
// identity conversion shouldn't change the expression category.
if (target.kind == ConversionTarget::ExplicitAs) {
Expand Down
6 changes: 4 additions & 2 deletions toolchain/check/testdata/array/array_in_place.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ fn G() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %.loc10_25: (type, type, type) = tuple_literal (i32, i32, i32)
// CHECK:STDOUT: %.loc10_28: i32 = int_literal 2
// CHECK:STDOUT: %.loc7: type = conversion %.loc10_25, constants.%.loc7_25.2
// CHECK:STDOUT: %.loc10_29: type = array_type %.loc10_28, (i32, i32, i32)
// CHECK:STDOUT: %v.var: ref [(i32, i32, i32); 2] = var "v"
// CHECK:STDOUT: %v: ref [(i32, i32, i32); 2] = bind_name "v", %v.var
Expand All @@ -45,7 +46,8 @@ fn G() {
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc10_40: init (i32, i32, i32) = call %F.ref.loc10_39() to %.loc10_42.6
// CHECK:STDOUT: %.loc10_42.7: ((i32, i32, i32), (i32, i32, i32)) = tuple_literal (%.loc10_35, %.loc10_40)
// CHECK:STDOUT: %.loc10_42.8: init [(i32, i32, i32); 2] = array_init %.loc10_42.7, (%.loc10_35, %.loc10_40) to %v.var
// CHECK:STDOUT: assign %v.var, %.loc10_42.8
// CHECK:STDOUT: %.loc10_42.8: init [(i32, i32, i32); 2] = array_init (%.loc10_35, %.loc10_40) to %v.var
// CHECK:STDOUT: %.loc10_42.9: init [(i32, i32, i32); 2] = conversion %.loc10_42.7, %.loc10_42.8
// CHECK:STDOUT: assign %v.var, %.loc10_42.9
// CHECK:STDOUT: return
// CHECK:STDOUT: }
10 changes: 6 additions & 4 deletions toolchain/check/testdata/array/assign_return_value.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ fn Run() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %.loc7_28: i32 = int_literal 0
// CHECK:STDOUT: %.loc7_30.1: (i32,) = tuple_literal (%.loc7_28)
// CHECK:STDOUT: %.loc7_30.2: (i32,) = tuple_value %.loc7_30.1, (%.loc7_28)
// CHECK:STDOUT: return %.loc7_30.2
// CHECK:STDOUT: %.loc7_30.2: (i32,) = tuple_value (%.loc7_28)
// CHECK:STDOUT: %.loc7_30.3: (i32,) = conversion %.loc7_30.1, %.loc7_30.2
// CHECK:STDOUT: return %.loc7_30.3
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Run() {
Expand All @@ -44,7 +45,8 @@ fn Run() {
// CHECK:STDOUT: %.loc10_22.6: i32 = int_literal 0
// CHECK:STDOUT: %.loc10_22.7: ref i32 = array_index %t.var, %.loc10_22.6
// CHECK:STDOUT: %.loc10_22.8: init i32 = initialize_from %.loc10_22.5 to %.loc10_22.7
// CHECK:STDOUT: %.loc10_22.9: init [i32; 1] = array_init %.loc10_22.3, (%.loc10_22.8) to %t.var
// CHECK:STDOUT: assign %t.var, %.loc10_22.9
// CHECK:STDOUT: %.loc10_22.9: init [i32; 1] = array_init (%.loc10_22.8) to %t.var
// CHECK:STDOUT: %.loc10_22.10: init [i32; 1] = conversion %.loc10_22.1, %.loc10_22.9
// CHECK:STDOUT: assign %t.var, %.loc10_22.10
// CHECK:STDOUT: return
// CHECK:STDOUT: }
13 changes: 8 additions & 5 deletions toolchain/check/testdata/array/assign_var.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ var b: [i32; 3] = a;
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file "assign_var.carbon" {
// CHECK:STDOUT: %.loc7_22: (type, type, type) = tuple_literal (i32, i32, i32)
// CHECK:STDOUT: %.loc7_22.1: (type, type, type) = tuple_literal (i32, i32, i32)
// CHECK:STDOUT: %.loc7_22.2: type = conversion %.loc7_22.1, constants.%.loc7_22.2
// CHECK:STDOUT: %a.var: ref (i32, i32, i32) = var "a"
// CHECK:STDOUT: %a: ref (i32, i32, i32) = bind_name "a", %a.var
// CHECK:STDOUT: %.loc7_27: i32 = int_literal 1
Expand All @@ -28,8 +29,9 @@ var b: [i32; 3] = a;
// CHECK:STDOUT: %.loc7_34.5: init i32 = initialize_from %.loc7_30 to %.loc7_34.4
// CHECK:STDOUT: %.loc7_34.6: ref i32 = tuple_access %a.var, member2
// CHECK:STDOUT: %.loc7_34.7: init i32 = initialize_from %.loc7_33 to %.loc7_34.6
// CHECK:STDOUT: %.loc7_34.8: init (i32, i32, i32) = tuple_init %.loc7_34.1, (%.loc7_34.3, %.loc7_34.5, %.loc7_34.7)
// CHECK:STDOUT: assign %a.var, %.loc7_34.8
// CHECK:STDOUT: %.loc7_34.8: init (i32, i32, i32) = tuple_init (%.loc7_34.3, %.loc7_34.5, %.loc7_34.7) to %a.var
// CHECK:STDOUT: %.loc7_34.9: init (i32, i32, i32) = conversion %.loc7_34.1, %.loc7_34.8
// CHECK:STDOUT: assign %a.var, %.loc7_34.9
// CHECK:STDOUT: %.loc8_14: i32 = int_literal 3
// CHECK:STDOUT: %.loc8_15: type = array_type %.loc8_14, i32
// CHECK:STDOUT: %b.var: ref [i32; 3] = var "b"
Expand All @@ -50,6 +52,7 @@ var b: [i32; 3] = a;
// CHECK:STDOUT: %.loc8_19.13: i32 = int_literal 2
// CHECK:STDOUT: %.loc8_19.14: ref i32 = array_index %b.var, %.loc8_19.13
// CHECK:STDOUT: %.loc8_19.15: init i32 = initialize_from %.loc8_19.12 to %.loc8_19.14
// CHECK:STDOUT: %.loc8_19.16: init [i32; 3] = array_init %a.ref, (%.loc8_19.5, %.loc8_19.10, %.loc8_19.15) to %b.var
// CHECK:STDOUT: assign %b.var, %.loc8_19.16
// CHECK:STDOUT: %.loc8_19.16: init [i32; 3] = array_init (%.loc8_19.5, %.loc8_19.10, %.loc8_19.15) to %b.var
// CHECK:STDOUT: %.loc8_19.17: init [i32; 3] = conversion %a.ref, %.loc8_19.16
// CHECK:STDOUT: assign %b.var, %.loc8_19.17
// CHECK:STDOUT: }
43 changes: 31 additions & 12 deletions toolchain/check/testdata/array/base.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ var c: [(); 5] = ((), (), (), (), (),);
// CHECK:STDOUT: %.loc7_22.2: i32 = int_literal 0
// CHECK:STDOUT: %.loc7_22.3: ref i32 = array_index %a.var, %.loc7_22.2
// CHECK:STDOUT: %.loc7_22.4: init i32 = initialize_from %.loc7_20 to %.loc7_22.3
// CHECK:STDOUT: %.loc7_22.5: init [i32; 1] = array_init %.loc7_22.1, (%.loc7_22.4) to %a.var
// CHECK:STDOUT: assign %a.var, %.loc7_22.5
// CHECK:STDOUT: %.loc7_22.5: init [i32; 1] = array_init (%.loc7_22.4) to %a.var
// CHECK:STDOUT: %.loc7_22.6: init [i32; 1] = conversion %.loc7_22.1, %.loc7_22.5
// CHECK:STDOUT: assign %a.var, %.loc7_22.6
// CHECK:STDOUT: %.loc8_14: i32 = int_literal 2
// CHECK:STDOUT: %.loc8_15: type = array_type %.loc8_14, f64
// CHECK:STDOUT: %b.var: ref [f64; 2] = var "b"
Expand All @@ -43,10 +44,12 @@ var c: [(); 5] = ((), (), (), (), (),);
// CHECK:STDOUT: %.loc8_30.5: i32 = int_literal 1
// CHECK:STDOUT: %.loc8_30.6: ref f64 = array_index %b.var, %.loc8_30.5
// CHECK:STDOUT: %.loc8_30.7: init f64 = initialize_from %.loc8_26 to %.loc8_30.6
// CHECK:STDOUT: %.loc8_30.8: init [f64; 2] = array_init %.loc8_30.1, (%.loc8_30.4, %.loc8_30.7) to %b.var
// CHECK:STDOUT: assign %b.var, %.loc8_30.8
// CHECK:STDOUT: %.loc9_10: () = tuple_literal ()
// CHECK:STDOUT: %.loc8_30.8: init [f64; 2] = array_init (%.loc8_30.4, %.loc8_30.7) to %b.var
// CHECK:STDOUT: %.loc8_30.9: init [f64; 2] = conversion %.loc8_30.1, %.loc8_30.8
// CHECK:STDOUT: assign %b.var, %.loc8_30.9
// CHECK:STDOUT: %.loc9_10.1: () = tuple_literal ()
// CHECK:STDOUT: %.loc9_13: i32 = int_literal 5
// CHECK:STDOUT: %.loc9_10.2: type = conversion %.loc9_10.1, constants.%.loc9_10
// CHECK:STDOUT: %.loc9_14: type = array_type %.loc9_13, ()
// CHECK:STDOUT: %c.var: ref [(); 5] = var "c"
// CHECK:STDOUT: %c: ref [(); 5] = bind_name "c", %c.var
Expand All @@ -56,11 +59,27 @@ var c: [(); 5] = ((), (), (), (), (),);
// CHECK:STDOUT: %.loc9_32.1: () = tuple_literal ()
// CHECK:STDOUT: %.loc9_36.1: () = tuple_literal ()
// CHECK:STDOUT: %.loc9_38.1: ((), (), (), (), ()) = tuple_literal (%.loc9_20.1, %.loc9_24.1, %.loc9_28.1, %.loc9_32.1, %.loc9_36.1)
// CHECK:STDOUT: %.loc9_20.2: init () = tuple_init %.loc9_20.1, ()
// CHECK:STDOUT: %.loc9_24.2: init () = tuple_init %.loc9_24.1, ()
// CHECK:STDOUT: %.loc9_28.2: init () = tuple_init %.loc9_28.1, ()
// CHECK:STDOUT: %.loc9_32.2: init () = tuple_init %.loc9_32.1, ()
// CHECK:STDOUT: %.loc9_36.2: init () = tuple_init %.loc9_36.1, ()
// CHECK:STDOUT: %.loc9_38.2: init [(); 5] = array_init %.loc9_38.1, (%.loc9_20.2, %.loc9_24.2, %.loc9_28.2, %.loc9_32.2, %.loc9_36.2) to %c.var
// CHECK:STDOUT: assign %c.var, %.loc9_38.2
// CHECK:STDOUT: %.loc9_38.2: i32 = int_literal 0
// CHECK:STDOUT: %.loc9_38.3: ref () = array_index %c.var, %.loc9_38.2
// CHECK:STDOUT: %.loc9_20.2: init () = tuple_init () to %.loc9_38.3
// CHECK:STDOUT: %.loc9_20.3: init () = conversion %.loc9_20.1, %.loc9_20.2
// CHECK:STDOUT: %.loc9_38.4: i32 = int_literal 1
// CHECK:STDOUT: %.loc9_38.5: ref () = array_index %c.var, %.loc9_38.4
// CHECK:STDOUT: %.loc9_24.2: init () = tuple_init () to %.loc9_38.5
// CHECK:STDOUT: %.loc9_24.3: init () = conversion %.loc9_24.1, %.loc9_24.2
// CHECK:STDOUT: %.loc9_38.6: i32 = int_literal 2
// CHECK:STDOUT: %.loc9_38.7: ref () = array_index %c.var, %.loc9_38.6
// CHECK:STDOUT: %.loc9_28.2: init () = tuple_init () to %.loc9_38.7
// CHECK:STDOUT: %.loc9_28.3: init () = conversion %.loc9_28.1, %.loc9_28.2
// CHECK:STDOUT: %.loc9_38.8: i32 = int_literal 3
// CHECK:STDOUT: %.loc9_38.9: ref () = array_index %c.var, %.loc9_38.8
// CHECK:STDOUT: %.loc9_32.2: init () = tuple_init () to %.loc9_38.9
// CHECK:STDOUT: %.loc9_32.3: init () = conversion %.loc9_32.1, %.loc9_32.2
// CHECK:STDOUT: %.loc9_38.10: i32 = int_literal 4
// CHECK:STDOUT: %.loc9_38.11: ref () = array_index %c.var, %.loc9_38.10
// CHECK:STDOUT: %.loc9_36.2: init () = tuple_init () to %.loc9_38.11
// CHECK:STDOUT: %.loc9_36.3: init () = conversion %.loc9_36.1, %.loc9_36.2
// CHECK:STDOUT: %.loc9_38.12: init [(); 5] = array_init (%.loc9_20.3, %.loc9_24.3, %.loc9_28.3, %.loc9_32.3, %.loc9_36.3) to %c.var
// CHECK:STDOUT: %.loc9_38.13: init [(); 5] = conversion %.loc9_38.1, %.loc9_38.12
// CHECK:STDOUT: assign %c.var, %.loc9_38.13
// CHECK:STDOUT: }
4 changes: 3 additions & 1 deletion toolchain/check/testdata/array/fail_type_mismatch.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var d: [i32; 3] = t2;
// CHECK:STDOUT: %.loc10_39.4: init i32 = initialize_from %.loc10_20 to %.loc10_39.3
// CHECK:STDOUT: assign %a.var, <error>
// CHECK:STDOUT: %.loc12: (type, type, type) = tuple_literal (i32, String, String)
// CHECK:STDOUT: %.loc10_39.5: type = conversion %.loc12, constants.%.loc10_39.1
// CHECK:STDOUT: %t1.var: ref (i32, String, String) = var "t1"
// CHECK:STDOUT: %t1: ref (i32, String, String) = bind_name "t1", %t1.var
// CHECK:STDOUT: %.loc16_14: i32 = int_literal 3
Expand All @@ -72,9 +73,10 @@ var d: [i32; 3] = t2;
// CHECK:STDOUT: %c: ref [i32; 3] = bind_name "c", %c.var
// CHECK:STDOUT: %.loc21_20: i32 = int_literal 1
// CHECK:STDOUT: %.loc21_23: i32 = int_literal 2
// CHECK:STDOUT: %.loc21_24: (i32, i32) = tuple_literal (%.loc21_20, %.loc21_23)
// CHECK:STDOUT: %.loc21_24.1: (i32, i32) = tuple_literal (%.loc21_20, %.loc21_23)
// CHECK:STDOUT: assign %c.var, <error>
// CHECK:STDOUT: %.loc23: (type, type) = tuple_literal (i32, i32)
// CHECK:STDOUT: %.loc21_24.2: type = conversion %.loc23, constants.%.loc21_24.1
// CHECK:STDOUT: %t2.var: ref (i32, i32) = var "t2"
// CHECK:STDOUT: %t2: ref (i32, i32) = bind_name "t2", %t2.var
// CHECK:STDOUT: %.loc27_14: i32 = int_literal 3
Expand Down
14 changes: 8 additions & 6 deletions toolchain/check/testdata/array/function_param.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ fn G() -> i32 {
// CHECK:STDOUT: %.loc12_20.9: i32 = int_literal 2
// CHECK:STDOUT: %.loc12_20.10: ref i32 = array_index %.loc12_20.2, %.loc12_20.9
// CHECK:STDOUT: %.loc12_20.11: init i32 = initialize_from %.loc12_19 to %.loc12_20.10
// CHECK:STDOUT: %.loc12_20.12: init [i32; 3] = array_init %.loc12_20.1, (%.loc12_20.5, %.loc12_20.8, %.loc12_20.11) to %.loc12_20.2
// CHECK:STDOUT: %.loc12_20.13: ref [i32; 3] = temporary %.loc12_20.2, %.loc12_20.12
// CHECK:STDOUT: %.loc12_20.14: [i32; 3] = bind_value %.loc12_20.13
// CHECK:STDOUT: %.loc12_11: init i32 = call %F.ref(%.loc12_20.14, %.loc12_23)
// CHECK:STDOUT: %.loc12_25: i32 = value_of_initializer %.loc12_11
// CHECK:STDOUT: return %.loc12_25
// CHECK:STDOUT: %.loc12_20.12: init [i32; 3] = array_init (%.loc12_20.5, %.loc12_20.8, %.loc12_20.11) to %.loc12_20.2
// CHECK:STDOUT: %.loc12_20.13: init [i32; 3] = conversion %.loc12_20.1, %.loc12_20.12
// CHECK:STDOUT: %.loc12_20.14: ref [i32; 3] = temporary %.loc12_20.2, %.loc12_20.13
// CHECK:STDOUT: %.loc12_20.15: [i32; 3] = bind_value %.loc12_20.14
// CHECK:STDOUT: %.loc12_11: init i32 = call %F.ref(%.loc12_20.15, %.loc12_23)
// CHECK:STDOUT: %.loc12_25.1: i32 = value_of_initializer %.loc12_11
// CHECK:STDOUT: %.loc12_25.2: i32 = conversion %.loc12_11, %.loc12_25.1
// CHECK:STDOUT: return %.loc12_25.2
// CHECK:STDOUT: }
5 changes: 3 additions & 2 deletions toolchain/check/testdata/array/nine_elements.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ var a: [i32; 9] = (1, 2, 3, 4, 5, 6, 7, 8, 9);
// CHECK:STDOUT: %.loc7_45.26: i32 = int_literal 8
// CHECK:STDOUT: %.loc7_45.27: ref i32 = array_index %a.var, %.loc7_45.26
// CHECK:STDOUT: %.loc7_45.28: init i32 = initialize_from %.loc7_44 to %.loc7_45.27
// CHECK:STDOUT: %.loc7_45.29: init [i32; 9] = array_init %.loc7_45.1, (%.loc7_45.4, %.loc7_45.7, %.loc7_45.10, %.loc7_45.13, %.loc7_45.16, %.loc7_45.19, %.loc7_45.22, %.loc7_45.25, %.loc7_45.28) to %a.var
// CHECK:STDOUT: assign %a.var, %.loc7_45.29
// CHECK:STDOUT: %.loc7_45.29: init [i32; 9] = array_init (%.loc7_45.4, %.loc7_45.7, %.loc7_45.10, %.loc7_45.13, %.loc7_45.16, %.loc7_45.19, %.loc7_45.22, %.loc7_45.25, %.loc7_45.28) to %a.var
// CHECK:STDOUT: %.loc7_45.30: init [i32; 9] = conversion %.loc7_45.1, %.loc7_45.29
// CHECK:STDOUT: assign %a.var, %.loc7_45.30
// CHECK:STDOUT: }
5 changes: 3 additions & 2 deletions toolchain/check/testdata/as/as_type.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ let t: type = (i32, i32) as type;
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file "as_type.carbon" {
// CHECK:STDOUT: %.loc7: (type, type) = tuple_literal (i32, i32)
// CHECK:STDOUT: %t: type = bind_name "t", constants.%.loc7_26
// CHECK:STDOUT: %.loc7_24: (type, type) = tuple_literal (i32, i32)
// CHECK:STDOUT: %.loc7_26: type = conversion %.loc7_24, constants.%.loc7_26
// CHECK:STDOUT: %t: type = bind_name "t", %.loc7_26
// CHECK:STDOUT: }
4 changes: 3 additions & 1 deletion toolchain/check/testdata/as/fail_no_conversion.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ let n: (i32, i32) = 1 as (i32, i32);
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file "fail_no_conversion.carbon" {
// CHECK:STDOUT: %.loc10_17: (type, type) = tuple_literal (i32, i32)
// CHECK:STDOUT: %.loc10_17.1: (type, type) = tuple_literal (i32, i32)
// CHECK:STDOUT: %.loc10_17.2: type = conversion %.loc10_17.1, constants.%.loc10_17.2
// CHECK:STDOUT: %.loc10_21: i32 = int_literal 1
// CHECK:STDOUT: %.loc10_35: (type, type) = tuple_literal (i32, i32)
// CHECK:STDOUT: %.loc10_17.3: type = conversion %.loc10_35, constants.%.loc10_17.2
// CHECK:STDOUT: %n: (i32, i32) = bind_name "n", <error>
// CHECK:STDOUT: }
Loading
Loading