Prechádzať zdrojové kódy

Remove ReturnTypeInfo (#6619)

Geoff Romer 3 mesiacov pred
rodič
commit
f53f837125

+ 5 - 10
toolchain/docs/lower.md

@@ -81,16 +81,11 @@ taken to only pass the `TypeId` in a `TypeInFile` to code that expects a
 code within `FunctionContext` and `HandleInst` functions should not directly
 interact with `TypeId`s, and should instead always use `TypeInFile`.
 
-Similarly, other type properties have `FunctionContext` wrappers that track the
-file that owns the `TypeId`s:
-
--   `FunctionContext::GetValueRepr` returns a `ValueReprInFile` which is a pair
-    of a `SemIR::File*` and a `SemIR::ValueRepr`.
--   `FunctionContext::GetReturnTypeInfo` returns a `ReturnTypeInfoInFile` which
-    is a pair of a `SemIR::File*` and a `SemIR::ReturnTypeInfo`.
-
-These pairs are kept wrapped in the `*InFile` structs wherever possible, in
-order to minimize the chance of an ID being used with the wrong file.
+Similarly, `SemIR::ValueRepr` has a `FunctionContext::ValueReprInFile` wrapper
+that tracks the file that owns its `TypeId`, and `SemIR::InstId` has a
+`FunctionContext::InstInFile` wrapper that tracks the file that owns the
+`InstId`. These wrappers are kept intact wherever possible, in order to minimize
+the chance of an ID being used with the wrong file.
 
 ## Specific deduplication and fingerprinting
 

+ 0 - 9
toolchain/lower/function_context.cpp

@@ -314,15 +314,6 @@ auto FunctionContext::GetInitRepr(TypeInFile type) -> SemIR::InitRepr {
   return result;
 }
 
-auto FunctionContext::GetReturnTypeInfo(InstInFile callee)
-    -> ReturnTypeInfoInFile {
-  ReturnTypeInfoInFile result = {
-      .file = callee.file,
-      .info = SemIR::ReturnTypeInfo::ForCallee(*callee.file, callee.inst_id)};
-  AddEnumToCurrentFingerprint(result.info.init_repr.kind);
-  return result;
-}
-
 // Given a type used for an LLVM value, return the type that we use to store
 // that value in memory. This is the same type unless the type is a
 // non-multiple-of-8 integer type, which we explicitly widen to a multiple of 8

+ 0 - 16
toolchain/lower/function_context.h

@@ -86,18 +86,6 @@ class FunctionContext {
     SemIR::InstId inst_id;
   };
 
-  // Information about a function's return type in a particular file. By
-  // convention, this represents a value whose initializing representation has
-  // been added to the fingerprint but whose type has not.
-  struct ReturnTypeInfoInFile {
-    const SemIR::File* file;
-    SemIR::ReturnTypeInfo info;
-
-    auto type() -> TypeInFile {
-      return {.file = file, .type_id = info.type_id};
-    }
-  };
-
   // Returns a basic block corresponding to the start of the given semantics
   // block, and enqueues it for emission.
   auto GetBlock(SemIR::InstBlockId block_id) -> llvm::BasicBlock*;
@@ -153,10 +141,6 @@ class FunctionContext {
   // kind of initializing representation to the fingerprint.
   auto GetInitRepr(TypeInFile type) -> SemIR::InitRepr;
 
-  // Returns the return type information for the given callee inst. This adds
-  // the kind of initializing representation to the fingerprint.
-  auto GetReturnTypeInfo(InstInFile callee) -> ReturnTypeInfoInFile;
-
   // Returns a lowered value to use for a value of type `type`.
   auto GetTypeAsValue() -> llvm::Value* {
     return file_context_->GetTypeAsValue();

+ 0 - 9
toolchain/sem_ir/type_info.cpp

@@ -79,15 +79,6 @@ auto InitRepr::ForType(const File& file, TypeId type_id) -> InitRepr {
   }
 }
 
-auto ReturnTypeInfo::ForCallee(const File& file, InstId callee_id,
-                               SemIR::SpecificId caller_specific_id)
-    -> ReturnTypeInfo {
-  auto callee_function =
-      SemIR::GetCalleeAsFunction(file, callee_id, caller_specific_id);
-  auto function = file.functions().Get(callee_function.function_id);
-  return ForFunction(file, function, callee_function.resolved_specific_id);
-}
-
 auto NumericTypeLiteralInfo::ForType(const File& file, ClassType class_type)
     -> NumericTypeLiteralInfo {
   // Quickly rule out any class that's not a specific.

+ 0 - 39
toolchain/sem_ir/type_info.h

@@ -164,45 +164,6 @@ struct InitRepr : Printable<InitRepr> {
   }
 };
 
-// Information about a function's return type.
-struct ReturnTypeInfo : public Printable<ReturnTypeInfo> {
-  // Builds return type information for a given function.
-  static auto ForFunction(const File& file, const Function& function,
-                          SpecificId specific_id = SpecificId::None)
-      -> ReturnTypeInfo {
-    auto type_id = function.GetDeclaredReturnType(file, specific_id);
-    return {.type_id = type_id,
-            .init_repr = type_id.has_value()
-                             ? InitRepr::ForType(file, type_id)
-                             : InitRepr{.kind = InitRepr::None}};
-  }
-
-  // Builds return type information for the function corresponding to callee_id
-  // in caller_specific_id.
-  static auto ForCallee(const File& file, InstId callee_id,
-                        SpecificId caller_specific_id = SemIR::SpecificId::None)
-      -> ReturnTypeInfo;
-
-  // Returns whether the return information could be fully computed.
-  auto is_valid() const -> bool { return init_repr.is_valid(); }
-
-  // Returns whether a function with this return type has a return slot. Can
-  // only be called for valid return info.
-  auto has_return_slot() const -> bool {
-    CARBON_CHECK(is_valid());
-    return init_repr.MightBeInPlace();
-  }
-
-  auto Print(llvm::raw_ostream& out) const -> void {
-    out << "{type_id: " << type_id << ", init_repr: " << init_repr << "}";
-  }
-
-  // The declared return type. `None` if no return type was specified.
-  TypeId type_id;
-  // The initializing representation for the return type.
-  InitRepr init_repr;
-};
-
 // Information about the numeric type literal that corresponds to a type.
 struct NumericTypeLiteralInfo {
   // The kind of a numeric type literal, as determined by the letter that