forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IRGen] Fix RecordTypeInfoImpl::initWithTake.
Apply the same control-flow changes to the method that were applied on main to avoid duplicated implementations one of which crashes with ``` Metadata for archetype not bound in function. The metadata could be missing entirely because it needs to be passed to the function. Or the metadata is present and not bound in which case setScopedLocalTypeMetadata or similar must be called. Archetype without metadata: Value (primary_archetype_type address=0x14207ebe0 conforms_to="Swift.(file).Escapable" name="Value" (interface_type=generic_type_param_type depth=0 index=0 decl="Synchronization.(file)._Cell.Value@/Volumes/ams1_ext4/Submit/SWE/DevTools/swift/6_0_0_6/swift/stdlib/public/Synchronization/Cell.swift:19:23")) Function: ; Function Attrs: noinline nounwind define linkonce_odr hidden ptr @"$s15Synchronization5_CellVyxGRi_zlWOb"(ptr %0, ptr %1, ptr %2) swiftlang#14 !dbg !8 { %4 = alloca i1, align 1 } LocalTypeData: (0x14207f5f8 (_Cell<Value>), FormalTypeMetadata) => [ (universal) concrete: 0x600003d1add0 ptr %2 ] ``` when building Synchronization.
- Loading branch information
1 parent
54898ce
commit 7fcbedd
Showing
2 changed files
with
56 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// RUN: %target-swift-emit-irgen -O \ | ||
// RUN: -parse-sil \ | ||
// RUN: -disable-type-layout \ | ||
// RUN: %s \ | ||
// RUN: -enable-experimental-feature RawLayout \ | ||
// RUN: | \ | ||
// RUN: %IRGenFileCheck %s | ||
|
||
import Builtin | ||
import Swift | ||
|
||
@usableFromInline | ||
@frozen @_rawLayout(like: Value, movesAsLike) internal struct _Cell<Value> : ~Copyable where Value : ~Copyable { | ||
@_alwaysEmitIntoClient @inlinable deinit | ||
} | ||
|
||
sil @$sSp12deinitialize5countSvSi_tF : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (Int, UnsafeMutablePointer<τ_0_0>) -> UnsafeMutableRawPointer | ||
|
||
// CHECK-LABEL: define swiftcc void @"$s15Synchronization5_CellVAARi_zrlEfD"( | ||
// CHECK-SAME: ptr %"_Cell<Value>", | ||
// CHECK-SAME: ptr noalias swiftself [[SOURCE:%[0-9]+]] | ||
// CHECK-SAME: ) | ||
// CHECK-SAME: { | ||
// CHECK: entry: | ||
// CHECK: [[CELL_VWT_ADDR:%[^,]+]] = getelementptr inbounds ptr, ptr %"_Cell<Value>", i64 -1 | ||
// CHECK: %"_Cell<Value>.valueWitnesses" = load ptr, ptr [[CELL_VWT_ADDR]] | ||
// CHECK: [[CELL_SIZE_ADDR:%[^,]+]] = getelementptr inbounds %swift.vwtable, ptr %"_Cell<Value>.valueWitnesses", i32 0, i32 8 | ||
// CHECK: %size = load i64, ptr [[CELL_SIZE_ADDR]] | ||
// CHECK: [[DEST:%[^,]+]] = alloca i8, i64 %size | ||
// CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr [[DEST]]) | ||
// CHECK: [[VALUE_METADATA_ADDR:%[^,]+]] = getelementptr inbounds ptr, ptr %"_Cell<Value>", i64 2 | ||
// CHECK: %Value = load ptr, ptr [[VALUE_METADATA_ADDR]] | ||
// CHECK: [[VALUE_VWT_ADDR:%[^,]+]] = getelementptr inbounds ptr, ptr %Value, i64 -1 | ||
// CHECK: %Value.valueWitnesses = load ptr, ptr [[VALUE_VWT_ADDR]] | ||
// CHECK: [[VALUE_INIT_WITH_TAKE_ADDR:%[^,]+]] = getelementptr inbounds ptr, ptr %Value.valueWitnesses, i32 4 | ||
// CHECK: %InitializeWithTake = load ptr, ptr [[VALUE_INIT_WITH_TAKE_ADDR]] | ||
// CHECK: call ptr %InitializeWithTake(ptr noalias [[DEST]], ptr noalias [[SOURCE]], ptr %Value) | ||
// CHECK: call swiftcc ptr @"$sSp12deinitialize5countSvSi_tF"(i64 1, ptr [[DEST]], ptr %Value) | ||
// CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr [[DEST]]) | ||
// CHECK: } | ||
sil @$s15Synchronization5_CellVAARi_zrlEfD : $@convention(method) <Value where Value : ~Copyable> (@in _Cell<Value>) -> () { | ||
bb0(%0 : $*_Cell<Value>): | ||
%1 = alloc_stack $_Cell<Value> | ||
copy_addr [take] %0 to [init] %1 : $*_Cell<Value> | ||
%7 = builtin "addressOfRawLayout"<_Cell<Value>>(%1 : $*_Cell<Value>) : $Builtin.RawPointer | ||
%8 = struct $UnsafeMutablePointer<Value> (%7 : $Builtin.RawPointer) | ||
%9 = integer_literal $Builtin.Int64, 1 | ||
%10 = struct $Int (%9 : $Builtin.Int64) | ||
%11 = function_ref @$sSp12deinitialize5countSvSi_tF : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (Int, UnsafeMutablePointer<τ_0_0>) -> UnsafeMutableRawPointer | ||
%12 = apply %11<Value>(%10, %8) : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (Int, UnsafeMutablePointer<τ_0_0>) -> UnsafeMutableRawPointer | ||
%13 = tuple () | ||
dealloc_stack %1 : $*_Cell<Value> | ||
return %13 : $() | ||
} |