Don't treat dependent types as having a copy value representation. (#6055)

Add `Dependent` value and initializing representations for types whose
representations are unknown because they are dependent. When generating
SemIR in such cases, use a worst-case initializing representation that
both provides a destination address and also propagates a potential
result value.

Use this to fix incorrect lowering and lowering crashes for specific
functions involving generic types that don't use a copy value
representation.

In lowering, be careful to distinguish between whether the initializing
representation for the generic return type uses a return slot (which
affects whether the SemIR declaration and call have one) and whether the
initializing representation for the specific return type uses a return
slot (which affects whether the LLVM IR declaration and call have one).
This commit is contained in:
Richard Smith
2025-09-15 23:59:00 +00:00
committed by GitHub
parent ca40e9d693
commit b44ba47cf3
53 changed files with 1375 additions and 670 deletions
+1 -1
View File
@@ -502,7 +502,6 @@ fn G(N:! i32) {
// CHECK:STDOUT: %const: type = const_type %T [symbolic]
// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [concrete]
// CHECK:STDOUT: %tuple.type.4f2: type = tuple_type (%ptr.79f, %const) [symbolic]
// CHECK:STDOUT: %ptr.6cd: type = ptr_type %tuple.type.4f2 [symbolic]
// CHECK:STDOUT: %require_complete.155: <witness> = require_complete_type %tuple.type.4f2 [symbolic]
// CHECK:STDOUT: %pattern_type.973: type = pattern_type %tuple.type.4f2 [symbolic]
// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %T} [symbolic]
@@ -528,6 +527,7 @@ fn G(N:! i32) {
// CHECK:STDOUT: %.aa5: type = fn_type_with_self_type %Destroy.Op.type, %Destroy.facet.90b [symbolic]
// CHECK:STDOUT: %impl.elem0.d3d: %.aa5 = impl_witness_access %Destroy.lookup_impl_witness.b34, element0 [symbolic]
// CHECK:STDOUT: %specific_impl_fn.612: <specific function> = specific_impl_function %impl.elem0.d3d, @Destroy.Op(%Destroy.facet.90b) [symbolic]
// CHECK:STDOUT: %ptr.6cd: type = ptr_type %tuple.type.4f2 [symbolic]
// CHECK:STDOUT: %require_complete.66e: <witness> = require_complete_type %ptr.6cd [symbolic]
// CHECK:STDOUT: %Destroy.lookup_impl_witness.a8a: <witness> = lookup_impl_witness %tuple.type.4f2, @Destroy [symbolic]
// CHECK:STDOUT: %Destroy.facet.6c8: %Destroy.type = facet_value %tuple.type.4f2, (%Destroy.lookup_impl_witness.a8a) [symbolic]