Просмотр исходного кода

Consolidate caller match in one function call (#4446)

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
Geoff Romer 1 год назад
Родитель
Сommit
e20e8bfbea
61 измененных файлов с 460 добавлено и 496 удалено
  1. 4 3
      toolchain/check/call.cpp
  2. 24 95
      toolchain/check/convert.cpp
  3. 10 11
      toolchain/check/convert.h
  4. 2 1
      toolchain/check/global_init.cpp
  5. 2 1
      toolchain/check/handle_function.cpp
  6. 32 1
      toolchain/check/import_ref.cpp
  7. 123 124
      toolchain/check/pattern_match.cpp
  8. 10 8
      toolchain/check/pattern_match.h
  9. 2 1
      toolchain/check/return.cpp
  10. 6 9
      toolchain/check/testdata/basics/no_prelude/multifile_raw_and_textual_ir.carbon
  11. 6 9
      toolchain/check/testdata/basics/no_prelude/multifile_raw_ir.carbon
  12. 1 1
      toolchain/check/testdata/basics/no_prelude/raw_and_textual_ir.carbon
  13. 1 1
      toolchain/check/testdata/basics/no_prelude/raw_ir.carbon
  14. 2 2
      toolchain/check/testdata/builtins/float/make_type.carbon
  15. 4 4
      toolchain/check/testdata/builtins/int/make_type_signed.carbon
  16. 4 4
      toolchain/check/testdata/builtins/int/make_type_unsigned.carbon
  17. 1 1
      toolchain/check/testdata/builtins/print.carbon
  18. 2 2
      toolchain/check/testdata/class/extend_adapt.carbon
  19. 1 1
      toolchain/check/testdata/class/fail_abstract.carbon
  20. 2 2
      toolchain/check/testdata/class/fail_addr_self.carbon
  21. 2 2
      toolchain/check/testdata/class/fail_incomplete.carbon
  22. 4 4
      toolchain/check/testdata/class/fail_memaccess_category.carbon
  23. 2 2
      toolchain/check/testdata/class/fail_method.carbon
  24. 2 2
      toolchain/check/testdata/class/fail_self.carbon
  25. 10 10
      toolchain/check/testdata/class/generic/import.carbon
  26. 9 9
      toolchain/check/testdata/class/import.carbon
  27. 5 5
      toolchain/check/testdata/class/import_base.carbon
  28. 3 3
      toolchain/check/testdata/const/import.carbon
  29. 2 2
      toolchain/check/testdata/deduce/array.carbon
  30. 1 1
      toolchain/check/testdata/function/call/fail_param_type.carbon
  31. 1 1
      toolchain/check/testdata/function/call/no_prelude/fail_runtime_implicit_param.carbon
  32. 43 43
      toolchain/check/testdata/function/declaration/import.carbon
  33. 9 9
      toolchain/check/testdata/function/definition/import.carbon
  34. 2 2
      toolchain/check/testdata/if_expr/fail_not_in_function.carbon
  35. 1 1
      toolchain/check/testdata/impl/fail_redefinition.carbon
  36. 3 3
      toolchain/check/testdata/operators/builtin/fail_and_or_not_in_function.carbon
  37. 1 1
      toolchain/check/testdata/operators/overloaded/add.carbon
  38. 1 1
      toolchain/check/testdata/operators/overloaded/bit_and.carbon
  39. 1 1
      toolchain/check/testdata/operators/overloaded/bit_or.carbon
  40. 1 1
      toolchain/check/testdata/operators/overloaded/bit_xor.carbon
  41. 1 1
      toolchain/check/testdata/operators/overloaded/div.carbon
  42. 21 21
      toolchain/check/testdata/operators/overloaded/eq.carbon
  43. 4 4
      toolchain/check/testdata/operators/overloaded/fail_assign_non_ref.carbon
  44. 2 2
      toolchain/check/testdata/operators/overloaded/fail_no_impl.carbon
  45. 4 4
      toolchain/check/testdata/operators/overloaded/fail_no_impl_for_arg.carbon
  46. 4 5
      toolchain/check/testdata/operators/overloaded/index.carbon
  47. 1 1
      toolchain/check/testdata/operators/overloaded/left_shift.carbon
  48. 1 1
      toolchain/check/testdata/operators/overloaded/mod.carbon
  49. 1 1
      toolchain/check/testdata/operators/overloaded/mul.carbon
  50. 28 28
      toolchain/check/testdata/operators/overloaded/ordered.carbon
  51. 1 1
      toolchain/check/testdata/operators/overloaded/right_shift.carbon
  52. 1 1
      toolchain/check/testdata/operators/overloaded/sub.carbon
  53. 1 1
      toolchain/check/testdata/packages/fail_conflict_no_namespaces.carbon
  54. 1 1
      toolchain/check/testdata/packages/implicit_imports_prelude.carbon
  55. 2 2
      toolchain/check/testdata/pointer/import.carbon
  56. 15 15
      toolchain/check/testdata/struct/import.carbon
  57. 15 15
      toolchain/check/testdata/tuple/import.carbon
  58. 0 1
      toolchain/diagnostics/diagnostic_kind.def
  59. 10 3
      toolchain/sem_ir/function.h
  60. 4 2
      toolchain/sem_ir/typed_insts.h
  61. 1 2
      toolchain/sem_ir/yaml_test.cpp

+ 4 - 3
toolchain/check/call.cpp

@@ -210,9 +210,10 @@ auto PerformCall(Context& context, SemIR::LocId loc_id, SemIR::InstId callee_id,
   }
 
   // Convert the arguments to match the parameters.
-  auto converted_args_id = ConvertCallArgs(
-      context, loc_id, callee_function.self_id, arg_ids, return_slot_arg_id,
-      CalleeParamsInfo(callable), *callee_specific_id);
+  auto converted_args_id =
+      ConvertCallArgs(context, loc_id, callee_function.self_id, arg_ids,
+                      return_slot_arg_id, CalleeParamsInfo(callable),
+                      callable.return_slot_pattern_id, *callee_specific_id);
   auto call_inst_id =
       context.AddInst<SemIR::Call>(loc_id, {.type_id = return_info.type_id,
                                             .callee_id = callee_id,

+ 24 - 95
toolchain/check/convert.cpp

@@ -1136,46 +1136,12 @@ auto ConvertForExplicitAs(Context& context, Parse::NodeId as_node,
                  {.kind = ConversionTarget::ExplicitAs, .type_id = type_id});
 }
 
-CARBON_DIAGNOSTIC(InCallToFunction, Note, "calling function declared here");
-
-// Convert the object argument in a method call to match the `self` parameter.
-static auto ConvertSelf(Context& context, SemIR::LocId call_loc_id,
-                        SemIRLoc callee_loc,
-                        SemIR::SpecificId callee_specific_id,
-                        SemIR::InstId self_param_id, SemIR::InstId self_id)
-    -> SemIR::InstId {
-  if (!self_id.is_valid()) {
-    CARBON_DIAGNOSTIC(MissingObjectInMethodCall, Error,
-                      "missing object argument in method call");
-    context.emitter()
-        .Build(call_loc_id, MissingObjectInMethodCall)
-        .Note(callee_loc, InCallToFunction)
-        .Emit();
-    return SemIR::InstId::BuiltinError;
-  }
-
-  bool addr_pattern = context.insts().Is<SemIR::AddrPattern>(self_param_id);
-  DiagnosticAnnotationScope annotate_diagnostics(
-      &context.emitter(), [&](auto& builder) {
-        CARBON_DIAGNOSTIC(InCallToFunctionSelf, Note,
-                          "initializing `{0:addr self|self}` parameter of "
-                          "method declared here",
-                          BoolAsSelect);
-        builder.Note(self_param_id, InCallToFunctionSelf, addr_pattern);
-      });
-
-  return CallerPatternMatch(context, callee_specific_id, self_param_id,
-                            self_id);
-}
-
 // TODO: consider moving this to pattern_match.h
-auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id,
-                     SemIR::InstId self_id,
-                     llvm::ArrayRef<SemIR::InstId> arg_refs,
-                     SemIR::InstId return_slot_arg_id,
-                     const CalleeParamsInfo& callee,
-                     SemIR::SpecificId callee_specific_id)
-    -> SemIR::InstBlockId {
+auto ConvertCallArgs(
+    Context& context, SemIR::LocId call_loc_id, SemIR::InstId self_id,
+    llvm::ArrayRef<SemIR::InstId> arg_refs, SemIR::InstId return_slot_arg_id,
+    const CalleeParamsInfo& callee, SemIR::InstId return_slot_pattern_id,
+    SemIR::SpecificId callee_specific_id) -> SemIR::InstBlockId {
   auto implicit_param_patterns =
       context.inst_blocks().GetOrEmpty(callee.implicit_param_patterns_id);
   auto param_patterns =
@@ -1184,68 +1150,31 @@ auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id,
   // The caller should have ensured this callee has the right arity.
   CARBON_CHECK(arg_refs.size() == param_patterns.size());
 
-  // Start building a block to hold the converted arguments.
-  llvm::SmallVector<SemIR::InstId> args;
-  args.reserve(implicit_param_patterns.size() + param_patterns.size() +
-               return_slot_arg_id.is_valid());
-
-  // Check implicit parameters.
+  // Find self parameter pattern.
+  // TODO: Do this during initial traversal of implicit params.
+  auto self_param_id = SemIR::InstId::Invalid;
   for (auto implicit_param_id : implicit_param_patterns) {
-    if (implicit_param_id == SemIR::InstId::BuiltinError) {
-      return SemIR::InstBlockId::Invalid;
+    if (SemIR::Function::GetNameFromPatternId(
+            context.sem_ir(), implicit_param_id) == SemIR::NameId::SelfValue) {
+      CARBON_CHECK(!self_param_id.is_valid());
+      self_param_id = implicit_param_id;
     }
-    auto param_pattern_info = SemIR::Function::GetParamPatternInfoFromPatternId(
-        context.sem_ir(), implicit_param_id);
-    if (param_pattern_info.GetNameId(context.sem_ir()) ==
-        SemIR::NameId::SelfValue) {
-      auto converted_self_id =
-          ConvertSelf(context, call_loc_id, callee.callee_loc,
-                      callee_specific_id, implicit_param_id, self_id);
-      if (converted_self_id == SemIR::InstId::BuiltinError) {
-        return SemIR::InstBlockId::Invalid;
-      }
-      args.push_back(converted_self_id);
-    } else {
-      CARBON_CHECK(!param_pattern_info.inst.runtime_index.is_valid(),
-                   "Unexpected implicit parameter passed at runtime");
-    }
-  }
-
-  // Check type conversions per-element.
-  for (auto [i, arg_id, param_pattern_id] :
-       llvm::enumerate(arg_refs, param_patterns)) {
-    auto runtime_index = SemIR::Function::GetParamPatternInfoFromPatternId(
-                             context.sem_ir(), param_pattern_id)
-                             .inst.runtime_index;
-    if (!runtime_index.is_valid()) {
-      // Not a runtime parameter: we don't pass an argument.
-      continue;
-    }
-
-    DiagnosticAnnotationScope annotate_diagnostics(
-        &context.emitter(), [&](auto& builder) {
-          CARBON_DIAGNOSTIC(InCallToFunctionParam, Note,
-                            "initializing function parameter");
-          builder.Note(param_pattern_id, InCallToFunctionParam);
-        });
-
-    auto converted_arg_id = CallerPatternMatch(context, callee_specific_id,
-                                               param_pattern_id, arg_id);
-    if (converted_arg_id == SemIR::InstId::BuiltinError) {
-      return SemIR::InstBlockId::Invalid;
-    }
-
-    CARBON_CHECK(static_cast<int32_t>(args.size()) == runtime_index.index,
-                 "Parameters not numbered in order.");
-    args.push_back(converted_arg_id);
   }
 
-  // Track the return storage, if present.
-  if (return_slot_arg_id.is_valid()) {
-    args.push_back(return_slot_arg_id);
+  if (self_param_id.is_valid() && !self_id.is_valid()) {
+    CARBON_DIAGNOSTIC(MissingObjectInMethodCall, Error,
+                      "missing object argument in method call");
+    CARBON_DIAGNOSTIC(InCallToFunction, Note, "calling function declared here");
+    context.emitter()
+        .Build(call_loc_id, MissingObjectInMethodCall)
+        .Note(callee.callee_loc, InCallToFunction)
+        .Emit();
+    self_id = SemIR::InstId::BuiltinError;
   }
 
-  return context.inst_blocks().AddOrEmpty(args);
+  return CallerPatternMatch(context, callee_specific_id, self_param_id,
+                            callee.param_patterns_id, return_slot_pattern_id,
+                            self_id, arg_refs, return_slot_arg_id);
 }
 
 auto ExprAsType(Context& context, SemIR::LocId loc_id, SemIR::InstId value_id)

+ 10 - 11
toolchain/check/convert.h

@@ -89,10 +89,11 @@ auto ConvertForExplicitAs(Context& context, Parse::NodeId as_node,
                           SemIR::InstId value_id, SemIR::TypeId type_id)
     -> SemIR::InstId;
 
-// Information about the parameters of a callee. This information is extracted
-// from the EntityWithParamsBase before calling ConvertCallArgs, because
-// conversion can trigger importing of more entities, which can invalidate the
-// reference to the callee.
+// Information about the syntactic parameters of a callee (excluding the return
+// slot, for example). This information is extracted from the
+// EntityWithParamsBase before calling ConvertCallArgs, because conversion can
+// trigger importing of more entities, which can invalidate the reference to the
+// callee.
 struct CalleeParamsInfo {
   explicit CalleeParamsInfo(const SemIR::EntityWithParamsBase& callee)
       : callee_loc(callee.latest_decl_id()),
@@ -114,13 +115,11 @@ struct CalleeParamsInfo {
 // Implicitly converts a set of arguments to match the parameter types in a
 // function call. Returns a block containing the converted implicit and explicit
 // argument values for runtime parameters.
-auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id,
-                     SemIR::InstId self_id,
-                     llvm::ArrayRef<SemIR::InstId> arg_refs,
-                     SemIR::InstId return_slot_arg_id,
-                     const CalleeParamsInfo& callee,
-                     SemIR::SpecificId callee_specific_id)
-    -> SemIR::InstBlockId;
+auto ConvertCallArgs(
+    Context& context, SemIR::LocId call_loc_id, SemIR::InstId self_id,
+    llvm::ArrayRef<SemIR::InstId> arg_refs, SemIR::InstId return_slot_arg_id,
+    const CalleeParamsInfo& callee, SemIR::InstId return_slot_pattern_id,
+    SemIR::SpecificId callee_specific_id) -> SemIR::InstBlockId;
 
 // A type that has been converted for use as a type expression.
 struct TypeExpr {

+ 2 - 1
toolchain/check/global_init.cpp

@@ -49,7 +49,8 @@ auto GlobalInit::Finalize() -> void {
         .extern_library_id = SemIR::LibraryNameId::Invalid,
         .non_owning_decl_id = SemIR::InstId::Invalid,
         .first_owning_decl_id = SemIR::InstId::Invalid},
-       {.return_slot_id = SemIR::InstId::Invalid,
+       {.return_slot_pattern_id = SemIR::InstId::Invalid,
+        .return_slot_id = SemIR::InstId::Invalid,
         .body_block_ids = {SemIR::InstBlockId::GlobalInit}}}));
 }
 

+ 2 - 1
toolchain/check/handle_function.cpp

@@ -236,7 +236,8 @@ static auto BuildFunctionDecl(Context& context,
   auto function_info =
       SemIR::Function{{name_context.MakeEntityWithParamsBase(
                           name, decl_id, is_extern, introducer.extern_library)},
-                      {.return_slot_id = name.return_slot_id,
+                      {.return_slot_pattern_id = name.return_slot_pattern_id,
+                       .return_slot_id = name.return_slot_id,
                        .virtual_modifier = virtual_modifier}};
   if (is_definition) {
     function_info.definition_id = decl_id;

+ 32 - 1
toolchain/check/import_ref.cpp

@@ -888,6 +888,34 @@ class ImportRefResolver {
     return context_.inst_blocks().Add(new_patterns);
   }
 
+  // Returns a version of import_return_slot_pattern_id localized to the current
+  // IR.
+  auto GetLocalReturnSlotPatternId(SemIR::InstId import_return_slot_pattern_id)
+      -> SemIR::InstId {
+    if (!import_return_slot_pattern_id.is_valid()) {
+      return SemIR::InstId::Invalid;
+    }
+
+    auto param_pattern = import_ir_.insts().GetAs<SemIR::OutParamPattern>(
+        import_return_slot_pattern_id);
+    auto return_slot_pattern =
+        import_ir_.insts().GetAs<SemIR::ReturnSlotPattern>(
+            param_pattern.subpattern_id);
+    auto type_id = context_.GetTypeIdForTypeConstant(
+        GetLocalConstantIdChecked(return_slot_pattern.type_id));
+
+    auto new_return_slot_pattern_id = context_.AddInstInNoBlock(
+        context_.MakeImportedLocAndInst<SemIR::ReturnSlotPattern>(
+            AddImportIRInst(param_pattern.subpattern_id),
+            {.type_id = type_id, .type_inst_id = SemIR::InstId::Invalid}));
+    return context_.AddInstInNoBlock(
+        context_.MakeImportedLocAndInst<SemIR::OutParamPattern>(
+            AddImportIRInst(import_return_slot_pattern_id),
+            {.type_id = type_id,
+             .subpattern_id = new_return_slot_pattern_id,
+             .runtime_index = param_pattern.runtime_index}));
+  }
+
   // Translates a NameId from the import IR to a local NameId.
   auto GetLocalNameId(SemIR::NameId import_name_id) -> SemIR::NameId {
     if (auto ident_id = import_name_id.AsIdentifierId(); ident_id.is_valid()) {
@@ -1600,7 +1628,8 @@ class ImportRefResolver {
     // Start with an incomplete function.
     function_decl.function_id = context_.functions().Add(
         {GetIncompleteLocalEntityBase(function_decl_id, import_function),
-         {.return_slot_id = SemIR::InstId::Invalid,
+         {.return_slot_pattern_id = SemIR::InstId::Invalid,
+          .return_slot_id = SemIR::InstId::Invalid,
           .builtin_function_kind = import_function.builtin_function_kind}});
 
     function_decl.type_id =
@@ -1671,6 +1700,8 @@ class ImportRefResolver {
         GetLocalParamRefsId(import_function.param_refs_id);
     new_function.param_patterns_id =
         GetLocalParamPatternsId(import_function.param_patterns_id);
+    new_function.return_slot_pattern_id =
+        GetLocalReturnSlotPatternId(import_function.return_slot_pattern_id);
     SetGenericData(import_function.generic_id, new_function.generic_id,
                    generic_data);
 

+ 123 - 124
toolchain/check/pattern_match.cpp

@@ -14,13 +14,12 @@
 #include "toolchain/check/convert.h"
 
 namespace Carbon::Check {
-namespace {
 
 // Returns a best-effort name for the given ParamPattern, suitable for use in
 // IR pretty-printing.
 // TODO: Resolve overlap with SemIR::Function::ParamPatternInfo::GetNameId
 template <typename ParamPattern>
-auto GetPrettyName(Context& context, ParamPattern param_pattern)
+static auto GetPrettyName(Context& context, ParamPattern param_pattern)
     -> SemIR::NameId {
   if (context.insts().Is<SemIR::ReturnSlotPattern>(
           param_pattern.subpattern_id)) {
@@ -33,6 +32,8 @@ auto GetPrettyName(Context& context, ParamPattern param_pattern)
   return SemIR::NameId::Invalid;
 }
 
+namespace {
+
 // Selects between the different kinds of pattern matching.
 enum class MatchKind {
   // Caller pattern matching occurs on the caller side of a function call, and
@@ -63,22 +64,22 @@ class MatchContext {
   explicit MatchContext(MatchKind kind, SemIR::SpecificId callee_specific_id =
                                             SemIR::SpecificId::Invalid)
       : next_index_(0),
-        result_(SemIR::InstId::Invalid),
         kind_(kind),
         callee_specific_id_(callee_specific_id),
         return_slot_id_(SemIR::InstId::Invalid) {}
 
-  // Returns whether there are any work items to process.
-  auto HasWork() const -> bool {
-    return !stack_.empty() && !result_.is_valid();
-  }
-
-  // Adds a work item to the stack. Cannot be called after Finish().
+  // Adds a work item to the stack.
   auto AddWork(WorkItem work_item) -> void { stack_.push_back(work_item); }
 
-  // Returns the next work item to process.
-  auto NextWorkItem() -> WorkItem { return stack_.pop_back_val(); }
+  // Processes all work items on the stack. When performing caller pattern
+  // matching, returns an inst block with one inst reference for each
+  // calling-convention argument. When performing callee pattern matching,
+  // returns an inst block with references to all the emitted BindName insts.
+  auto DoWork(Context& context) -> SemIR::InstBlockId;
+
+  auto return_slot_id() const -> SemIR::InstId { return return_slot_id_; }
 
+ private:
   // Allocates the next unallocated RuntimeParamIndex, starting from 0.
   auto NextRuntimeIndex() -> SemIR::RuntimeParamIndex {
     auto result = next_index_;
@@ -86,95 +87,69 @@ class MatchContext {
     return result;
   }
 
-  // TODO: Eliminate the caller/callee API split below, by restructuring
-  // CallerPatternMatch to operate on the whole pattern.
-
-  // Sets the result of this pattern matching operation. Must not be called when
-  // there is still pending work, except to report an error, or called more than
-  // once between calls to ConsumeResult. Valid only during caller matching.
-  auto Finish(SemIR::InstId result) -> void {
-    CARBON_CHECK(!HasWork() || result == SemIR::InstId::BuiltinError);
-    CARBON_CHECK(kind_ == MatchKind::Caller);
-    CARBON_CHECK(result_ == SemIR::InstId::Invalid);
-    result_ = result;
-  }
-
-  // Consumes and returns the result stored by Finish. Valid only during caller
-  // matching.
-  auto ConsumeResult() -> SemIR::InstId {
-    CARBON_CHECK(stack_.empty() || result_ == SemIR::InstId::BuiltinError);
-    CARBON_CHECK(kind_ == MatchKind::Caller);
-    return std::exchange(result_, SemIR::InstId::Invalid);
-  }
-
-  // Records that `bind_name_id` is the ID of an inst in the AnyBindName
-  // category, emitted as part of this pattern match. Valid only during callee
-  // pattern matching.
-  auto RecordBindName(SemIR::InstId bind_name_id) {
-    CARBON_CHECK(kind_ == MatchKind::Callee);
-    bind_name_ids_.push_back(bind_name_id);
-  }
-
-  // Allocates an InstBlock containing the IDs recorded by RecordBindName since
-  // the last call to this function (if any), and returns its ID. Valid only
-  // during callee pattern matching.
-  auto ConsumeBindNames(Context& context) -> SemIR::InstBlockId {
-    CARBON_CHECK(stack_.empty());
-    CARBON_CHECK(kind_ == MatchKind::Callee);
-    auto block_id = context.inst_blocks().Add(bind_name_ids_);
-    bind_name_ids_.clear();
-    return block_id;
-  }
-
-  auto kind() const -> MatchKind { return kind_; }
-
-  auto callee_specific_id() const -> SemIR::SpecificId {
-    return callee_specific_id_;
-  }
-
-  auto return_slot_id() const -> SemIR::InstId { return return_slot_id_; }
-
-  auto set_return_slot_id(SemIR::InstId return_slot_id) {
-    return_slot_id_ = return_slot_id;
-  }
-
- private:
+  // Emits the pattern-match insts necessary to match the pattern inst
+  // `entry.pattern_id` against the scrutinee value `entry.scrutinee_id`, and
+  // adds to `stack_` any work necessary to traverse into its subpatterns. This
+  // behavior is contingent on the kind of match being performed, as indicated
+  // by kind_`. For example, when performing a callee pattern match, this does
+  // not emit insts for patterns on the caller side. However, it still traverses
+  // into subpatterns if any of their descendants might emit insts.
+  // TODO: Require that `entry.scrutinee_id` is valid if and only if insts
+  // should be emitted, once we start emitting `Param` insts in the
+  // `ParamPattern` case.
+  auto EmitPatternMatch(Context& context, MatchContext::WorkItem entry) -> void;
+
+  // The stack of work to be processed.
   llvm::SmallVector<WorkItem> stack_;
 
+  // The next index to be allocated by `NextRuntimeIndex`.
   SemIR::RuntimeParamIndex next_index_;
 
-  SemIR::InstId result_;
-
-  llvm::SmallVector<SemIR::InstId> bind_name_ids_;
+  // The pending results that will be returned by the current `DoWork` call.
+  llvm::SmallVector<SemIR::InstId> results_;
 
+  // The kind of pattern match being performed.
   MatchKind kind_;
 
+  // The SpecificId of the function being called (if any).
   SemIR::SpecificId callee_specific_id_;
 
+  // The return slot inst emitted by `DoWork`, if any.
+  // TODO: can this be added to the block returned by `DoWork`, instead?
   SemIR::InstId return_slot_id_;
 };
 
-// Emits the pattern-match insts necessary to match the pattern inst
-// `entry.pattern_id` against the scrutinee value `entry.scrutinee_id`,
-// and adds to `match` any work necessary to traverse into its subpatterns.
-// This behavior is contingent on the kind of match being performed, as
-// indicated by `match.kind()`. For example, when performing a callee
-// pattern match, this does not emit insts for patterns on the caller side.
-// However, it still traverses into subpatterns if any of their descendants
-// might emit insts.
-// TODO: Require that `entry.scrutinee_id` is valid if and only if insts should
-// be emitted, once we start emitting `Param` insts in the `ParamPattern` case.
-auto EmitPatternMatch(Context& context, MatchContext& match,
-                      MatchContext::WorkItem entry) -> void {
+}  // namespace
+
+auto MatchContext::DoWork(Context& context) -> SemIR::InstBlockId {
+  results_.reserve(stack_.size());
+  while (!stack_.empty()) {
+    EmitPatternMatch(context, stack_.pop_back_val());
+  }
+  auto block_id = context.inst_blocks().AddOrEmpty(results_);
+  results_.clear();
+  return block_id;
+}
+
+auto MatchContext::EmitPatternMatch(Context& context,
+                                    MatchContext::WorkItem entry) -> void {
   if (entry.pattern_id == SemIR::InstId::BuiltinError) {
-    match.RecordBindName(SemIR::InstId::BuiltinError);
+    results_.push_back(SemIR::InstId::BuiltinError);
     return;
   }
+  DiagnosticAnnotationScope annotate_diagnostics(
+      &context.emitter(), [&](auto& builder) {
+        if (kind_ == MatchKind::Caller) {
+          CARBON_DIAGNOSTIC(InCallToFunctionParam, Note,
+                            "initializing function parameter");
+          builder.Note(entry.pattern_id, InCallToFunctionParam);
+        }
+      });
   auto pattern = context.insts().GetWithLocId(entry.pattern_id);
   CARBON_KIND_SWITCH(pattern.inst) {
     case SemIR::BindingPattern::Kind:
     case SemIR::SymbolicBindingPattern::Kind: {
-      CARBON_CHECK(match.kind() == MatchKind::Callee);
+      CARBON_CHECK(kind_ == MatchKind::Callee);
       auto binding_pattern = pattern.inst.As<SemIR::AnyBindingPattern>();
       auto bind_name = context.insts().GetAs<SemIR::AnyBindName>(
           binding_pattern.bind_name_id);
@@ -183,16 +158,16 @@ auto EmitPatternMatch(Context& context, MatchContext& match,
       context.ReplaceInstBeforeConstantUse(binding_pattern.bind_name_id,
                                            bind_name);
       context.inst_block_stack().AddInstId(binding_pattern.bind_name_id);
-      match.RecordBindName(binding_pattern.bind_name_id);
+      results_.push_back(binding_pattern.bind_name_id);
       break;
     }
     case CARBON_KIND(SemIR::AddrPattern addr_pattern): {
-      if (match.kind() == MatchKind::Callee) {
+      if (kind_ == MatchKind::Callee) {
         // We're emitting pattern-match IR for the callee, but we're still on
         // the caller side of the pattern, so we traverse without emitting any
         // insts.
-        match.AddWork({.pattern_id = addr_pattern.inner_id,
-                       .scrutinee_id = SemIR::InstId::Invalid});
+        AddWork({.pattern_id = addr_pattern.inner_id,
+                 .scrutinee_id = SemIR::InstId::Invalid});
         break;
       }
       CARBON_CHECK(entry.scrutinee_id.is_valid());
@@ -209,7 +184,7 @@ auto EmitPatternMatch(Context& context, MatchContext& match,
           context.emitter().Emit(
               TokenOnly(context.insts().GetLocId(entry.scrutinee_id)),
               AddrSelfIsNonRef);
-          match.Finish(SemIR::InstId::BuiltinError);
+          results_.push_back(SemIR::InstId::BuiltinError);
           return;
       }
       auto scrutinee_ref = context.insts().Get(scrutinee_ref_id);
@@ -217,20 +192,28 @@ auto EmitPatternMatch(Context& context, MatchContext& match,
           context.insts().GetLocId(scrutinee_ref_id),
           {.type_id = context.GetPointerType(scrutinee_ref.type_id()),
            .lvalue_id = scrutinee_ref_id});
-      match.AddWork(
+      AddWork(
           {.pattern_id = addr_pattern.inner_id, .scrutinee_id = new_scrutinee});
       break;
     }
     case CARBON_KIND(SemIR::ValueParamPattern param_pattern): {
-      switch (match.kind()) {
+      CARBON_CHECK(param_pattern.runtime_index.index < 0 ||
+                       static_cast<size_t>(param_pattern.runtime_index.index) ==
+                           results_.size(),
+                   "Parameters out of order; expecting {0} but got {1}",
+                   results_.size(), param_pattern.runtime_index.index);
+      switch (kind_) {
         case MatchKind::Caller: {
           CARBON_CHECK(entry.scrutinee_id.is_valid());
-          match.Finish(ConvertToValueOfType(
-              context, context.insts().GetLocId(entry.scrutinee_id),
-              entry.scrutinee_id,
-              SemIR::GetTypeInSpecific(context.sem_ir(),
-                                       match.callee_specific_id(),
-                                       param_pattern.type_id)));
+          if (entry.scrutinee_id == SemIR::InstId::BuiltinError) {
+            results_.push_back(SemIR::InstId::BuiltinError);
+          } else {
+            results_.push_back(ConvertToValueOfType(
+                context, context.insts().GetLocId(entry.scrutinee_id),
+                entry.scrutinee_id,
+                SemIR::GetTypeInSpecific(context.sem_ir(), callee_specific_id_,
+                                         param_pattern.type_id)));
+          }
           // Do not traverse farther, because the caller side of the pattern
           // ends here.
           break;
@@ -238,11 +221,11 @@ auto EmitPatternMatch(Context& context, MatchContext& match,
         case MatchKind::Callee: {
           if (param_pattern.runtime_index ==
               SemIR::RuntimeParamIndex::Unknown) {
-            param_pattern.runtime_index = match.NextRuntimeIndex();
+            param_pattern.runtime_index = NextRuntimeIndex();
             context.ReplaceInstBeforeConstantUse(entry.pattern_id,
                                                  param_pattern);
           }
-          match.AddWork(
+          AddWork(
               {.pattern_id = param_pattern.subpattern_id,
                .scrutinee_id = context.AddInst<SemIR::ValueParam>(
                    pattern.loc_id,
@@ -255,14 +238,14 @@ auto EmitPatternMatch(Context& context, MatchContext& match,
       break;
     }
     case CARBON_KIND(SemIR::OutParamPattern param_pattern): {
-      switch (match.kind()) {
+      switch (kind_) {
         case MatchKind::Caller: {
           CARBON_CHECK(entry.scrutinee_id.is_valid());
           CARBON_CHECK(context.insts().Get(entry.scrutinee_id).type_id() ==
                        SemIR::GetTypeInSpecific(context.sem_ir(),
-                                                match.callee_specific_id(),
+                                                callee_specific_id_,
                                                 param_pattern.type_id));
-          match.Finish(entry.scrutinee_id);
+          results_.push_back(entry.scrutinee_id);
           // Do not traverse farther, because the caller side of the pattern
           // ends here.
           break;
@@ -272,11 +255,11 @@ auto EmitPatternMatch(Context& context, MatchContext& match,
           // ValueParamPattern case.
           if (param_pattern.runtime_index ==
               SemIR::RuntimeParamIndex::Unknown) {
-            param_pattern.runtime_index = match.NextRuntimeIndex();
+            param_pattern.runtime_index = NextRuntimeIndex();
             context.ReplaceInstBeforeConstantUse(entry.pattern_id,
                                                  param_pattern);
           }
-          match.AddWork(
+          AddWork(
               {.pattern_id = param_pattern.subpattern_id,
                .scrutinee_id = context.AddInst<SemIR::OutParam>(
                    pattern.loc_id,
@@ -289,11 +272,11 @@ auto EmitPatternMatch(Context& context, MatchContext& match,
       break;
     }
     case CARBON_KIND(SemIR::ReturnSlotPattern return_slot_pattern): {
-      CARBON_CHECK(match.kind() == MatchKind::Callee);
-      match.set_return_slot_id(context.AddInst<SemIR::ReturnSlot>(
+      CARBON_CHECK(kind_ == MatchKind::Callee);
+      return_slot_id_ = context.AddInst<SemIR::ReturnSlot>(
           pattern.loc_id, {.type_id = return_slot_pattern.type_id,
                            .type_inst_id = return_slot_pattern.type_inst_id,
-                           .storage_id = entry.scrutinee_id}));
+                           .storage_id = entry.scrutinee_id});
       break;
     }
     default: {
@@ -302,8 +285,6 @@ auto EmitPatternMatch(Context& context, MatchContext& match,
   }
 }
 
-}  // namespace
-
 auto CalleePatternMatch(Context& context,
                         SemIR::InstBlockId implicit_param_patterns_id,
                         SemIR::InstBlockId param_patterns_id,
@@ -313,7 +294,6 @@ auto CalleePatternMatch(Context& context,
   auto implicit_params_id = SemIR::InstBlockId::Invalid;
 
   MatchContext match(MatchKind::Callee);
-  // TODO reserve space in bind_name_ids_
 
   if (implicit_param_patterns_id.is_valid()) {
     // We add work to the stack in reverse so that the results will be produced
@@ -323,10 +303,7 @@ auto CalleePatternMatch(Context& context,
       match.AddWork(
           {.pattern_id = inst_id, .scrutinee_id = SemIR::InstId::Invalid});
     }
-    while (match.HasWork()) {
-      EmitPatternMatch(context, match, match.NextWorkItem());
-    }
-    implicit_params_id = match.ConsumeBindNames(context);
+    implicit_params_id = match.DoWork(context);
   }
 
   if (param_patterns_id.is_valid()) {
@@ -335,18 +312,13 @@ auto CalleePatternMatch(Context& context,
       match.AddWork(
           {.pattern_id = inst_id, .scrutinee_id = SemIR::InstId::Invalid});
     }
-    while (match.HasWork()) {
-      EmitPatternMatch(context, match, match.NextWorkItem());
-    }
-    params_id = match.ConsumeBindNames(context);
+    params_id = match.DoWork(context);
   }
 
   if (return_slot_pattern_id.is_valid()) {
     match.AddWork({.pattern_id = return_slot_pattern_id,
                    .scrutinee_id = SemIR::InstId::Invalid});
-    while (match.HasWork()) {
-      EmitPatternMatch(context, match, match.NextWorkItem());
-    }
+    CARBON_CHECK(match.DoWork(context) == SemIR::InstBlockId::Empty);
   }
 
   return {.implicit_params_id = implicit_params_id,
@@ -355,14 +327,41 @@ auto CalleePatternMatch(Context& context,
 }
 
 auto CallerPatternMatch(Context& context, SemIR::SpecificId specific_id,
-                        SemIR::InstId param, SemIR::InstId arg)
-    -> SemIR::InstId {
+                        SemIR::InstId self_pattern_id,
+                        SemIR::InstBlockId param_patterns_id,
+                        SemIR::InstId return_slot_pattern_id,
+                        SemIR::InstId self_arg_id,
+                        llvm::ArrayRef<SemIR::InstId> arg_refs,
+                        SemIR::InstId return_slot_arg_id)
+    -> SemIR::InstBlockId {
   MatchContext match(MatchKind::Caller, specific_id);
-  match.AddWork({.pattern_id = param, .scrutinee_id = arg});
-  while (match.HasWork()) {
-    EmitPatternMatch(context, match, match.NextWorkItem());
+
+  // Track the return storage, if present.
+  if (return_slot_arg_id.is_valid()) {
+    CARBON_CHECK(return_slot_pattern_id.is_valid());
+    match.AddWork({.pattern_id = return_slot_pattern_id,
+                   .scrutinee_id = return_slot_arg_id});
+  }
+
+  // Check type conversions per-element.
+  for (auto [arg_id, param_pattern_id] : llvm::reverse(llvm::zip_equal(
+           arg_refs, context.inst_blocks().GetOrEmpty(param_patterns_id)))) {
+    auto runtime_index = SemIR::Function::GetParamPatternInfoFromPatternId(
+                             context.sem_ir(), param_pattern_id)
+                             .inst.runtime_index;
+    if (!runtime_index.is_valid()) {
+      // Not a runtime parameter: we don't pass an argument.
+      continue;
+    }
+
+    match.AddWork({.pattern_id = param_pattern_id, .scrutinee_id = arg_id});
   }
-  return match.ConsumeResult();
+
+  if (self_pattern_id.is_valid()) {
+    match.AddWork({.pattern_id = self_pattern_id, .scrutinee_id = self_arg_id});
+  }
+
+  return match.DoWork(context);
 }
 
 }  // namespace Carbon::Check

+ 10 - 8
toolchain/check/pattern_match.h

@@ -45,15 +45,17 @@ auto CalleePatternMatch(Context& context,
                         SemIR::InstId return_slot_pattern_id)
     -> ParameterBlocks;
 
-// Emits the pattern-match IR for matching the given argument with the given
-// parameter pattern, and returns the inst representing the resulting
-// calling-convention argument. This IR performs the caller side of pattern
-// matching that argument.
-//
-// TODO: restructure to have this handle the entire signature.
+// Emits the pattern-match IR for matching the given arguments with the given
+// parameter patterns, and returns an inst block with one inst for each
+// calling convention argument. This IR performs the caller side of pattern
+// matching.
 auto CallerPatternMatch(Context& context, SemIR::SpecificId specific_id,
-                        SemIR::InstId param, SemIR::InstId arg)
-    -> SemIR::InstId;
+                        SemIR::InstId self_pattern_id,
+                        SemIR::InstBlockId param_patterns_id,
+                        SemIR::InstId return_slot_pattern_id,
+                        SemIR::InstId self_arg_id,
+                        llvm::ArrayRef<SemIR::InstId> arg_refs,
+                        SemIR::InstId return_slot_arg_id) -> SemIR::InstBlockId;
 
 }  // namespace Carbon::Check
 

+ 2 - 1
toolchain/check/return.cpp

@@ -36,7 +36,8 @@ static auto NoteNoReturnTypeProvided(Context::DiagnosticBuilder& diag,
   diag.Note(function.latest_decl_id(), ReturnTypeOmittedNote);
 }
 
-// Produces a note describing the return type of the given function.
+// Produces a note describing the return type of the given function, which
+// must be a function whose definition is currently being checked.
 static auto NoteReturnType(Context& context, Context::DiagnosticBuilder& diag,
                            const SemIR::Function& function) {
   auto return_type_inst_id =

+ 6 - 9
toolchain/check/testdata/basics/no_prelude/multifile_raw_and_textual_ir.carbon

@@ -36,7 +36,7 @@ fn B() {
 // CHECK:STDOUT:     name_scope0:     {inst: inst+0, parent_scope: name_scope<invalid>, has_error: false, extended_scopes: [], names: {name0: inst+1}}
 // CHECK:STDOUT:   entity_names:    {}
 // CHECK:STDOUT:   functions:
-// CHECK:STDOUT:     function0:       {name: name0, parent_scope: name_scope0, body: [block5]}
+// CHECK:STDOUT:     function0:       {name: name0, parent_scope: name_scope0, body: [block4]}
 // CHECK:STDOUT:   classes:         {}
 // CHECK:STDOUT:   generics:        {}
 // CHECK:STDOUT:   specifics:       {}
@@ -68,10 +68,9 @@ fn B() {
 // CHECK:STDOUT:       0:               inst+1
 // CHECK:STDOUT:     import_refs:     {}
 // CHECK:STDOUT:     global_init:     {}
-// CHECK:STDOUT:     block4:          {}
-// CHECK:STDOUT:     block5:
+// CHECK:STDOUT:     block4:
 // CHECK:STDOUT:       0:               inst+5
-// CHECK:STDOUT:     block6:
+// CHECK:STDOUT:     block5:
 // CHECK:STDOUT:       0:               inst+0
 // CHECK:STDOUT:       1:               inst+1
 // CHECK:STDOUT: ...
@@ -111,7 +110,7 @@ fn B() {
 // CHECK:STDOUT:   entity_names:
 // CHECK:STDOUT:     entity_name0:    {name: name1, parent_scope: name_scope1, index: comp_time_bind<invalid>}
 // CHECK:STDOUT:   functions:
-// CHECK:STDOUT:     function0:       {name: name0, parent_scope: name_scope0, body: [block5]}
+// CHECK:STDOUT:     function0:       {name: name0, parent_scope: name_scope0, body: [block4]}
 // CHECK:STDOUT:     function1:       {name: name1, parent_scope: name_scope1}
 // CHECK:STDOUT:   classes:         {}
 // CHECK:STDOUT:   generics:        {}
@@ -163,14 +162,12 @@ fn B() {
 // CHECK:STDOUT:       0:               inst+2
 // CHECK:STDOUT:       1:               inst+8
 // CHECK:STDOUT:     global_init:     {}
-// CHECK:STDOUT:     block4:          {}
-// CHECK:STDOUT:     block5:
+// CHECK:STDOUT:     block4:
 // CHECK:STDOUT:       0:               inst+7
 // CHECK:STDOUT:       1:               inst+12
 // CHECK:STDOUT:       2:               inst+13
 // CHECK:STDOUT:       3:               inst+14
-// CHECK:STDOUT:     block6:          {}
-// CHECK:STDOUT:     block7:
+// CHECK:STDOUT:     block5:
 // CHECK:STDOUT:       0:               inst+0
 // CHECK:STDOUT:       1:               inst+1
 // CHECK:STDOUT:       2:               inst+3

+ 6 - 9
toolchain/check/testdata/basics/no_prelude/multifile_raw_ir.carbon

@@ -36,7 +36,7 @@ fn B() {
 // CHECK:STDOUT:     name_scope0:     {inst: inst+0, parent_scope: name_scope<invalid>, has_error: false, extended_scopes: [], names: {name0: inst+1}}
 // CHECK:STDOUT:   entity_names:    {}
 // CHECK:STDOUT:   functions:
-// CHECK:STDOUT:     function0:       {name: name0, parent_scope: name_scope0, body: [block5]}
+// CHECK:STDOUT:     function0:       {name: name0, parent_scope: name_scope0, body: [block4]}
 // CHECK:STDOUT:   classes:         {}
 // CHECK:STDOUT:   generics:        {}
 // CHECK:STDOUT:   specifics:       {}
@@ -68,10 +68,9 @@ fn B() {
 // CHECK:STDOUT:       0:               inst+1
 // CHECK:STDOUT:     import_refs:     {}
 // CHECK:STDOUT:     global_init:     {}
-// CHECK:STDOUT:     block4:          {}
-// CHECK:STDOUT:     block5:
+// CHECK:STDOUT:     block4:
 // CHECK:STDOUT:       0:               inst+5
-// CHECK:STDOUT:     block6:
+// CHECK:STDOUT:     block5:
 // CHECK:STDOUT:       0:               inst+0
 // CHECK:STDOUT:       1:               inst+1
 // CHECK:STDOUT: ...
@@ -90,7 +89,7 @@ fn B() {
 // CHECK:STDOUT:   entity_names:
 // CHECK:STDOUT:     entity_name0:    {name: name1, parent_scope: name_scope1, index: comp_time_bind<invalid>}
 // CHECK:STDOUT:   functions:
-// CHECK:STDOUT:     function0:       {name: name0, parent_scope: name_scope0, body: [block5]}
+// CHECK:STDOUT:     function0:       {name: name0, parent_scope: name_scope0, body: [block4]}
 // CHECK:STDOUT:     function1:       {name: name1, parent_scope: name_scope1}
 // CHECK:STDOUT:   classes:         {}
 // CHECK:STDOUT:   generics:        {}
@@ -142,14 +141,12 @@ fn B() {
 // CHECK:STDOUT:       0:               inst+2
 // CHECK:STDOUT:       1:               inst+8
 // CHECK:STDOUT:     global_init:     {}
-// CHECK:STDOUT:     block4:          {}
-// CHECK:STDOUT:     block5:
+// CHECK:STDOUT:     block4:
 // CHECK:STDOUT:       0:               inst+7
 // CHECK:STDOUT:       1:               inst+12
 // CHECK:STDOUT:       2:               inst+13
 // CHECK:STDOUT:       3:               inst+14
-// CHECK:STDOUT:     block6:          {}
-// CHECK:STDOUT:     block7:
+// CHECK:STDOUT:     block5:
 // CHECK:STDOUT:       0:               inst+0
 // CHECK:STDOUT:       1:               inst+1
 // CHECK:STDOUT:       2:               inst+3

+ 1 - 1
toolchain/check/testdata/basics/no_prelude/raw_and_textual_ir.carbon

@@ -27,7 +27,7 @@ fn Foo(n: ()) -> ((), ()) {
 // CHECK:STDOUT:   entity_names:
 // CHECK:STDOUT:     entity_name0:    {name: name1, parent_scope: name_scope<invalid>, index: comp_time_bind<invalid>}
 // CHECK:STDOUT:   functions:
-// CHECK:STDOUT:     function0:       {name: name0, parent_scope: name_scope0, return_slot: inst+18, body: [block9]}
+// CHECK:STDOUT:     function0:       {name: name0, parent_scope: name_scope0, return_slot_pattern: inst+15, return_slot: inst+18, body: [block9]}
 // CHECK:STDOUT:   classes:         {}
 // CHECK:STDOUT:   generics:        {}
 // CHECK:STDOUT:   specifics:       {}

+ 1 - 1
toolchain/check/testdata/basics/no_prelude/raw_ir.carbon

@@ -28,7 +28,7 @@ fn Foo[T:! type](n: T) -> (T, ()) {
 // CHECK:STDOUT:     entity_name0:    {name: name1, parent_scope: name_scope<invalid>, index: comp_time_bind0}
 // CHECK:STDOUT:     entity_name1:    {name: name2, parent_scope: name_scope<invalid>, index: comp_time_bind<invalid>}
 // CHECK:STDOUT:   functions:
-// CHECK:STDOUT:     function0:       {name: name0, parent_scope: name_scope0, return_slot: inst+23, body: [block15]}
+// CHECK:STDOUT:     function0:       {name: name0, parent_scope: name_scope0, return_slot_pattern: inst+19, return_slot: inst+23, body: [block15]}
 // CHECK:STDOUT:   classes:         {}
 // CHECK:STDOUT:   generics:
 // CHECK:STDOUT:     generic0:        {decl: inst+24, bindings: block11}

+ 2 - 2
toolchain/check/testdata/builtins/float/make_type.carbon

@@ -111,7 +111,7 @@ var dyn: Float(dyn_size);
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
-// CHECK:STDOUT:   %import_ref.1: %Float.type = import_ref Main//types, inst+20, loaded [template = constants.%Float]
+// CHECK:STDOUT:   %import_ref.1: %Float.type = import_ref Main//types, inst+22, loaded [template = constants.%Float]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.2
 // CHECK:STDOUT:     import Core//prelude
@@ -193,7 +193,7 @@ var dyn: Float(dyn_size);
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
-// CHECK:STDOUT:   %import_ref.1: %Float.type = import_ref Main//types, inst+20, loaded [template = constants.%Float]
+// CHECK:STDOUT:   %import_ref.1: %Float.type = import_ref Main//types, inst+22, loaded [template = constants.%Float]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.2
 // CHECK:STDOUT:     import Core//prelude

+ 4 - 4
toolchain/check/testdata/builtins/int/make_type_signed.carbon

@@ -145,7 +145,7 @@ var m: Int(1000000000);
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
-// CHECK:STDOUT:   %import_ref.1: %Int.type = import_ref Main//types, inst+20, loaded [template = constants.%Int]
+// CHECK:STDOUT:   %import_ref.1: %Int.type = import_ref Main//types, inst+22, loaded [template = constants.%Int]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.2
 // CHECK:STDOUT:     import Core//prelude
@@ -289,7 +289,7 @@ var m: Int(1000000000);
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
-// CHECK:STDOUT:   %import_ref: %Int.type = import_ref Main//types, inst+20, loaded [template = constants.%Int]
+// CHECK:STDOUT:   %import_ref: %Int.type = import_ref Main//types, inst+22, loaded [template = constants.%Int]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     import Core//prelude
 // CHECK:STDOUT:     import Core//prelude/operators
@@ -337,7 +337,7 @@ var m: Int(1000000000);
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
-// CHECK:STDOUT:   %import_ref.1: %Int.type = import_ref Main//types, inst+20, loaded [template = constants.%Int]
+// CHECK:STDOUT:   %import_ref.1: %Int.type = import_ref Main//types, inst+22, loaded [template = constants.%Int]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.2
 // CHECK:STDOUT:     import Core//prelude
@@ -408,7 +408,7 @@ var m: Int(1000000000);
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
-// CHECK:STDOUT:   %import_ref: %Int.type = import_ref Main//types, inst+20, loaded [template = constants.%Int]
+// CHECK:STDOUT:   %import_ref: %Int.type = import_ref Main//types, inst+22, loaded [template = constants.%Int]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     import Core//prelude
 // CHECK:STDOUT:     import Core//prelude/operators

+ 4 - 4
toolchain/check/testdata/builtins/int/make_type_unsigned.carbon

@@ -145,7 +145,7 @@ var m: UInt(1000000000);
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
-// CHECK:STDOUT:   %import_ref.1: %UInt.type = import_ref Main//types, inst+20, loaded [template = constants.%UInt]
+// CHECK:STDOUT:   %import_ref.1: %UInt.type = import_ref Main//types, inst+22, loaded [template = constants.%UInt]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.2
 // CHECK:STDOUT:     import Core//prelude
@@ -289,7 +289,7 @@ var m: UInt(1000000000);
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
-// CHECK:STDOUT:   %import_ref: %UInt.type = import_ref Main//types, inst+20, loaded [template = constants.%UInt]
+// CHECK:STDOUT:   %import_ref: %UInt.type = import_ref Main//types, inst+22, loaded [template = constants.%UInt]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     import Core//prelude
 // CHECK:STDOUT:     import Core//prelude/operators
@@ -337,7 +337,7 @@ var m: UInt(1000000000);
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
-// CHECK:STDOUT:   %import_ref.1: %UInt.type = import_ref Main//types, inst+20, loaded [template = constants.%UInt]
+// CHECK:STDOUT:   %import_ref.1: %UInt.type = import_ref Main//types, inst+22, loaded [template = constants.%UInt]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.2
 // CHECK:STDOUT:     import Core//prelude
@@ -408,7 +408,7 @@ var m: UInt(1000000000);
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
-// CHECK:STDOUT:   %import_ref: %UInt.type = import_ref Main//types, inst+20, loaded [template = constants.%UInt]
+// CHECK:STDOUT:   %import_ref: %UInt.type = import_ref Main//types, inst+22, loaded [template = constants.%UInt]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     import Core//prelude
 // CHECK:STDOUT:     import Core//prelude/operators

+ 1 - 1
toolchain/check/testdata/builtins/print.carbon

@@ -47,7 +47,7 @@ fn Main() {
 // CHECK:STDOUT:     import Core//prelude/types/bool
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
-// CHECK:STDOUT:   %import_ref.2: %Print.type.2 = import_ref Core//prelude, inst+49, loaded [template = constants.%Print.2]
+// CHECK:STDOUT:   %import_ref.2: %Print.type.2 = import_ref Core//prelude, inst+51, loaded [template = constants.%Print.2]
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {

+ 2 - 2
toolchain/check/testdata/class/extend_adapt.carbon

@@ -54,7 +54,7 @@ fn F(a: SomeClassAdapter) {
   // CHECK:STDERR: fail_todo_method_access.carbon:[[@LINE+7]]:3: note: type `SomeClassAdapter` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote]
   // CHECK:STDERR:   a.F();
   // CHECK:STDERR:   ^
-  // CHECK:STDERR: fail_todo_method_access.carbon:[[@LINE-14]]:8: note: initializing `self` parameter of method declared here [InCallToFunctionSelf]
+  // CHECK:STDERR: fail_todo_method_access.carbon:[[@LINE-14]]:8: note: initializing function parameter [InCallToFunctionParam]
   // CHECK:STDERR:   fn F[self: Self]();
   // CHECK:STDERR:        ^~~~~~~~~~
   // CHECK:STDERR:
@@ -357,7 +357,7 @@ class StructAdapter {
 // CHECK:STDOUT:   %.loc23_3.1: %.8 = specific_constant imports.%import_ref.3, @ImplicitAs(constants.%SomeClass) [template = constants.%.9]
 // CHECK:STDOUT:   %Convert.ref: %.8 = name_ref Convert, %.loc23_3.1 [template = constants.%.9]
 // CHECK:STDOUT:   %.loc23_3.2: %SomeClass = converted %a.ref, <error> [template = <error>]
-// CHECK:STDOUT:   %F.call: init %.1 = call %.loc23_4(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %F.call: init %.1 = call %.loc23_4(<error>)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 1 - 1
toolchain/check/testdata/class/fail_abstract.carbon

@@ -472,7 +472,7 @@ fn CallReturnAbstract() {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   %Param.ref: %Param.type = name_ref Param, file.%Param.decl [template = constants.%Param]
 // CHECK:STDOUT:   %p.ref: %Abstract = name_ref p, %p
-// CHECK:STDOUT:   %Param.call: init %.3 = call %Param.ref(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %Param.call: init %.3 = call %Param.ref(<error>)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 2 - 2
toolchain/check/testdata/class/fail_addr_self.carbon

@@ -21,7 +21,7 @@ fn F(c: Class, p: Class*) {
   // CHECK:STDERR: fail_addr_self.carbon:[[@LINE+6]]:3: error: `addr self` method cannot be invoked on a value [AddrSelfIsNonRef]
   // CHECK:STDERR:   c.F();
   // CHECK:STDERR:   ^
-  // CHECK:STDERR: fail_addr_self.carbon:[[@LINE-12]]:8: note: initializing `addr self` parameter of method declared here [InCallToFunctionSelf]
+  // CHECK:STDERR: fail_addr_self.carbon:[[@LINE-12]]:8: note: initializing function parameter [InCallToFunctionParam]
   // CHECK:STDERR:   fn F[addr self: Class*]();
   // CHECK:STDERR:        ^~~~~~~~~~~~~~~~~
   c.F();
@@ -125,7 +125,7 @@ fn F(c: Class, p: Class*) {
 // CHECK:STDOUT:   %c.ref.loc27: %Class = name_ref c, %c
 // CHECK:STDOUT:   %F.ref.loc27: %F.type.1 = name_ref F, @Class.%F.decl [template = constants.%F.1]
 // CHECK:STDOUT:   %.loc27: <bound method> = bound_method %c.ref.loc27, %F.ref.loc27
-// CHECK:STDOUT:   %F.call.loc27: init %.2 = call %.loc27(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %F.call.loc27: init %.2 = call %.loc27(<error>)
 // CHECK:STDOUT:   %c.ref.loc29: %Class = name_ref c, %c
 // CHECK:STDOUT:   %G.ref.loc29: %G.type = name_ref G, @Class.%G.decl [template = constants.%G]
 // CHECK:STDOUT:   %.loc29: <bound method> = bound_method %c.ref.loc29, %G.ref.loc29

+ 2 - 2
toolchain/check/testdata/class/fail_incomplete.carbon

@@ -378,10 +378,10 @@ class C {
 // CHECK:STDOUT:   %TakeIncomplete.ref.loc103: %TakeIncomplete.type = name_ref TakeIncomplete, file.%TakeIncomplete.decl [template = constants.%TakeIncomplete]
 // CHECK:STDOUT:   %p.ref: %.4 = name_ref p, %p
 // CHECK:STDOUT:   %.loc103: ref %Class = deref %p.ref
-// CHECK:STDOUT:   %TakeIncomplete.call.loc103: init %.1 = call %TakeIncomplete.ref.loc103(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %TakeIncomplete.call.loc103: init %.1 = call %TakeIncomplete.ref.loc103(<error>)
 // CHECK:STDOUT:   %TakeIncomplete.ref.loc115: %TakeIncomplete.type = name_ref TakeIncomplete, file.%TakeIncomplete.decl [template = constants.%TakeIncomplete]
 // CHECK:STDOUT:   %.loc115: %.3 = struct_literal ()
-// CHECK:STDOUT:   %TakeIncomplete.call.loc115: init %.1 = call %TakeIncomplete.ref.loc115(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %TakeIncomplete.call.loc115: init %.1 = call %TakeIncomplete.ref.loc115(<error>)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 4 - 4
toolchain/check/testdata/class/fail_memaccess_category.carbon

@@ -21,7 +21,7 @@ fn F(s: {.a: A}, b: B) {
   // CHECK:STDERR: fail_memaccess_category.carbon:[[@LINE+7]]:4: error: `addr self` method cannot be invoked on a value [AddrSelfIsNonRef]
   // CHECK:STDERR:   s.a.F();
   // CHECK:STDERR:    ^
-  // CHECK:STDERR: fail_memaccess_category.carbon:[[@LINE-12]]:8: note: initializing `addr self` parameter of method declared here [InCallToFunctionSelf]
+  // CHECK:STDERR: fail_memaccess_category.carbon:[[@LINE-12]]:8: note: initializing function parameter [InCallToFunctionParam]
   // CHECK:STDERR:   fn F[addr self: A*]();
   // CHECK:STDERR:        ^~~~~~~~~~~~~
   // CHECK:STDERR:
@@ -32,7 +32,7 @@ fn F(s: {.a: A}, b: B) {
   // CHECK:STDERR: fail_memaccess_category.carbon:[[@LINE+6]]:4: error: `addr self` method cannot be invoked on a value [AddrSelfIsNonRef]
   // CHECK:STDERR:   b.a.F();
   // CHECK:STDERR:    ^
-  // CHECK:STDERR: fail_memaccess_category.carbon:[[@LINE-23]]:8: note: initializing `addr self` parameter of method declared here [InCallToFunctionSelf]
+  // CHECK:STDERR: fail_memaccess_category.carbon:[[@LINE-23]]:8: note: initializing function parameter [InCallToFunctionParam]
   // CHECK:STDERR:   fn F[addr self: A*]();
   // CHECK:STDERR:        ^~~~~~~~~~~~~
   b.a.F();
@@ -135,14 +135,14 @@ fn F(s: {.a: A}, b: B) {
 // CHECK:STDOUT:   %.loc28_4: %A = struct_access %s.ref, element0
 // CHECK:STDOUT:   %F.ref.loc28: %F.type.1 = name_ref F, @A.%F.decl [template = constants.%F.1]
 // CHECK:STDOUT:   %.loc28_6: <bound method> = bound_method %.loc28_4, %F.ref.loc28
-// CHECK:STDOUT:   %F.call.loc28: init %.2 = call %.loc28_6(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %F.call.loc28: init %.2 = call %.loc28_6(<error>)
 // CHECK:STDOUT:   %b.ref: %B = name_ref b, %b
 // CHECK:STDOUT:   %a.ref: %.6 = name_ref a, @B.%.loc16 [template = @B.%.loc16]
 // CHECK:STDOUT:   %.loc38_4.1: ref %A = class_element_access %b.ref, element0
 // CHECK:STDOUT:   %.loc38_4.2: %A = bind_value %.loc38_4.1
 // CHECK:STDOUT:   %F.ref.loc38: %F.type.1 = name_ref F, @A.%F.decl [template = constants.%F.1]
 // CHECK:STDOUT:   %.loc38_6: <bound method> = bound_method %.loc38_4.2, %F.ref.loc38
-// CHECK:STDOUT:   %F.call.loc38: init %.2 = call %.loc38_6(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %F.call.loc38: init %.2 = call %.loc38_6(<error>)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 2 - 2
toolchain/check/testdata/class/fail_method.carbon

@@ -134,12 +134,12 @@ fn F(c: Class) {
 // CHECK:STDOUT:   %NoSelf.call.loc22: init %.1 = call %NoSelf.ref.loc22()
 // CHECK:STDOUT:   %Class.ref.loc30: type = name_ref Class, file.%Class.decl [template = constants.%Class]
 // CHECK:STDOUT:   %WithSelf.ref.loc30: %WithSelf.type = name_ref WithSelf, @Class.%WithSelf.decl [template = constants.%WithSelf]
-// CHECK:STDOUT:   %WithSelf.call.loc30: init %.1 = call %WithSelf.ref.loc30(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %WithSelf.call.loc30: init %.1 = call %WithSelf.ref.loc30(<error>)
 // CHECK:STDOUT:   %Class.ref.loc38: type = name_ref Class, file.%Class.decl [template = constants.%Class]
 // CHECK:STDOUT:   %WithSelf.ref.loc38: %WithSelf.type = name_ref WithSelf, @Class.%WithSelf.decl [template = constants.%WithSelf]
 // CHECK:STDOUT:   %c.ref.loc38: %Class = name_ref c, %c
 // CHECK:STDOUT:   %A.ref: %WithSelf.type = name_ref A, file.%A [template = constants.%WithSelf]
-// CHECK:STDOUT:   %WithSelf.call.loc46: init %.1 = call %A.ref(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %WithSelf.call.loc46: init %.1 = call %A.ref(<error>)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 2 - 2
toolchain/check/testdata/class/fail_self.carbon

@@ -49,7 +49,7 @@ fn CallWrongSelf(ws: WrongSelf) {
   // CHECK:STDERR: fail_self.carbon:[[@LINE+6]]:3: note: type `WrongSelf` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote]
   // CHECK:STDERR:   ws.F();
   // CHECK:STDERR:   ^~
-  // CHECK:STDERR: fail_self.carbon:[[@LINE-10]]:8: note: initializing `self` parameter of method declared here [InCallToFunctionSelf]
+  // CHECK:STDERR: fail_self.carbon:[[@LINE-10]]:8: note: initializing function parameter [InCallToFunctionParam]
   // CHECK:STDERR:   fn F[self: Class]();
   // CHECK:STDERR:        ^~~~~~~~~~~
   ws.F();
@@ -235,7 +235,7 @@ fn CallWrongSelf(ws: WrongSelf) {
 // CHECK:STDOUT:   %.loc55_3.1: %.7 = specific_constant imports.%import_ref.3, @ImplicitAs(constants.%Class) [template = constants.%.8]
 // CHECK:STDOUT:   %Convert.ref: %.7 = name_ref Convert, %.loc55_3.1 [template = constants.%.8]
 // CHECK:STDOUT:   %.loc55_3.2: %Class = converted %ws.ref, <error> [template = <error>]
-// CHECK:STDOUT:   %F.call: init %.1 = call %.loc55_5(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %F.call: init %.1 = call %.loc55_5(<error>)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 10 - 10
toolchain/check/testdata/class/generic/import.carbon

@@ -282,7 +282,7 @@ class Class(U:! type) {
 // CHECK:STDOUT: imports {
 // CHECK:STDOUT:   %import_ref.1: %Class.type = import_ref Main//foo, inst+9, loaded [template = constants.%Class.1]
 // CHECK:STDOUT:   %import_ref.2: %CompleteClass.type = import_ref Main//foo, inst+21, loaded [template = constants.%CompleteClass.1]
-// CHECK:STDOUT:   %import_ref.3: %F.type.2 = import_ref Main//foo, inst+69, loaded [template = constants.%F.2]
+// CHECK:STDOUT:   %import_ref.3: %F.type.2 = import_ref Main//foo, inst+71, loaded [template = constants.%F.2]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.7
 // CHECK:STDOUT:     import Core//prelude
@@ -296,8 +296,8 @@ class Class(U:! type) {
 // CHECK:STDOUT:     import Core//prelude/types/bool
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %import_ref.4 = import_ref Main//foo, inst+26, unloaded
-// CHECK:STDOUT:   %import_ref.5 = import_ref Main//foo, inst+36, unloaded
-// CHECK:STDOUT:   %import_ref.6 = import_ref Main//foo, inst+46, unloaded
+// CHECK:STDOUT:   %import_ref.5 = import_ref Main//foo, inst+38, unloaded
+// CHECK:STDOUT:   %import_ref.6 = import_ref Main//foo, inst+48, unloaded
 // CHECK:STDOUT:   %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
@@ -462,7 +462,7 @@ class Class(U:! type) {
 // CHECK:STDOUT: imports {
 // CHECK:STDOUT:   %import_ref.1 = import_ref Main//foo, inst+9, unloaded
 // CHECK:STDOUT:   %import_ref.2: %CompleteClass.type = import_ref Main//foo, inst+21, loaded [template = constants.%CompleteClass.1]
-// CHECK:STDOUT:   %import_ref.3: %F.type.3 = import_ref Main//foo, inst+69, loaded [template = constants.%F.3]
+// CHECK:STDOUT:   %import_ref.3: %F.type.3 = import_ref Main//foo, inst+71, loaded [template = constants.%F.3]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.4
 // CHECK:STDOUT:     import Core//prelude
@@ -477,8 +477,8 @@ class Class(U:! type) {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %import_ref.4: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
 // CHECK:STDOUT:   %import_ref.5 = import_ref Main//foo, inst+26, unloaded
-// CHECK:STDOUT:   %import_ref.6: @CompleteClass.%.1 (%.4) = import_ref Main//foo, inst+36, loaded [template = %.1]
-// CHECK:STDOUT:   %import_ref.7: @CompleteClass.%F.type (%F.type.1) = import_ref Main//foo, inst+46, loaded [symbolic = @CompleteClass.%F (constants.%F.1)]
+// CHECK:STDOUT:   %import_ref.6: @CompleteClass.%.1 (%.4) = import_ref Main//foo, inst+38, loaded [template = %.1]
+// CHECK:STDOUT:   %import_ref.7: @CompleteClass.%F.type (%F.type.1) = import_ref Main//foo, inst+48, loaded [symbolic = @CompleteClass.%F (constants.%F.1)]
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
@@ -670,7 +670,7 @@ class Class(U:! type) {
 // CHECK:STDOUT: imports {
 // CHECK:STDOUT:   %import_ref.1 = import_ref Main//foo, inst+9, unloaded
 // CHECK:STDOUT:   %import_ref.2: %CompleteClass.type = import_ref Main//foo, inst+21, loaded [template = constants.%CompleteClass.1]
-// CHECK:STDOUT:   %import_ref.3: %F.type.3 = import_ref Main//foo, inst+69, loaded [template = constants.%F.3]
+// CHECK:STDOUT:   %import_ref.3: %F.type.3 = import_ref Main//foo, inst+71, loaded [template = constants.%F.3]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.7
 // CHECK:STDOUT:     .ImplicitAs = %import_ref.8
@@ -685,8 +685,8 @@ class Class(U:! type) {
 // CHECK:STDOUT:     import Core//prelude/types/bool
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %import_ref.4 = import_ref Main//foo, inst+26, unloaded
-// CHECK:STDOUT:   %import_ref.5 = import_ref Main//foo, inst+36, unloaded
-// CHECK:STDOUT:   %import_ref.6 = import_ref Main//foo, inst+46, unloaded
+// CHECK:STDOUT:   %import_ref.5 = import_ref Main//foo, inst+38, unloaded
+// CHECK:STDOUT:   %import_ref.6 = import_ref Main//foo, inst+48, unloaded
 // CHECK:STDOUT:   %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
 // CHECK:STDOUT:   %import_ref.8: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+49, loaded [template = constants.%ImplicitAs]
 // CHECK:STDOUT:   %import_ref.9 = import_ref Core//prelude/operators/as, inst+55, unloaded
@@ -880,7 +880,7 @@ class Class(U:! type) {
 // CHECK:STDOUT: imports {
 // CHECK:STDOUT:   %import_ref.1: %Class.type = import_ref Main//foo, inst+9, loaded [template = constants.%Class.1]
 // CHECK:STDOUT:   %import_ref.2 = import_ref Main//foo, inst+21, unloaded
-// CHECK:STDOUT:   %import_ref.3 = import_ref Main//foo, inst+69, unloaded
+// CHECK:STDOUT:   %import_ref.3 = import_ref Main//foo, inst+71, unloaded
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     import Core//prelude
 // CHECK:STDOUT:     import Core//prelude/operators

+ 9 - 9
toolchain/check/testdata/class/import.carbon

@@ -191,8 +191,8 @@ fn Run() {
 // CHECK:STDOUT: imports {
 // CHECK:STDOUT:   %import_ref.1: type = import_ref Main//a, inst+3, loaded [template = constants.%Empty]
 // CHECK:STDOUT:   %import_ref.2: type = import_ref Main//a, inst+8, loaded [template = constants.%Field]
-// CHECK:STDOUT:   %import_ref.3: type = import_ref Main//a, inst+26, loaded [template = constants.%ForwardDeclared.1]
-// CHECK:STDOUT:   %import_ref.4: type = import_ref Main//a, inst+49, loaded [template = constants.%Incomplete]
+// CHECK:STDOUT:   %import_ref.3: type = import_ref Main//a, inst+28, loaded [template = constants.%ForwardDeclared.1]
+// CHECK:STDOUT:   %import_ref.4: type = import_ref Main//a, inst+51, loaded [template = constants.%Incomplete]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     import Core//prelude
 // CHECK:STDOUT:     import Core//prelude/operators
@@ -206,13 +206,13 @@ fn Run() {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %import_ref.5 = import_ref Main//a, inst+4, unloaded
 // CHECK:STDOUT:   %import_ref.6 = import_ref Main//a, inst+9, unloaded
-// CHECK:STDOUT:   %import_ref.7: %.9 = import_ref Main//a, inst+20, loaded [template = %.1]
-// CHECK:STDOUT:   %import_ref.8 = import_ref Main//a, inst+27, unloaded
-// CHECK:STDOUT:   %import_ref.9: %F.type = import_ref Main//a, inst+34, loaded [template = constants.%F]
-// CHECK:STDOUT:   %import_ref.10: %G.type = import_ref Main//a, inst+45, loaded [template = constants.%G]
-// CHECK:STDOUT:   %import_ref.11 = import_ref Main//a, inst+27, unloaded
-// CHECK:STDOUT:   %import_ref.12 = import_ref Main//a, inst+34, unloaded
-// CHECK:STDOUT:   %import_ref.13 = import_ref Main//a, inst+45, unloaded
+// CHECK:STDOUT:   %import_ref.7: %.9 = import_ref Main//a, inst+22, loaded [template = %.1]
+// CHECK:STDOUT:   %import_ref.8 = import_ref Main//a, inst+29, unloaded
+// CHECK:STDOUT:   %import_ref.9: %F.type = import_ref Main//a, inst+36, loaded [template = constants.%F]
+// CHECK:STDOUT:   %import_ref.10: %G.type = import_ref Main//a, inst+47, loaded [template = constants.%G]
+// CHECK:STDOUT:   %import_ref.11 = import_ref Main//a, inst+29, unloaded
+// CHECK:STDOUT:   %import_ref.12 = import_ref Main//a, inst+36, unloaded
+// CHECK:STDOUT:   %import_ref.13 = import_ref Main//a, inst+47, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {

+ 5 - 5
toolchain/check/testdata/class/import_base.carbon

@@ -165,7 +165,7 @@ fn Run() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
 // CHECK:STDOUT:   %import_ref.1 = import_ref Main//a, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.2: type = import_ref Main//a, inst+43, loaded [template = constants.%Child]
+// CHECK:STDOUT:   %import_ref.2: type = import_ref Main//a, inst+45, loaded [template = constants.%Child]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     import Core//prelude
 // CHECK:STDOUT:     import Core//prelude/operators
@@ -180,10 +180,10 @@ fn Run() {
 // CHECK:STDOUT:   %import_ref.3 = import_ref Main//a, inst+4, unloaded
 // CHECK:STDOUT:   %import_ref.4: %F.type = import_ref Main//a, inst+10, loaded [template = constants.%F]
 // CHECK:STDOUT:   %import_ref.5 = import_ref Main//a, inst+19, unloaded
-// CHECK:STDOUT:   %import_ref.6: %.13 = import_ref Main//a, inst+31, loaded [template = %.1]
-// CHECK:STDOUT:   %import_ref.7 = import_ref Main//a, inst+37, unloaded
-// CHECK:STDOUT:   %import_ref.8 = import_ref Main//a, inst+44, unloaded
-// CHECK:STDOUT:   %import_ref.9 = import_ref Main//a, inst+48, unloaded
+// CHECK:STDOUT:   %import_ref.6: %.13 = import_ref Main//a, inst+33, loaded [template = %.1]
+// CHECK:STDOUT:   %import_ref.7 = import_ref Main//a, inst+39, unloaded
+// CHECK:STDOUT:   %import_ref.8 = import_ref Main//a, inst+46, unloaded
+// CHECK:STDOUT:   %import_ref.9 = import_ref Main//a, inst+50, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {

+ 3 - 3
toolchain/check/testdata/const/import.carbon

@@ -114,9 +114,9 @@ var a_ptr: const i32* = a_ptr_ref;
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
-// CHECK:STDOUT:   %import_ref.1 = import_ref Implicit//default, inst+18, unloaded
-// CHECK:STDOUT:   %import_ref.2: ref %.2 = import_ref Implicit//default, inst+26, loaded
-// CHECK:STDOUT:   %import_ref.3: ref %.3 = import_ref Implicit//default, inst+37, loaded
+// CHECK:STDOUT:   %import_ref.1 = import_ref Implicit//default, inst+20, unloaded
+// CHECK:STDOUT:   %import_ref.2: ref %.2 = import_ref Implicit//default, inst+28, loaded
+// CHECK:STDOUT:   %import_ref.3: ref %.3 = import_ref Implicit//default, inst+39, loaded
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.4
 // CHECK:STDOUT:     import Core//prelude

+ 2 - 2
toolchain/check/testdata/deduce/array.carbon

@@ -721,12 +721,12 @@ fn G() -> C {
 // CHECK:STDOUT:   %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
 // CHECK:STDOUT:   %a.ref: ref %.10 = name_ref a, %a
 // CHECK:STDOUT:   %.loc21_10: <specific function> = specific_function %F.ref, @F(constants.%C) [template = constants.%.15]
-// CHECK:STDOUT:   %.loc21_11: ref %C = temporary_storage
+// CHECK:STDOUT:   %.loc8_8.2: ref %C = splice_block %return {}
 // CHECK:STDOUT:   %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(constants.%.14) [template = constants.%ImplicitAs.type.3]
 // CHECK:STDOUT:   %.loc21_12.1: %.19 = specific_constant imports.%import_ref.3, @ImplicitAs(constants.%.14) [template = constants.%.20]
 // CHECK:STDOUT:   %Convert.ref: %.19 = name_ref Convert, %.loc21_12.1 [template = constants.%.20]
 // CHECK:STDOUT:   %.loc21_12.2: %.14 = converted %a.ref, <error> [template = <error>]
-// CHECK:STDOUT:   %F.call: init %C = call %.loc21_10(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %F.call: init %C = call %.loc21_10(<error>) to %.loc8_8.2
 // CHECK:STDOUT:   return %F.call to %return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 1 - 1
toolchain/check/testdata/function/call/fail_param_type.carbon

@@ -131,7 +131,7 @@ fn F() {
 // CHECK:STDOUT:   %.loc23_5.2: %.5 = specific_constant imports.%import_ref.4, @ImplicitAs(i32) [template = constants.%.6]
 // CHECK:STDOUT:   %Convert.ref: %.5 = name_ref Convert, %.loc23_5.2 [template = constants.%.6]
 // CHECK:STDOUT:   %.loc23_5.3: i32 = converted %.loc23_5.1, <error> [template = <error>]
-// CHECK:STDOUT:   %G.call: init %.1 = call %G.ref(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %G.call: init %.1 = call %G.ref(<error>)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 1 - 1
toolchain/check/testdata/function/call/no_prelude/fail_runtime_implicit_param.carbon

@@ -44,7 +44,7 @@ fn Run() {
 // CHECK:STDOUT: fn @Run() {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
-// CHECK:STDOUT:   %F.call: init %.1 = call %F.ref(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %F.call: init %.1 = call %F.ref()
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 43 - 43
toolchain/check/testdata/function/declaration/import.carbon

@@ -487,14 +487,14 @@ import library "extern_api";
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
 // CHECK:STDOUT:   %import_ref.1: %A.type = import_ref Main//api, inst+3, loaded [template = constants.%A]
-// CHECK:STDOUT:   %import_ref.2: %B.type = import_ref Main//api, inst+26, loaded [template = constants.%B]
-// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Main//api, inst+51, loaded [template = constants.%C]
-// CHECK:STDOUT:   %import_ref.4: %D.type = import_ref Main//api, inst+54, loaded [template = constants.%D]
-// CHECK:STDOUT:   %import_ref.5: <namespace> = import_ref Main//api, inst+57, loaded
+// CHECK:STDOUT:   %import_ref.2: %B.type = import_ref Main//api, inst+28, loaded [template = constants.%B]
+// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Main//api, inst+53, loaded [template = constants.%C]
+// CHECK:STDOUT:   %import_ref.4: %D.type = import_ref Main//api, inst+56, loaded [template = constants.%D]
+// CHECK:STDOUT:   %import_ref.5: <namespace> = import_ref Main//api, inst+59, loaded
 // CHECK:STDOUT:   %NS: <namespace> = namespace %import_ref.5, [template] {
 // CHECK:STDOUT:     .E = %import_ref.6
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.6: %E.type = import_ref Main//api, inst+58, loaded [template = constants.%E]
+// CHECK:STDOUT:   %import_ref.6: %E.type = import_ref Main//api, inst+60, loaded [template = constants.%E]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.7
 // CHECK:STDOUT:     import Core//prelude
@@ -614,14 +614,14 @@ import library "extern_api";
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
 // CHECK:STDOUT:   %import_ref.1: %A.type = import_ref Main//api, inst+3, loaded [template = constants.%A]
-// CHECK:STDOUT:   %import_ref.2: %B.type = import_ref Main//api, inst+26, loaded [template = constants.%B]
-// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Main//api, inst+51, loaded [template = constants.%C]
-// CHECK:STDOUT:   %import_ref.4: %D.type = import_ref Main//api, inst+54, loaded [template = constants.%D]
-// CHECK:STDOUT:   %import_ref.5: <namespace> = import_ref Main//api, inst+57, loaded
+// CHECK:STDOUT:   %import_ref.2: %B.type = import_ref Main//api, inst+28, loaded [template = constants.%B]
+// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Main//api, inst+53, loaded [template = constants.%C]
+// CHECK:STDOUT:   %import_ref.4: %D.type = import_ref Main//api, inst+56, loaded [template = constants.%D]
+// CHECK:STDOUT:   %import_ref.5: <namespace> = import_ref Main//api, inst+59, loaded
 // CHECK:STDOUT:   %NS: <namespace> = namespace %import_ref.5, [template] {
 // CHECK:STDOUT:     .E = file.%E.decl
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.6: %E.type = import_ref Main//api, inst+58, loaded [template = constants.%E]
+// CHECK:STDOUT:   %import_ref.6: %E.type = import_ref Main//api, inst+60, loaded [template = constants.%E]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.7
 // CHECK:STDOUT:     import Core//prelude
@@ -771,14 +771,14 @@ import library "extern_api";
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
 // CHECK:STDOUT:   %import_ref.1: %A.type = import_ref Main//extern_api, inst+3, loaded [template = constants.%A]
-// CHECK:STDOUT:   %import_ref.2: %B.type = import_ref Main//extern_api, inst+26, loaded [template = constants.%B]
-// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Main//extern_api, inst+51, loaded [template = constants.%C]
-// CHECK:STDOUT:   %import_ref.4: %D.type = import_ref Main//extern_api, inst+54, loaded [template = constants.%D]
-// CHECK:STDOUT:   %import_ref.5: <namespace> = import_ref Main//extern_api, inst+57, loaded
+// CHECK:STDOUT:   %import_ref.2: %B.type = import_ref Main//extern_api, inst+28, loaded [template = constants.%B]
+// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Main//extern_api, inst+53, loaded [template = constants.%C]
+// CHECK:STDOUT:   %import_ref.4: %D.type = import_ref Main//extern_api, inst+56, loaded [template = constants.%D]
+// CHECK:STDOUT:   %import_ref.5: <namespace> = import_ref Main//extern_api, inst+59, loaded
 // CHECK:STDOUT:   %NS: <namespace> = namespace %import_ref.5, [template] {
 // CHECK:STDOUT:     .E = file.%E.decl
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.6: %E.type = import_ref Main//extern_api, inst+58, loaded [template = constants.%E]
+// CHECK:STDOUT:   %import_ref.6: %E.type = import_ref Main//extern_api, inst+60, loaded [template = constants.%E]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.7
 // CHECK:STDOUT:     import Core//prelude
@@ -927,19 +927,19 @@ import library "extern_api";
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
 // CHECK:STDOUT:   %import_ref.1: %A.type = import_ref Main//api, inst+3, loaded [template = constants.%A]
-// CHECK:STDOUT:   %import_ref.2: %B.type = import_ref Main//api, inst+26, loaded [template = constants.%B]
-// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Main//api, inst+51, loaded [template = constants.%C]
-// CHECK:STDOUT:   %import_ref.4: %D.type = import_ref Main//api, inst+54, loaded [template = constants.%D]
-// CHECK:STDOUT:   %import_ref.5: <namespace> = import_ref Main//api, inst+57, loaded
+// CHECK:STDOUT:   %import_ref.2: %B.type = import_ref Main//api, inst+28, loaded [template = constants.%B]
+// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Main//api, inst+53, loaded [template = constants.%C]
+// CHECK:STDOUT:   %import_ref.4: %D.type = import_ref Main//api, inst+56, loaded [template = constants.%D]
+// CHECK:STDOUT:   %import_ref.5: <namespace> = import_ref Main//api, inst+59, loaded
 // CHECK:STDOUT:   %NS: <namespace> = namespace %import_ref.5, [template] {
 // CHECK:STDOUT:     .E = %import_ref.6
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.6: %E.type = import_ref Main//api, inst+58, loaded [template = constants.%E]
+// CHECK:STDOUT:   %import_ref.6: %E.type = import_ref Main//api, inst+60, loaded [template = constants.%E]
 // CHECK:STDOUT:   %import_ref.7 = import_ref Main//extern_api, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.8 = import_ref Main//extern_api, inst+26, unloaded
-// CHECK:STDOUT:   %import_ref.9 = import_ref Main//extern_api, inst+51, unloaded
-// CHECK:STDOUT:   %import_ref.10 = import_ref Main//extern_api, inst+54, unloaded
-// CHECK:STDOUT:   %import_ref.11 = import_ref Main//extern_api, inst+58, unloaded
+// CHECK:STDOUT:   %import_ref.8 = import_ref Main//extern_api, inst+28, unloaded
+// CHECK:STDOUT:   %import_ref.9 = import_ref Main//extern_api, inst+53, unloaded
+// CHECK:STDOUT:   %import_ref.10 = import_ref Main//extern_api, inst+56, unloaded
+// CHECK:STDOUT:   %import_ref.11 = import_ref Main//extern_api, inst+60, unloaded
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.12
 // CHECK:STDOUT:     import Core//prelude
@@ -1058,19 +1058,19 @@ import library "extern_api";
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
 // CHECK:STDOUT:   %import_ref.1: %A.type = import_ref Main//extern_api, inst+3, loaded [template = constants.%A]
-// CHECK:STDOUT:   %import_ref.2: %B.type = import_ref Main//extern_api, inst+26, loaded [template = constants.%B]
-// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Main//extern_api, inst+51, loaded [template = constants.%C]
-// CHECK:STDOUT:   %import_ref.4: %D.type = import_ref Main//extern_api, inst+54, loaded [template = constants.%D]
-// CHECK:STDOUT:   %import_ref.5: <namespace> = import_ref Main//extern_api, inst+57, loaded
+// CHECK:STDOUT:   %import_ref.2: %B.type = import_ref Main//extern_api, inst+28, loaded [template = constants.%B]
+// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Main//extern_api, inst+53, loaded [template = constants.%C]
+// CHECK:STDOUT:   %import_ref.4: %D.type = import_ref Main//extern_api, inst+56, loaded [template = constants.%D]
+// CHECK:STDOUT:   %import_ref.5: <namespace> = import_ref Main//extern_api, inst+59, loaded
 // CHECK:STDOUT:   %NS: <namespace> = namespace %import_ref.5, [template] {
 // CHECK:STDOUT:     .E = %import_ref.6
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.6: %E.type = import_ref Main//extern_api, inst+58, loaded [template = constants.%E]
+// CHECK:STDOUT:   %import_ref.6: %E.type = import_ref Main//extern_api, inst+60, loaded [template = constants.%E]
 // CHECK:STDOUT:   %import_ref.7 = import_ref Main//api, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.8 = import_ref Main//api, inst+26, unloaded
-// CHECK:STDOUT:   %import_ref.9 = import_ref Main//api, inst+51, unloaded
-// CHECK:STDOUT:   %import_ref.10 = import_ref Main//api, inst+54, unloaded
-// CHECK:STDOUT:   %import_ref.11 = import_ref Main//api, inst+58, unloaded
+// CHECK:STDOUT:   %import_ref.8 = import_ref Main//api, inst+28, unloaded
+// CHECK:STDOUT:   %import_ref.9 = import_ref Main//api, inst+53, unloaded
+// CHECK:STDOUT:   %import_ref.10 = import_ref Main//api, inst+56, unloaded
+// CHECK:STDOUT:   %import_ref.11 = import_ref Main//api, inst+60, unloaded
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.12
 // CHECK:STDOUT:     import Core//prelude
@@ -1169,14 +1169,14 @@ import library "extern_api";
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
 // CHECK:STDOUT:   %import_ref.1 = import_ref Main//api, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.2 = import_ref Main//api, inst+26, unloaded
-// CHECK:STDOUT:   %import_ref.3 = import_ref Main//api, inst+51, unloaded
-// CHECK:STDOUT:   %import_ref.4 = import_ref Main//api, inst+54, unloaded
-// CHECK:STDOUT:   %import_ref.5: <namespace> = import_ref Main//api, inst+57, loaded
+// CHECK:STDOUT:   %import_ref.2 = import_ref Main//api, inst+28, unloaded
+// CHECK:STDOUT:   %import_ref.3 = import_ref Main//api, inst+53, unloaded
+// CHECK:STDOUT:   %import_ref.4 = import_ref Main//api, inst+56, unloaded
+// CHECK:STDOUT:   %import_ref.5: <namespace> = import_ref Main//api, inst+59, loaded
 // CHECK:STDOUT:   %NS: <namespace> = namespace %import_ref.5, [template] {
 // CHECK:STDOUT:     .E = %import_ref.6
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.6 = import_ref Main//api, inst+58, unloaded
+// CHECK:STDOUT:   %import_ref.6 = import_ref Main//api, inst+60, unloaded
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     import Core//prelude
 // CHECK:STDOUT:     import Core//prelude/operators
@@ -1207,14 +1207,14 @@ import library "extern_api";
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
 // CHECK:STDOUT:   %import_ref.1 = import_ref Main//extern_api, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.2 = import_ref Main//extern_api, inst+26, unloaded
-// CHECK:STDOUT:   %import_ref.3 = import_ref Main//extern_api, inst+51, unloaded
-// CHECK:STDOUT:   %import_ref.4 = import_ref Main//extern_api, inst+54, unloaded
-// CHECK:STDOUT:   %import_ref.5: <namespace> = import_ref Main//extern_api, inst+57, loaded
+// CHECK:STDOUT:   %import_ref.2 = import_ref Main//extern_api, inst+28, unloaded
+// CHECK:STDOUT:   %import_ref.3 = import_ref Main//extern_api, inst+53, unloaded
+// CHECK:STDOUT:   %import_ref.4 = import_ref Main//extern_api, inst+56, unloaded
+// CHECK:STDOUT:   %import_ref.5: <namespace> = import_ref Main//extern_api, inst+59, loaded
 // CHECK:STDOUT:   %NS: <namespace> = namespace %import_ref.5, [template] {
 // CHECK:STDOUT:     .E = %import_ref.6
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.6 = import_ref Main//extern_api, inst+58, unloaded
+// CHECK:STDOUT:   %import_ref.6 = import_ref Main//extern_api, inst+60, unloaded
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     import Core//prelude
 // CHECK:STDOUT:     import Core//prelude/operators

+ 9 - 9
toolchain/check/testdata/function/definition/import.carbon

@@ -274,9 +274,9 @@ fn D() {}
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
 // CHECK:STDOUT:   %import_ref.1: %A.type = import_ref Main//fns, inst+3, loaded [template = constants.%A]
-// CHECK:STDOUT:   %import_ref.2: %B.type = import_ref Main//fns, inst+27, loaded [template = constants.%B]
-// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Main//fns, inst+54, loaded [template = constants.%C]
-// CHECK:STDOUT:   %import_ref.4 = import_ref Main//fns, inst+66, unloaded
+// CHECK:STDOUT:   %import_ref.2: %B.type = import_ref Main//fns, inst+29, loaded [template = constants.%B]
+// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Main//fns, inst+56, loaded [template = constants.%C]
+// CHECK:STDOUT:   %import_ref.4 = import_ref Main//fns, inst+68, unloaded
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.5
 // CHECK:STDOUT:     import Core//prelude
@@ -363,9 +363,9 @@ fn D() {}
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
 // CHECK:STDOUT:   %import_ref.1: %A.type = import_ref Main//fns, inst+3, loaded [template = constants.%A]
-// CHECK:STDOUT:   %import_ref.2: %B.type = import_ref Main//fns, inst+27, loaded [template = constants.%B]
-// CHECK:STDOUT:   %import_ref.3 = import_ref Main//fns, inst+54, unloaded
-// CHECK:STDOUT:   %import_ref.4 = import_ref Main//fns, inst+66, unloaded
+// CHECK:STDOUT:   %import_ref.2: %B.type = import_ref Main//fns, inst+29, loaded [template = constants.%B]
+// CHECK:STDOUT:   %import_ref.3 = import_ref Main//fns, inst+56, unloaded
+// CHECK:STDOUT:   %import_ref.4 = import_ref Main//fns, inst+68, unloaded
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.5
 // CHECK:STDOUT:     import Core//prelude
@@ -464,9 +464,9 @@ fn D() {}
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
 // CHECK:STDOUT:   %import_ref.1 = import_ref Main//fns, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.2 = import_ref Main//fns, inst+27, unloaded
-// CHECK:STDOUT:   %import_ref.3 = import_ref Main//fns, inst+54, unloaded
-// CHECK:STDOUT:   %import_ref.4: %D.type = import_ref Main//fns, inst+66, loaded [template = constants.%D]
+// CHECK:STDOUT:   %import_ref.2 = import_ref Main//fns, inst+29, unloaded
+// CHECK:STDOUT:   %import_ref.3 = import_ref Main//fns, inst+56, unloaded
+// CHECK:STDOUT:   %import_ref.4: %D.type = import_ref Main//fns, inst+68, loaded [template = constants.%D]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     import Core//prelude
 // CHECK:STDOUT:     import Core//prelude/operators

+ 2 - 2
toolchain/check/testdata/if_expr/fail_not_in_function.carbon

@@ -76,7 +76,7 @@ class C {
 // CHECK:STDOUT: file {
 // CHECK:STDOUT:   package: <namespace> = namespace [template] {
 // CHECK:STDOUT:     .Core = imports.%Core
-// CHECK:STDOUT:     .x = <unexpected>.inst+12.loc23_5
+// CHECK:STDOUT:     .x = <unexpected>.inst+14.loc23_5
 // CHECK:STDOUT:     .C = %C.decl
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core.import = import Core
@@ -92,7 +92,7 @@ class C {
 // CHECK:STDOUT:
 // CHECK:STDOUT: !members:
 // CHECK:STDOUT:   .Self = constants.%C
-// CHECK:STDOUT:   .n = <unexpected>.inst+50.loc37_8
+// CHECK:STDOUT:   .n = <unexpected>.inst+54.loc37_8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";

+ 1 - 1
toolchain/check/testdata/impl/fail_redefinition.carbon

@@ -78,7 +78,7 @@ impl i32 as I {}
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl: %.loc13_6.2 as %I.ref.loc13 {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   witness = <unexpected>.inst+18.loc13_15
+// CHECK:STDOUT:   witness = <unexpected>.inst+20.loc13_15
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";

+ 3 - 3
toolchain/check/testdata/operators/builtin/fail_and_or_not_in_function.carbon

@@ -79,8 +79,8 @@ var or_: F(true or true);
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   %.loc42_17: bool = block_arg <unexpected instblockref block23> [template = constants.%.3]
-// CHECK:STDOUT:   %F.call: init type = call <unexpected>.inst+67.loc42_10(%.loc42_17)
+// CHECK:STDOUT:   %.loc42_17: bool = block_arg <unexpected instblockref block21> [template = constants.%.3]
+// CHECK:STDOUT:   %F.call: init type = call <unexpected>.inst+73.loc42_10(%.loc42_17)
 // CHECK:STDOUT:   %.loc42_24.1: type = value_of_initializer %F.call
 // CHECK:STDOUT:   %.loc42_24.2: type = converted %F.call, %.loc42_24.1
 // CHECK:STDOUT:   %or_.var: ref <error> = var or_
@@ -91,7 +91,7 @@ var or_: F(true or true);
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @F(%b.param_patt: bool) -> type {
 // CHECK:STDOUT: !entry:
-// CHECK:STDOUT:   %b.ref: bool = name_ref b, <unexpected>.inst+12.loc12_6
+// CHECK:STDOUT:   %b.ref: bool = name_ref b, <unexpected>.inst+14.loc12_6
 // CHECK:STDOUT:   if %b.ref br !if.expr.then else br !if.expr.else
 // CHECK:STDOUT:
 // CHECK:STDOUT: !if.expr.then:

+ 1 - 1
toolchain/check/testdata/operators/overloaded/add.carbon

@@ -238,7 +238,7 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   %Self: %AddAssign.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.2)]
 // CHECK:STDOUT:   %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.7)]
 // CHECK:STDOUT:
-// CHECK:STDOUT:   fn[addr <unexpected>.inst+93: @Op.4.%.2 (%.7)](%other.param_patt: @Op.4.%Self (%Self.2));
+// CHECK:STDOUT:   fn[addr <unexpected>.inst+95: @Op.4.%.2 (%.7)](%other.param_patt: @Op.4.%Self (%Self.2));
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestOp(%a.param_patt: %C, %b.param_patt: %C) -> %return: %C {

+ 1 - 1
toolchain/check/testdata/operators/overloaded/bit_and.carbon

@@ -238,7 +238,7 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   %Self: %BitAndAssign.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.2)]
 // CHECK:STDOUT:   %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.7)]
 // CHECK:STDOUT:
-// CHECK:STDOUT:   fn[addr <unexpected>.inst+93: @Op.4.%.2 (%.7)](%other.param_patt: @Op.4.%Self (%Self.2));
+// CHECK:STDOUT:   fn[addr <unexpected>.inst+95: @Op.4.%.2 (%.7)](%other.param_patt: @Op.4.%Self (%Self.2));
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestOp(%a.param_patt: %C, %b.param_patt: %C) -> %return: %C {

+ 1 - 1
toolchain/check/testdata/operators/overloaded/bit_or.carbon

@@ -238,7 +238,7 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   %Self: %BitOrAssign.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.2)]
 // CHECK:STDOUT:   %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.7)]
 // CHECK:STDOUT:
-// CHECK:STDOUT:   fn[addr <unexpected>.inst+93: @Op.4.%.2 (%.7)](%other.param_patt: @Op.4.%Self (%Self.2));
+// CHECK:STDOUT:   fn[addr <unexpected>.inst+95: @Op.4.%.2 (%.7)](%other.param_patt: @Op.4.%Self (%Self.2));
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestOp(%a.param_patt: %C, %b.param_patt: %C) -> %return: %C {

+ 1 - 1
toolchain/check/testdata/operators/overloaded/bit_xor.carbon

@@ -238,7 +238,7 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   %Self: %BitXorAssign.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.2)]
 // CHECK:STDOUT:   %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.7)]
 // CHECK:STDOUT:
-// CHECK:STDOUT:   fn[addr <unexpected>.inst+93: @Op.4.%.2 (%.7)](%other.param_patt: @Op.4.%Self (%Self.2));
+// CHECK:STDOUT:   fn[addr <unexpected>.inst+95: @Op.4.%.2 (%.7)](%other.param_patt: @Op.4.%Self (%Self.2));
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestOp(%a.param_patt: %C, %b.param_patt: %C) -> %return: %C {

+ 1 - 1
toolchain/check/testdata/operators/overloaded/div.carbon

@@ -238,7 +238,7 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   %Self: %DivAssign.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.2)]
 // CHECK:STDOUT:   %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.7)]
 // CHECK:STDOUT:
-// CHECK:STDOUT:   fn[addr <unexpected>.inst+93: @Op.4.%.2 (%.7)](%other.param_patt: @Op.4.%Self (%Self.2));
+// CHECK:STDOUT:   fn[addr <unexpected>.inst+95: @Op.4.%.2 (%.7)](%other.param_patt: @Op.4.%Self (%Self.2));
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestOp(%a.param_patt: %C, %b.param_patt: %C) -> %return: %C {

+ 21 - 21
toolchain/check/testdata/operators/overloaded/eq.carbon

@@ -129,13 +129,13 @@ fn TestLhsBad(a: D, b: C) -> bool {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %import_ref.1: type = import_ref Core//prelude/operators/comparison, inst+3, loaded [template = constants.%Eq.type]
 // CHECK:STDOUT:   %import_ref.2 = import_ref Core//prelude/operators/comparison, inst+5, unloaded
-// CHECK:STDOUT:   %import_ref.3: %.6 = import_ref Core//prelude/operators/comparison, inst+38, loaded [template = constants.%.7]
-// CHECK:STDOUT:   %import_ref.4: %.8 = import_ref Core//prelude/operators/comparison, inst+66, loaded [template = constants.%.9]
-// CHECK:STDOUT:   %import_ref.5: %Equal.type.2 = import_ref Core//prelude/operators/comparison, inst+33, loaded [template = constants.%Equal.2]
-// CHECK:STDOUT:   %import_ref.6: %NotEqual.type.2 = import_ref Core//prelude/operators/comparison, inst+61, loaded [template = constants.%NotEqual.2]
+// CHECK:STDOUT:   %import_ref.3: %.6 = import_ref Core//prelude/operators/comparison, inst+40, loaded [template = constants.%.7]
+// CHECK:STDOUT:   %import_ref.4: %.8 = import_ref Core//prelude/operators/comparison, inst+68, loaded [template = constants.%.9]
+// CHECK:STDOUT:   %import_ref.5: %Equal.type.2 = import_ref Core//prelude/operators/comparison, inst+35, loaded [template = constants.%Equal.2]
+// CHECK:STDOUT:   %import_ref.6: %NotEqual.type.2 = import_ref Core//prelude/operators/comparison, inst+63, loaded [template = constants.%NotEqual.2]
 // CHECK:STDOUT:   %import_ref.7: %Bool.type = import_ref Core//prelude/types/bool, inst+5, loaded [template = constants.%Bool]
-// CHECK:STDOUT:   %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+33, unloaded
-// CHECK:STDOUT:   %import_ref.9 = import_ref Core//prelude/operators/comparison, inst+61, unloaded
+// CHECK:STDOUT:   %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+35, unloaded
+// CHECK:STDOUT:   %import_ref.9 = import_ref Core//prelude/operators/comparison, inst+63, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
@@ -361,12 +361,12 @@ fn TestLhsBad(a: D, b: C) -> bool {
 // CHECK:STDOUT:   %import_ref.1: %Bool.type = import_ref Core//prelude/types/bool, inst+5, loaded [template = constants.%Bool]
 // CHECK:STDOUT:   %import_ref.2: type = import_ref Core//prelude/operators/comparison, inst+3, loaded [template = constants.%Eq.type]
 // CHECK:STDOUT:   %import_ref.3 = import_ref Core//prelude/operators/comparison, inst+5, unloaded
-// CHECK:STDOUT:   %import_ref.4: %.5 = import_ref Core//prelude/operators/comparison, inst+38, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.5: %.7 = import_ref Core//prelude/operators/comparison, inst+66, loaded [template = constants.%.8]
-// CHECK:STDOUT:   %import_ref.6 = import_ref Core//prelude/operators/comparison, inst+33, unloaded
-// CHECK:STDOUT:   %import_ref.7 = import_ref Core//prelude/operators/comparison, inst+61, unloaded
-// CHECK:STDOUT:   %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+33, unloaded
-// CHECK:STDOUT:   %import_ref.9 = import_ref Core//prelude/operators/comparison, inst+61, unloaded
+// CHECK:STDOUT:   %import_ref.4: %.5 = import_ref Core//prelude/operators/comparison, inst+40, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.5: %.7 = import_ref Core//prelude/operators/comparison, inst+68, loaded [template = constants.%.8]
+// CHECK:STDOUT:   %import_ref.6 = import_ref Core//prelude/operators/comparison, inst+35, unloaded
+// CHECK:STDOUT:   %import_ref.7 = import_ref Core//prelude/operators/comparison, inst+63, unloaded
+// CHECK:STDOUT:   %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+35, unloaded
+// CHECK:STDOUT:   %import_ref.9 = import_ref Core//prelude/operators/comparison, inst+63, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
@@ -539,19 +539,19 @@ fn TestLhsBad(a: D, b: C) -> bool {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %import_ref.1: type = import_ref Core//prelude/operators/comparison, inst+3, loaded [template = constants.%Eq.type]
 // CHECK:STDOUT:   %import_ref.2 = import_ref Core//prelude/operators/comparison, inst+5, unloaded
-// CHECK:STDOUT:   %import_ref.3: %.6 = import_ref Core//prelude/operators/comparison, inst+38, loaded [template = constants.%.7]
-// CHECK:STDOUT:   %import_ref.4: %.13 = import_ref Core//prelude/operators/comparison, inst+66, loaded [template = constants.%.14]
-// CHECK:STDOUT:   %import_ref.5: %Equal.type.2 = import_ref Core//prelude/operators/comparison, inst+33, loaded [template = constants.%Equal.2]
-// CHECK:STDOUT:   %import_ref.6: %NotEqual.type.2 = import_ref Core//prelude/operators/comparison, inst+61, loaded [template = constants.%NotEqual.2]
+// CHECK:STDOUT:   %import_ref.3: %.6 = import_ref Core//prelude/operators/comparison, inst+40, loaded [template = constants.%.7]
+// CHECK:STDOUT:   %import_ref.4: %.13 = import_ref Core//prelude/operators/comparison, inst+68, loaded [template = constants.%.14]
+// CHECK:STDOUT:   %import_ref.5: %Equal.type.2 = import_ref Core//prelude/operators/comparison, inst+35, loaded [template = constants.%Equal.2]
+// CHECK:STDOUT:   %import_ref.6: %NotEqual.type.2 = import_ref Core//prelude/operators/comparison, inst+63, loaded [template = constants.%NotEqual.2]
 // CHECK:STDOUT:   %import_ref.7: %Bool.type = import_ref Core//prelude/types/bool, inst+5, loaded [template = constants.%Bool]
-// CHECK:STDOUT:   %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+33, unloaded
+// CHECK:STDOUT:   %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+35, unloaded
 // CHECK:STDOUT:   %import_ref.9: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+49, loaded [template = constants.%ImplicitAs]
 // CHECK:STDOUT:   %import_ref.10 = import_ref Core//prelude/operators/as, inst+55, unloaded
 // CHECK:STDOUT:   %import_ref.11: @ImplicitAs.%.1 (%.8) = import_ref Core//prelude/operators/as, inst+77, loaded [symbolic = @ImplicitAs.%.2 (constants.%.12)]
 // CHECK:STDOUT:   %import_ref.12 = import_ref Core//prelude/operators/as, inst+70, unloaded
 // CHECK:STDOUT:   %import_ref.13 = import_ref Core//prelude/operators/as, inst+70, unloaded
 // CHECK:STDOUT:   %import_ref.14 = import_ref Core//prelude/operators/as, inst+70, unloaded
-// CHECK:STDOUT:   %import_ref.15 = import_ref Core//prelude/operators/comparison, inst+61, unloaded
+// CHECK:STDOUT:   %import_ref.15 = import_ref Core//prelude/operators/comparison, inst+63, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
@@ -732,9 +732,9 @@ fn TestLhsBad(a: D, b: C) -> bool {
 // CHECK:STDOUT:   %.loc23_15.1: %.10 = specific_constant imports.%import_ref.11, @ImplicitAs(constants.%C) [template = constants.%.11]
 // CHECK:STDOUT:   %Convert.ref: %.10 = name_ref Convert, %.loc23_15.1 [template = constants.%.11]
 // CHECK:STDOUT:   %.loc23_15.2: %C = converted %b.ref, <error> [template = <error>]
-// CHECK:STDOUT:   %Equal.call: init bool = call %.loc23_12.2(<invalid>) [template = <error>]
-// CHECK:STDOUT:   %.loc23_16.1: bool = value_of_initializer %Equal.call [template = <error>]
-// CHECK:STDOUT:   %.loc23_16.2: bool = converted %Equal.call, %.loc23_16.1 [template = <error>]
+// CHECK:STDOUT:   %Equal.call: init bool = call %.loc23_12.2(%a.ref, <error>)
+// CHECK:STDOUT:   %.loc23_16.1: bool = value_of_initializer %Equal.call
+// CHECK:STDOUT:   %.loc23_16.2: bool = converted %Equal.call, %.loc23_16.1
 // CHECK:STDOUT:   return %.loc23_16.2
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 4 - 4
toolchain/check/testdata/operators/overloaded/fail_assign_non_ref.carbon

@@ -23,7 +23,7 @@ fn TestIncNonRef(a: C) {
   // CHECK:STDERR: fail_assign_non_ref.carbon:[[@LINE+7]]:5: error: `addr self` method cannot be invoked on a value [AddrSelfIsNonRef]
   // CHECK:STDERR:   ++a;
   // CHECK:STDERR:     ^
-  // CHECK:STDERR: fail_assign_non_ref.carbon:[[@LINE-10]]:9: note: initializing `addr self` parameter of method declared here [InCallToFunctionSelf]
+  // CHECK:STDERR: fail_assign_non_ref.carbon:[[@LINE-10]]:9: note: initializing function parameter [InCallToFunctionParam]
   // CHECK:STDERR:   fn Op[addr self: C*]();
   // CHECK:STDERR:         ^~~~~~~~~~~~~
   // CHECK:STDERR:
@@ -34,7 +34,7 @@ fn TestAddAssignNonRef(a: C, b: C) {
   // CHECK:STDERR: fail_assign_non_ref.carbon:[[@LINE+6]]:3: error: `addr self` method cannot be invoked on a value [AddrSelfIsNonRef]
   // CHECK:STDERR:   a += b;
   // CHECK:STDERR:   ^
-  // CHECK:STDERR: fail_assign_non_ref.carbon:[[@LINE-18]]:9: note: initializing `addr self` parameter of method declared here [InCallToFunctionSelf]
+  // CHECK:STDERR: fail_assign_non_ref.carbon:[[@LINE-18]]:9: note: initializing function parameter [InCallToFunctionParam]
   // CHECK:STDERR:   fn Op[addr self: C*](other: C);
   // CHECK:STDERR:         ^~~~~~~~~~~~~
   a += b;
@@ -229,7 +229,7 @@ fn TestAddAssignNonRef(a: C, b: C) {
 // CHECK:STDOUT:   %Op.ref: %.10 = name_ref Op, imports.%import_ref.3 [template = constants.%.11]
 // CHECK:STDOUT:   %.loc30_3.1: %Op.type.2 = interface_witness_access constants.%.6, element0 [template = constants.%Op.1]
 // CHECK:STDOUT:   %.loc30_3.2: <bound method> = bound_method %a.ref, %.loc30_3.1
-// CHECK:STDOUT:   %Op.call: init %.4 = call %.loc30_3.2(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %Op.call: init %.4 = call %.loc30_3.2(<error>)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
@@ -240,7 +240,7 @@ fn TestAddAssignNonRef(a: C, b: C) {
 // CHECK:STDOUT:   %Op.ref: %.12 = name_ref Op, imports.%import_ref.7 [template = constants.%.13]
 // CHECK:STDOUT:   %.loc40_5.1: %Op.type.4 = interface_witness_access constants.%.8, element0 [template = constants.%Op.3]
 // CHECK:STDOUT:   %.loc40_5.2: <bound method> = bound_method %a.ref, %.loc40_5.1
-// CHECK:STDOUT:   %Op.call: init %.4 = call %.loc40_5.2(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %Op.call: init %.4 = call %.loc40_5.2(<error>, %b.ref)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 2 - 2
toolchain/check/testdata/operators/overloaded/fail_no_impl.carbon

@@ -256,14 +256,14 @@ fn TestRef(b: C) {
 // CHECK:STDOUT:   %Self: %AddAssign.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.3)]
 // CHECK:STDOUT:   %.2: type = ptr_type @Op.3.%Self (%Self.3) [symbolic = %.2 (constants.%.9)]
 // CHECK:STDOUT:
-// CHECK:STDOUT:   fn[addr <unexpected>.inst+122: @Op.3.%.2 (%.9)](%other.param_patt: @Op.3.%Self (%Self.3));
+// CHECK:STDOUT:   fn[addr <unexpected>.inst+126: @Op.3.%.2 (%.9)](%other.param_patt: @Op.3.%Self (%Self.3));
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: generic fn @Op.4(constants.%Self.4: %Inc.type) {
 // CHECK:STDOUT:   %Self: %Inc.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.4)]
 // CHECK:STDOUT:   %.2: type = ptr_type @Op.4.%Self (%Self.4) [symbolic = %.2 (constants.%.12)]
 // CHECK:STDOUT:
-// CHECK:STDOUT:   fn[addr <unexpected>.inst+149: @Op.4.%.2 (%.12)]();
+// CHECK:STDOUT:   fn[addr <unexpected>.inst+153: @Op.4.%.2 (%.12)]();
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: specific @Op.1(constants.%Self.1) {

+ 4 - 4
toolchain/check/testdata/operators/overloaded/fail_no_impl_for_arg.carbon

@@ -294,7 +294,7 @@ fn TestAssign(b: D) {
 // CHECK:STDOUT:   %Self: %AddAssign.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.2)]
 // CHECK:STDOUT:   %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.6)]
 // CHECK:STDOUT:
-// CHECK:STDOUT:   fn[addr <unexpected>.inst+90: @Op.4.%.2 (%.6)](%other.param_patt: @Op.4.%Self (%Self.2));
+// CHECK:STDOUT:   fn[addr <unexpected>.inst+92: @Op.4.%.2 (%.6)](%other.param_patt: @Op.4.%Self (%Self.2));
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Test(%a.param_patt: %C, %b.param_patt: %D) -> %return: %C {
@@ -304,12 +304,12 @@ fn TestAssign(b: D) {
 // CHECK:STDOUT:   %Op.ref: %.9 = name_ref Op, imports.%import_ref.3 [template = constants.%.10]
 // CHECK:STDOUT:   %.loc34_12.1: %Op.type.2 = interface_witness_access constants.%.4, element0 [template = constants.%Op.1]
 // CHECK:STDOUT:   %.loc34_12.2: <bound method> = bound_method %a.ref, %.loc34_12.1
-// CHECK:STDOUT:   %.loc34_12.3: ref %C = temporary_storage
+// CHECK:STDOUT:   %.loc23_21.2: ref %C = splice_block %return {}
 // CHECK:STDOUT:   %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(constants.%C) [template = constants.%ImplicitAs.type.3]
 // CHECK:STDOUT:   %.loc34_14.1: %.13 = specific_constant imports.%import_ref.12, @ImplicitAs(constants.%C) [template = constants.%.14]
 // CHECK:STDOUT:   %Convert.ref: %.13 = name_ref Convert, %.loc34_14.1 [template = constants.%.14]
 // CHECK:STDOUT:   %.loc34_14.2: %C = converted %b.ref, <error> [template = <error>]
-// CHECK:STDOUT:   %Op.call: init %C = call %.loc34_12.2(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %Op.call: init %C = call %.loc34_12.2(%a.ref, <error>) to %.loc23_21.2
 // CHECK:STDOUT:   return %Op.call to %return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
@@ -340,7 +340,7 @@ fn TestAssign(b: D) {
 // CHECK:STDOUT:   %.loc48_8.1: %.13 = specific_constant imports.%import_ref.12, @ImplicitAs(constants.%C) [template = constants.%.14]
 // CHECK:STDOUT:   %Convert.ref: %.13 = name_ref Convert, %.loc48_8.1 [template = constants.%.14]
 // CHECK:STDOUT:   %.loc48_8.2: %C = converted %b.ref, <error> [template = <error>]
-// CHECK:STDOUT:   %Op.call: init %.3 = call %.loc48_5.2(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %Op.call: init %.3 = call %.loc48_5.2(%.loc48_3, <error>)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 4 - 5
toolchain/check/testdata/operators/overloaded/index.carbon

@@ -812,11 +812,10 @@ let x: i32 = c[0];
 // CHECK:STDOUT:   %.loc22_25.4: %At.type.3 = interface_witness_access constants.%.8, element0 [template = constants.%At.2]
 // CHECK:STDOUT:   %.loc22_25.5: <bound method> = bound_method %c.ref, %.loc22_25.4
 // CHECK:STDOUT:   %.loc22_25.6: ref %ElementType.1 = temporary_storage
-// CHECK:STDOUT:   %At.call: init %ElementType.1 = call %.loc22_25.5(<invalid>) [template = <error>]
-// CHECK:STDOUT:   %.loc22_25.7: ref %ElementType.1 = temporary_storage
-// CHECK:STDOUT:   %.loc22_25.8: ref %ElementType.1 = temporary %.loc22_25.7, %At.call
-// CHECK:STDOUT:   %.loc22_25.9: %ElementType.1 = bind_value %.loc22_25.8
-// CHECK:STDOUT:   %x: %ElementType.1 = bind_name x, %.loc22_25.9
+// CHECK:STDOUT:   %At.call: init %ElementType.1 = call %.loc22_25.5(%c.ref, <error>) to %.loc22_25.6
+// CHECK:STDOUT:   %.loc22_25.7: ref %ElementType.1 = temporary %.loc22_25.6, %At.call
+// CHECK:STDOUT:   %.loc22_25.8: %ElementType.1 = bind_value %.loc22_25.7
+// CHECK:STDOUT:   %x: %ElementType.1 = bind_name x, %.loc22_25.8
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 1 - 1
toolchain/check/testdata/operators/overloaded/left_shift.carbon

@@ -238,7 +238,7 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   %Self: %LeftShiftAssign.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.2)]
 // CHECK:STDOUT:   %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.7)]
 // CHECK:STDOUT:
-// CHECK:STDOUT:   fn[addr <unexpected>.inst+93: @Op.4.%.2 (%.7)](%other.param_patt: @Op.4.%Self (%Self.2));
+// CHECK:STDOUT:   fn[addr <unexpected>.inst+95: @Op.4.%.2 (%.7)](%other.param_patt: @Op.4.%Self (%Self.2));
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestOp(%a.param_patt: %C, %b.param_patt: %C) -> %return: %C {

+ 1 - 1
toolchain/check/testdata/operators/overloaded/mod.carbon

@@ -238,7 +238,7 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   %Self: %ModAssign.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.2)]
 // CHECK:STDOUT:   %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.7)]
 // CHECK:STDOUT:
-// CHECK:STDOUT:   fn[addr <unexpected>.inst+93: @Op.4.%.2 (%.7)](%other.param_patt: @Op.4.%Self (%Self.2));
+// CHECK:STDOUT:   fn[addr <unexpected>.inst+95: @Op.4.%.2 (%.7)](%other.param_patt: @Op.4.%Self (%Self.2));
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestOp(%a.param_patt: %C, %b.param_patt: %C) -> %return: %C {

+ 1 - 1
toolchain/check/testdata/operators/overloaded/mul.carbon

@@ -238,7 +238,7 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   %Self: %MulAssign.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.2)]
 // CHECK:STDOUT:   %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.7)]
 // CHECK:STDOUT:
-// CHECK:STDOUT:   fn[addr <unexpected>.inst+93: @Op.4.%.2 (%.7)](%other.param_patt: @Op.4.%Self (%Self.2));
+// CHECK:STDOUT:   fn[addr <unexpected>.inst+95: @Op.4.%.2 (%.7)](%other.param_patt: @Op.4.%Self (%Self.2));
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestOp(%a.param_patt: %C, %b.param_patt: %C) -> %return: %C {

+ 28 - 28
toolchain/check/testdata/operators/overloaded/ordered.carbon

@@ -135,21 +135,21 @@ fn TestGreaterEqual(a: D, b: D) -> bool {
 // CHECK:STDOUT:     import Core//prelude/operators/comparison
 // CHECK:STDOUT:     import Core//prelude/types/bool
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.1: type = import_ref Core//prelude/operators/comparison, inst+68, loaded [template = constants.%Ordered.type]
-// CHECK:STDOUT:   %import_ref.2 = import_ref Core//prelude/operators/comparison, inst+70, unloaded
-// CHECK:STDOUT:   %import_ref.3: %.6 = import_ref Core//prelude/operators/comparison, inst+98, loaded [template = constants.%.7]
-// CHECK:STDOUT:   %import_ref.4: %.8 = import_ref Core//prelude/operators/comparison, inst+126, loaded [template = constants.%.9]
-// CHECK:STDOUT:   %import_ref.5: %.10 = import_ref Core//prelude/operators/comparison, inst+154, loaded [template = constants.%.11]
-// CHECK:STDOUT:   %import_ref.6: %.12 = import_ref Core//prelude/operators/comparison, inst+182, loaded [template = constants.%.13]
-// CHECK:STDOUT:   %import_ref.7: %Less.type.2 = import_ref Core//prelude/operators/comparison, inst+93, loaded [template = constants.%Less.2]
-// CHECK:STDOUT:   %import_ref.8: %LessOrEquivalent.type.2 = import_ref Core//prelude/operators/comparison, inst+121, loaded [template = constants.%LessOrEquivalent.2]
-// CHECK:STDOUT:   %import_ref.9: %Greater.type.2 = import_ref Core//prelude/operators/comparison, inst+149, loaded [template = constants.%Greater.2]
-// CHECK:STDOUT:   %import_ref.10: %GreaterOrEquivalent.type.2 = import_ref Core//prelude/operators/comparison, inst+177, loaded [template = constants.%GreaterOrEquivalent.2]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref Core//prelude/operators/comparison, inst+70, loaded [template = constants.%Ordered.type]
+// CHECK:STDOUT:   %import_ref.2 = import_ref Core//prelude/operators/comparison, inst+72, unloaded
+// CHECK:STDOUT:   %import_ref.3: %.6 = import_ref Core//prelude/operators/comparison, inst+100, loaded [template = constants.%.7]
+// CHECK:STDOUT:   %import_ref.4: %.8 = import_ref Core//prelude/operators/comparison, inst+128, loaded [template = constants.%.9]
+// CHECK:STDOUT:   %import_ref.5: %.10 = import_ref Core//prelude/operators/comparison, inst+156, loaded [template = constants.%.11]
+// CHECK:STDOUT:   %import_ref.6: %.12 = import_ref Core//prelude/operators/comparison, inst+184, loaded [template = constants.%.13]
+// CHECK:STDOUT:   %import_ref.7: %Less.type.2 = import_ref Core//prelude/operators/comparison, inst+95, loaded [template = constants.%Less.2]
+// CHECK:STDOUT:   %import_ref.8: %LessOrEquivalent.type.2 = import_ref Core//prelude/operators/comparison, inst+123, loaded [template = constants.%LessOrEquivalent.2]
+// CHECK:STDOUT:   %import_ref.9: %Greater.type.2 = import_ref Core//prelude/operators/comparison, inst+151, loaded [template = constants.%Greater.2]
+// CHECK:STDOUT:   %import_ref.10: %GreaterOrEquivalent.type.2 = import_ref Core//prelude/operators/comparison, inst+179, loaded [template = constants.%GreaterOrEquivalent.2]
 // CHECK:STDOUT:   %import_ref.11: %Bool.type = import_ref Core//prelude/types/bool, inst+5, loaded [template = constants.%Bool]
-// CHECK:STDOUT:   %import_ref.12 = import_ref Core//prelude/operators/comparison, inst+93, unloaded
-// CHECK:STDOUT:   %import_ref.13 = import_ref Core//prelude/operators/comparison, inst+121, unloaded
-// CHECK:STDOUT:   %import_ref.14 = import_ref Core//prelude/operators/comparison, inst+149, unloaded
-// CHECK:STDOUT:   %import_ref.15 = import_ref Core//prelude/operators/comparison, inst+177, unloaded
+// CHECK:STDOUT:   %import_ref.12 = import_ref Core//prelude/operators/comparison, inst+95, unloaded
+// CHECK:STDOUT:   %import_ref.13 = import_ref Core//prelude/operators/comparison, inst+123, unloaded
+// CHECK:STDOUT:   %import_ref.14 = import_ref Core//prelude/operators/comparison, inst+151, unloaded
+// CHECK:STDOUT:   %import_ref.15 = import_ref Core//prelude/operators/comparison, inst+179, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
@@ -529,20 +529,20 @@ fn TestGreaterEqual(a: D, b: D) -> bool {
 // CHECK:STDOUT:     import Core//prelude/types/bool
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %import_ref.1: %Bool.type = import_ref Core//prelude/types/bool, inst+5, loaded [template = constants.%Bool]
-// CHECK:STDOUT:   %import_ref.2: type = import_ref Core//prelude/operators/comparison, inst+68, loaded [template = constants.%Ordered.type]
-// CHECK:STDOUT:   %import_ref.3 = import_ref Core//prelude/operators/comparison, inst+70, unloaded
-// CHECK:STDOUT:   %import_ref.4: %.5 = import_ref Core//prelude/operators/comparison, inst+98, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.5: %.7 = import_ref Core//prelude/operators/comparison, inst+126, loaded [template = constants.%.8]
-// CHECK:STDOUT:   %import_ref.6: %.9 = import_ref Core//prelude/operators/comparison, inst+154, loaded [template = constants.%.10]
-// CHECK:STDOUT:   %import_ref.7: %.11 = import_ref Core//prelude/operators/comparison, inst+182, loaded [template = constants.%.12]
-// CHECK:STDOUT:   %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+93, unloaded
-// CHECK:STDOUT:   %import_ref.9 = import_ref Core//prelude/operators/comparison, inst+121, unloaded
-// CHECK:STDOUT:   %import_ref.10 = import_ref Core//prelude/operators/comparison, inst+149, unloaded
-// CHECK:STDOUT:   %import_ref.11 = import_ref Core//prelude/operators/comparison, inst+177, unloaded
-// CHECK:STDOUT:   %import_ref.12 = import_ref Core//prelude/operators/comparison, inst+93, unloaded
-// CHECK:STDOUT:   %import_ref.13 = import_ref Core//prelude/operators/comparison, inst+121, unloaded
-// CHECK:STDOUT:   %import_ref.14 = import_ref Core//prelude/operators/comparison, inst+149, unloaded
-// CHECK:STDOUT:   %import_ref.15 = import_ref Core//prelude/operators/comparison, inst+177, unloaded
+// CHECK:STDOUT:   %import_ref.2: type = import_ref Core//prelude/operators/comparison, inst+70, loaded [template = constants.%Ordered.type]
+// CHECK:STDOUT:   %import_ref.3 = import_ref Core//prelude/operators/comparison, inst+72, unloaded
+// CHECK:STDOUT:   %import_ref.4: %.5 = import_ref Core//prelude/operators/comparison, inst+100, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.5: %.7 = import_ref Core//prelude/operators/comparison, inst+128, loaded [template = constants.%.8]
+// CHECK:STDOUT:   %import_ref.6: %.9 = import_ref Core//prelude/operators/comparison, inst+156, loaded [template = constants.%.10]
+// CHECK:STDOUT:   %import_ref.7: %.11 = import_ref Core//prelude/operators/comparison, inst+184, loaded [template = constants.%.12]
+// CHECK:STDOUT:   %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+95, unloaded
+// CHECK:STDOUT:   %import_ref.9 = import_ref Core//prelude/operators/comparison, inst+123, unloaded
+// CHECK:STDOUT:   %import_ref.10 = import_ref Core//prelude/operators/comparison, inst+151, unloaded
+// CHECK:STDOUT:   %import_ref.11 = import_ref Core//prelude/operators/comparison, inst+179, unloaded
+// CHECK:STDOUT:   %import_ref.12 = import_ref Core//prelude/operators/comparison, inst+95, unloaded
+// CHECK:STDOUT:   %import_ref.13 = import_ref Core//prelude/operators/comparison, inst+123, unloaded
+// CHECK:STDOUT:   %import_ref.14 = import_ref Core//prelude/operators/comparison, inst+151, unloaded
+// CHECK:STDOUT:   %import_ref.15 = import_ref Core//prelude/operators/comparison, inst+179, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {

+ 1 - 1
toolchain/check/testdata/operators/overloaded/right_shift.carbon

@@ -238,7 +238,7 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   %Self: %RightShiftAssign.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.2)]
 // CHECK:STDOUT:   %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.7)]
 // CHECK:STDOUT:
-// CHECK:STDOUT:   fn[addr <unexpected>.inst+93: @Op.4.%.2 (%.7)](%other.param_patt: @Op.4.%Self (%Self.2));
+// CHECK:STDOUT:   fn[addr <unexpected>.inst+95: @Op.4.%.2 (%.7)](%other.param_patt: @Op.4.%Self (%Self.2));
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestOp(%a.param_patt: %C, %b.param_patt: %C) -> %return: %C {

+ 1 - 1
toolchain/check/testdata/operators/overloaded/sub.carbon

@@ -238,7 +238,7 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   %Self: %SubAssign.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.2)]
 // CHECK:STDOUT:   %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.7)]
 // CHECK:STDOUT:
-// CHECK:STDOUT:   fn[addr <unexpected>.inst+93: @Op.4.%.2 (%.7)](%other.param_patt: @Op.4.%Self (%Self.2));
+// CHECK:STDOUT:   fn[addr <unexpected>.inst+95: @Op.4.%.2 (%.7)](%other.param_patt: @Op.4.%Self (%Self.2));
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestOp(%a.param_patt: %C, %b.param_patt: %C) -> %return: %C {

+ 1 - 1
toolchain/check/testdata/packages/fail_conflict_no_namespaces.carbon

@@ -111,7 +111,7 @@ import library "var";
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
 // CHECK:STDOUT:   %import_ref.1 = import_ref Example//fn, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.2 = import_ref Example//var, inst+13, unloaded
+// CHECK:STDOUT:   %import_ref.2 = import_ref Example//var, inst+15, unloaded
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     import Core//prelude
 // CHECK:STDOUT:     import Core//prelude/operators

+ 1 - 1
toolchain/check/testdata/packages/implicit_imports_prelude.carbon

@@ -78,7 +78,7 @@ var b: i32 = a;
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
-// CHECK:STDOUT:   %import_ref.1: ref i32 = import_ref Main//lib, inst+13, loaded
+// CHECK:STDOUT:   %import_ref.1: ref i32 = import_ref Main//lib, inst+15, loaded
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.2
 // CHECK:STDOUT:     import Core//prelude

+ 2 - 2
toolchain/check/testdata/pointer/import.carbon

@@ -89,8 +89,8 @@ var a: i32* = a_ref;
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
-// CHECK:STDOUT:   %import_ref.1 = import_ref Implicit//default, inst+13, unloaded
-// CHECK:STDOUT:   %import_ref.2: ref %.2 = import_ref Implicit//default, inst+23, loaded
+// CHECK:STDOUT:   %import_ref.1 = import_ref Implicit//default, inst+15, unloaded
+// CHECK:STDOUT:   %import_ref.2: ref %.2 = import_ref Implicit//default, inst+25, loaded
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.3
 // CHECK:STDOUT:     import Core//prelude

+ 15 - 15
toolchain/check/testdata/struct/import.carbon

@@ -254,10 +254,10 @@ var c_bad: C({.a = 3, .b = 4}) = F();
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
-// CHECK:STDOUT:   %import_ref.1: ref %.2 = import_ref Implicit//default, inst+17, loaded
-// CHECK:STDOUT:   %import_ref.2: ref %.6 = import_ref Implicit//default, inst+57, loaded
-// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Implicit//default, inst+102, loaded [template = constants.%C.1]
-// CHECK:STDOUT:   %import_ref.4: %F.type = import_ref Implicit//default, inst+129, loaded [template = constants.%F]
+// CHECK:STDOUT:   %import_ref.1: ref %.2 = import_ref Implicit//default, inst+19, loaded
+// CHECK:STDOUT:   %import_ref.2: ref %.6 = import_ref Implicit//default, inst+59, loaded
+// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Implicit//default, inst+104, loaded [template = constants.%C.1]
+// CHECK:STDOUT:   %import_ref.4: %F.type = import_ref Implicit//default, inst+131, loaded [template = constants.%F]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.5
 // CHECK:STDOUT:     import Core//prelude
@@ -271,7 +271,7 @@ var c_bad: C({.a = 3, .b = 4}) = F();
 // CHECK:STDOUT:     import Core//prelude/types/bool
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %import_ref.5: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
-// CHECK:STDOUT:   %import_ref.6 = import_ref Implicit//default, inst+107, unloaded
+// CHECK:STDOUT:   %import_ref.6 = import_ref Implicit//default, inst+109, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
@@ -410,10 +410,10 @@ var c_bad: C({.a = 3, .b = 4}) = F();
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
-// CHECK:STDOUT:   %import_ref.1 = import_ref Implicit//default, inst+17, unloaded
-// CHECK:STDOUT:   %import_ref.2 = import_ref Implicit//default, inst+57, unloaded
-// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Implicit//default, inst+102, loaded [template = constants.%C.1]
-// CHECK:STDOUT:   %import_ref.4: %F.type = import_ref Implicit//default, inst+129, loaded [template = constants.%F]
+// CHECK:STDOUT:   %import_ref.1 = import_ref Implicit//default, inst+19, unloaded
+// CHECK:STDOUT:   %import_ref.2 = import_ref Implicit//default, inst+59, unloaded
+// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Implicit//default, inst+104, loaded [template = constants.%C.1]
+// CHECK:STDOUT:   %import_ref.4: %F.type = import_ref Implicit//default, inst+131, loaded [template = constants.%F]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     import Core//prelude
 // CHECK:STDOUT:     import Core//prelude/operators
@@ -425,7 +425,7 @@ var c_bad: C({.a = 3, .b = 4}) = F();
 // CHECK:STDOUT:     import Core//prelude/operators/comparison
 // CHECK:STDOUT:     import Core//prelude/types/bool
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.5 = import_ref Implicit//default, inst+107, unloaded
+// CHECK:STDOUT:   %import_ref.5 = import_ref Implicit//default, inst+109, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
@@ -527,10 +527,10 @@ var c_bad: C({.a = 3, .b = 4}) = F();
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
-// CHECK:STDOUT:   %import_ref.1 = import_ref Implicit//default, inst+17, unloaded
-// CHECK:STDOUT:   %import_ref.2 = import_ref Implicit//default, inst+57, unloaded
-// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Implicit//default, inst+102, loaded [template = constants.%C.1]
-// CHECK:STDOUT:   %import_ref.4: %F.type = import_ref Implicit//default, inst+129, loaded [template = constants.%F]
+// CHECK:STDOUT:   %import_ref.1 = import_ref Implicit//default, inst+19, unloaded
+// CHECK:STDOUT:   %import_ref.2 = import_ref Implicit//default, inst+59, unloaded
+// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Implicit//default, inst+104, loaded [template = constants.%C.1]
+// CHECK:STDOUT:   %import_ref.4: %F.type = import_ref Implicit//default, inst+131, loaded [template = constants.%F]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .ImplicitAs = %import_ref.6
 // CHECK:STDOUT:     import Core//prelude
@@ -543,7 +543,7 @@ var c_bad: C({.a = 3, .b = 4}) = F();
 // CHECK:STDOUT:     import Core//prelude/operators/comparison
 // CHECK:STDOUT:     import Core//prelude/types/bool
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.5 = import_ref Implicit//default, inst+107, unloaded
+// CHECK:STDOUT:   %import_ref.5 = import_ref Implicit//default, inst+109, unloaded
 // CHECK:STDOUT:   %import_ref.6: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+49, loaded [template = constants.%ImplicitAs]
 // CHECK:STDOUT:   %import_ref.7 = import_ref Core//prelude/operators/as, inst+55, unloaded
 // CHECK:STDOUT:   %import_ref.8: @ImplicitAs.%.1 (%.11) = import_ref Core//prelude/operators/as, inst+77, loaded [symbolic = @ImplicitAs.%.2 (constants.%.15)]

+ 15 - 15
toolchain/check/testdata/tuple/import.carbon

@@ -277,10 +277,10 @@ var c_bad: C((3, 4)) = F();
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
-// CHECK:STDOUT:   %import_ref.1: ref %.3 = import_ref Implicit//default, inst+17, loaded
-// CHECK:STDOUT:   %import_ref.2: ref %.9 = import_ref Implicit//default, inst+57, loaded
-// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Implicit//default, inst+106, loaded [template = constants.%C.1]
-// CHECK:STDOUT:   %import_ref.4: %F.type = import_ref Implicit//default, inst+128, loaded [template = constants.%F]
+// CHECK:STDOUT:   %import_ref.1: ref %.3 = import_ref Implicit//default, inst+19, loaded
+// CHECK:STDOUT:   %import_ref.2: ref %.9 = import_ref Implicit//default, inst+59, loaded
+// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Implicit//default, inst+108, loaded [template = constants.%C.1]
+// CHECK:STDOUT:   %import_ref.4: %F.type = import_ref Implicit//default, inst+130, loaded [template = constants.%F]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .Int32 = %import_ref.5
 // CHECK:STDOUT:     import Core//prelude
@@ -294,7 +294,7 @@ var c_bad: C((3, 4)) = F();
 // CHECK:STDOUT:     import Core//prelude/types/bool
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %import_ref.5: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
-// CHECK:STDOUT:   %import_ref.6 = import_ref Implicit//default, inst+111, unloaded
+// CHECK:STDOUT:   %import_ref.6 = import_ref Implicit//default, inst+113, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
@@ -450,10 +450,10 @@ var c_bad: C((3, 4)) = F();
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
-// CHECK:STDOUT:   %import_ref.1 = import_ref Implicit//default, inst+17, unloaded
-// CHECK:STDOUT:   %import_ref.2 = import_ref Implicit//default, inst+57, unloaded
-// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Implicit//default, inst+106, loaded [template = constants.%C.1]
-// CHECK:STDOUT:   %import_ref.4: %F.type = import_ref Implicit//default, inst+128, loaded [template = constants.%F]
+// CHECK:STDOUT:   %import_ref.1 = import_ref Implicit//default, inst+19, unloaded
+// CHECK:STDOUT:   %import_ref.2 = import_ref Implicit//default, inst+59, unloaded
+// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Implicit//default, inst+108, loaded [template = constants.%C.1]
+// CHECK:STDOUT:   %import_ref.4: %F.type = import_ref Implicit//default, inst+130, loaded [template = constants.%F]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     import Core//prelude
 // CHECK:STDOUT:     import Core//prelude/operators
@@ -465,7 +465,7 @@ var c_bad: C((3, 4)) = F();
 // CHECK:STDOUT:     import Core//prelude/operators/comparison
 // CHECK:STDOUT:     import Core//prelude/types/bool
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.5 = import_ref Implicit//default, inst+111, unloaded
+// CHECK:STDOUT:   %import_ref.5 = import_ref Implicit//default, inst+113, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
@@ -568,10 +568,10 @@ var c_bad: C((3, 4)) = F();
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: imports {
-// CHECK:STDOUT:   %import_ref.1 = import_ref Implicit//default, inst+17, unloaded
-// CHECK:STDOUT:   %import_ref.2 = import_ref Implicit//default, inst+57, unloaded
-// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Implicit//default, inst+106, loaded [template = constants.%C.1]
-// CHECK:STDOUT:   %import_ref.4: %F.type = import_ref Implicit//default, inst+128, loaded [template = constants.%F]
+// CHECK:STDOUT:   %import_ref.1 = import_ref Implicit//default, inst+19, unloaded
+// CHECK:STDOUT:   %import_ref.2 = import_ref Implicit//default, inst+59, unloaded
+// CHECK:STDOUT:   %import_ref.3: %C.type = import_ref Implicit//default, inst+108, loaded [template = constants.%C.1]
+// CHECK:STDOUT:   %import_ref.4: %F.type = import_ref Implicit//default, inst+130, loaded [template = constants.%F]
 // CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
 // CHECK:STDOUT:     .ImplicitAs = %import_ref.6
 // CHECK:STDOUT:     import Core//prelude
@@ -584,7 +584,7 @@ var c_bad: C((3, 4)) = F();
 // CHECK:STDOUT:     import Core//prelude/operators/comparison
 // CHECK:STDOUT:     import Core//prelude/types/bool
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.5 = import_ref Implicit//default, inst+111, unloaded
+// CHECK:STDOUT:   %import_ref.5 = import_ref Implicit//default, inst+113, unloaded
 // CHECK:STDOUT:   %import_ref.6: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+49, loaded [template = constants.%ImplicitAs]
 // CHECK:STDOUT:   %import_ref.7 = import_ref Core//prelude/operators/as, inst+55, unloaded
 // CHECK:STDOUT:   %import_ref.8: @ImplicitAs.%.1 (%.11) = import_ref Core//prelude/operators/as, inst+77, loaded [symbolic = @ImplicitAs.%.2 (constants.%.15)]

+ 0 - 1
toolchain/diagnostics/diagnostic_kind.def

@@ -193,7 +193,6 @@ CARBON_DIAGNOSTIC_KIND(IncompleteReturnTypeHere)
 CARBON_DIAGNOSTIC_KIND(InCallToEntity)
 CARBON_DIAGNOSTIC_KIND(InCallToFunction)
 CARBON_DIAGNOSTIC_KIND(InCallToFunctionParam)
-CARBON_DIAGNOSTIC_KIND(InCallToFunctionSelf)
 CARBON_DIAGNOSTIC_KIND(MissingObjectInMethodCall)
 CARBON_DIAGNOSTIC_KIND(SelfParameterNotAllowed)
 

+ 10 - 3
toolchain/sem_ir/function.h

@@ -20,10 +20,16 @@ struct FunctionFields {
   // The following members always have values, and do not change throughout the
   // lifetime of the function.
 
+  // A reference to the instruction in the entity's pattern block that depends
+  // on all other pattern insts pertaining to the return slot pattern. This may
+  // or may not be used by the function, depending on whether the return type
+  // needs a return slot, but is always present if the function has a declared
+  // return type.
+  InstId return_slot_pattern_id;
+
   // The storage for the return value, which is a reference expression whose
-  // type is the return type of the function. This may or may not be used by the
-  // function, depending on whether the return type needs a return slot, but is
-  // always present if the function has a declared return type.
+  // type is the return type of the function. As with return_slot_pattern_id,
+  // this is always present if the function has a declared return type.
   InstId return_slot_id;
 
   // Which, if any, virtual modifier (virtual, abstract, or impl) is applied to
@@ -54,6 +60,7 @@ struct Function : public EntityWithParamsBase,
     out << "{";
     PrintBaseFields(out);
     if (return_slot_id.is_valid()) {
+      out << ", return_slot_pattern: " << return_slot_pattern_id;
       out << ", return_slot: " << return_slot_id;
     }
     if (!body_block_ids.empty()) {

+ 4 - 2
toolchain/sem_ir/typed_insts.h

@@ -945,7 +945,8 @@ struct ReturnSlot {
   TypeId type_id;
 
   // The function return type as originally written by the user. For diagnostics
-  // only; this has no semantic significance.
+  // only; this has no semantic significance, and is not preserved across
+  // imports.
   InstId type_inst_id;
 
   // The storage that will be initialized by the function.
@@ -965,7 +966,8 @@ struct ReturnSlotPattern {
   TypeId type_id;
 
   // The function return type as originally written by the user. For diagnostics
-  // only; this has no semantic significance.
+  // only; this has no semantic significance, and is not preserved across
+  // imports.
   InstId type_inst_id;
 };
 

+ 1 - 2
toolchain/sem_ir/yaml_test.cpp

@@ -94,8 +94,7 @@ TEST(SemIRTest, YAML) {
                Pair("import_refs", Yaml::Mapping(IsEmpty())),
                Pair("global_init", Yaml::Mapping(IsEmpty())),
                Pair("block4", Yaml::Mapping(Each(Pair(_, inst_id)))),
-               Pair("block5", Yaml::Mapping(Each(Pair(_, inst_id)))),
-               Pair("block6", Yaml::Mapping(Each(Pair(_, inst_id)))))))));
+               Pair("block5", Yaml::Mapping(Each(Pair(_, inst_id)))))))));
 
   auto root = Yaml::Sequence(ElementsAre(Yaml::Mapping(
       ElementsAre(Pair("filename", "test.carbon"), Pair("sem_ir", file)))));