Skip to content

Commit

Permalink
Fix test cases and enable copy-on-write existentials
Browse files Browse the repository at this point in the history
  • Loading branch information
aschwaighofer committed Mar 28, 2017
1 parent 17e8ce4 commit 343193f
Show file tree
Hide file tree
Showing 19 changed files with 149 additions and 121 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ option(SWIFT_STDLIB_ENABLE_RESILIENCE

option(SWIFT_RUNTIME_ENABLE_COW_EXISTENTIALS
"Build the runtime with a copy-on-write implementation for opaque existentials"
FALSE)
TRUE)

option(SWIFT_STDLIB_USE_NONATOMIC_RC
"Build the standard libraries and overlays with nonatomic reference count operations enabled"
Expand Down
11 changes: 6 additions & 5 deletions test/IRGen/alloc.sil
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ struct Huge {
}

// CHECK: @_swift_slowAlloc = external global i8* ([[SIZE_T:i(32|64)]],
// CHECK: define linkonce_odr hidden i8* @swift_rt_swift_slowAlloc([[SIZE_T:i(32|64)]],

// CHECK: define linkonce_odr hidden void @_T04main4HugeVwde(
// CHECK: [[T0:%.*]] = bitcast [[BUFFER:.[0-9]+ x i8.]]* {{%.*}} to i8**
// CHECK-NEXT: [[T1:%.*]] = load i8*, i8** [[T0]]
// CHECK-NEXT: call void @swift_rt_swift_slowDealloc(i8* [[T1]], [[SIZE_T]] 4097, [[SIZE_T]] 7)
// CHECK-NEXT: ret void

// CHECK: define linkonce_odr hidden [[OPAQUE:%swift.opaque]]* @_T04main4HugeVwal(
// CHECK: [[T0:%.*]] = call noalias i8* @swift_rt_swift_slowAlloc([[SIZE_T]] 4097, [[SIZE_T]] 7)
// CHECK-NEXT: [[T1:%.*]] = bitcast [[BUFFER]]* {{%.*}} to i8**
// CHECK-NEXT: store i8* [[T0]], i8** [[T1]]

// CHECK: define linkonce_odr hidden [[OPAQUE:%swift.opaque]]* @_T04main4HugeVwal({{.*}}* [[BUFFER:%.*]], %swift.type
// CHECK: [[BOXPAIR:%.*]] = call { %swift.refcounted*, %swift.opaque* } @swift_allocBox({{.*}} @_T04main4HugeVMf
// CHECK: [[REF:%.*]] = extractvalue { %swift.refcounted*, %swift.opaque* } %0, 0
// CHECK: [[BUFFER_ADDR:%.*]] = bitcast {{.*}}* [[BUFFER]] to %swift.refcounted**
// CHECK: store %swift.refcounted* [[REF]], %swift.refcounted** [[BUFFER_ADDR]]
19 changes: 10 additions & 9 deletions test/IRGen/existentials_objc.sil
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ bb0(%0 : $*Any, %1 : $T):
// CHECK: [[T0:%.*]] = getelementptr inbounds [[ANY]], [[ANY]]* %0, i32 0, i32 1
// CHECK-NEXT: store [[TYPE]]* %T, [[TYPE]]** [[T0]], align 8
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[ANY]], [[ANY]]* %0, i32 0, i32 0
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[ANY]], [[ANY]]* %0, i32 0, i32 0
// CHECK-NEXT: [[T1:%.*]] = bitcast [24 x i8]* [[T0]] to [[GIZMO]]**
// CHECK-NEXT: store [[GIZMO]]* %1, [[GIZMO]]** [[T1]], align 8
// CHECK-NEXT: ret void
Expand All @@ -39,15 +40,15 @@ bb0(%0 : $*Any, %1 : $*Any):
// CHECK-NEXT: [[TYPE:%.*]] = load %swift.type*, %swift.type** [[T0]], align 8
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[ANY]], [[ANY]]* [[DEST:%0]], i32 0, i32 1
// CHECK-NEXT: store %swift.type* [[TYPE]], %swift.type** [[T0]], align 8
// CHECK-NEXT: [[SRC_BUF:%.*]] = getelementptr inbounds [[ANY]], [[ANY]]* [[SRC]], i32 0, i32 0
// CHECK-NEXT: [[DEST_BUF:%.*]] = getelementptr inbounds [[ANY]], [[ANY]]* [[DEST]], i32 0, i32 0
// CHECK-NEXT: [[T0:%.*]] = bitcast %swift.type* [[TYPE]] to i8***
// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8**, i8*** [[T0]], i64 -1
// CHECK-NEXT: [[VWTABLE:%.*]] = load i8**, i8*** [[T1]], align 8
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds i8*, i8** [[VWTABLE]], i32 12
// CHECK-NEXT: [[T1:%.*]] = load i8*, i8** [[T0]], align 8
// CHECK-NEXT: [[INIT:%.*]] = bitcast i8* [[T1]] to %swift.opaque* ([24 x i8]*, [24 x i8]*, %swift.type*)*
// CHECK-NEXT: call %swift.opaque* [[INIT]]([24 x i8]* noalias [[DEST_BUF]], [24 x i8]* [[SRC_BUF]], %swift.type* [[TYPE]])
// CHECK-NEXT: [[FROM_BUFFER_ADDR:%.*]] = getelementptr inbounds %Any, %Any* %1, i32 0, i32 0
// CHECK-NEXT: [[TO_BUFFER_ADDR:%.*]] = getelementptr inbounds %Any, %Any* %0, i32 0, i32 0
// CHECK-NEXT: [[CAST:%.*]] = bitcast %swift.type* [[TYPE]] to i8***
// CHECK-NEXT: [[VWT_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[CAST]], i64 -1
// CHECK-NEXT: [[VWT:%.*]] = load i8**, i8*** [[VWT_ADDR]]
// CHECK-NEXT: [[VW_ADDR:%.*]] = getelementptr inbounds i8*, i8** [[VWT]], i32 12
// CHECK-NEXT: [[VW:%.*]] = load i8*, i8** [[VW_ADDR]]
// CHECK-NEXT: [[INITWITHTAKEBUFFER:%.*]] = bitcast i8* [[VW]]
// CHECK-NEXT: call %swift.opaque* [[INITWITHTAKEBUFFER]]({{.*}} [[TO_BUFFER_ADDR]], {{.*}} [[FROM_BUFFER_ADDR]], %swift.type* [[TYPE]])
// CHECK-NEXT: ret void

// rdar://problem/19035529
Expand Down
24 changes: 4 additions & 20 deletions test/IRGen/fixed_size_buffer_peepholes.sil
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,17 @@ import Builtin

protocol P {}

// CHECK-LABEL: define{{( protected)?}} swiftcc void @join_init_existential_copy_addr(%T27fixed_size_buffer_peepholes1PP* noalias nocapture sret, %swift.opaque* noalias nocapture, %swift.type* %T, i8** %T.P)
// CHECK: [[BUFFER:%.*]] = getelementptr inbounds %T27fixed_size_buffer_peepholes1PP, %T27fixed_size_buffer_peepholes1PP* %0, i32 0, i32 0
// CHECK: call %swift.opaque* %initializeBufferWithTake([[BUFFER_TYPE:\[.* x i8\]]]* [[BUFFER]], %swift.opaque* %1
sil @join_init_existential_copy_addr : $@convention(thin) <T: P> (@in T) -> @out P {
entry(%p : $*P, %x: $*T):
%y = init_existential_addr %p : $*P, $T
copy_addr [take] %x to [initialization] %y : $*T
return undef : $()
}

// CHECK-LABEL: define{{( protected)?}} swiftcc void @dont_crash(
// CHECK: [[TYPE_ADDR:%.*]] = getelementptr inbounds %T27fixed_size_buffer_peepholes1PP, %T27fixed_size_buffer_peepholes1PP* %0, i32 0, i32 1
// CHECK: [[TYPE:%.*]] = load %swift.type*, %swift.type** [[TYPE_ADDR]]
// CHECK: call {{.*}} @__swift_project_boxed_opaque_existential_1
// CHECK: [[PTR:%.*]] = bitcast %swift.type* [[TYPE]] to i8***
// CHECK: [[VWT_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[PTR]], {{(i64|i32)}} -1
// CHECK: [[VWT:%.*]] = load i8**, i8*** [[VWT_ADDR]]
// CHECK: [[WITNESS_ADDR:%.*]] = getelementptr inbounds i8*, i8** [[VWT]], {{(i64|i32)}} 2
// CHECK: [[WITNESS:%.*]] = load i8*, i8** [[WITNESS_ADDR]]
// CHECK: [[PROJECTBUFFER:%.*]] = bitcast i8* [[WITNESS]]
// CHECK: call %swift.opaque* [[PROJECTBUFFER]](
// CHECK: [[PTR:%.*]] = bitcast %swift.type* [[TYPE]] to i8***
// CHECK: [[VWT_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[PTR]], {{(i64|i32)}} -1
// CHECK: [[VWT:%.*]] = load i8**, i8*** [[VWT_ADDR]]
// CHECK: [[WITNESS_ADDR:%.*]] = getelementptr inbounds i8*, i8** [[VWT]], {{(i64|i32)}} 5
// CHECK: [[WITNESS_ADDR:%.*]] = getelementptr inbounds i8*, i8** [[VWT]], {{(i64|i32)}} 6
// CHECK: [[WITNESS:%.*]] = load i8*, i8** [[WITNESS_ADDR]]
// CHECK: [[INITBUFFERWITHCOPY:%.*]] = bitcast i8* [[WITNESS]] to %swift.opaque* ([{{.*}} x i8]*, %swift.opaque*, %swift.type*)*
// CHECK: call %swift.opaque* [[INITBUFFERWITHCOPY]](
// CHECK: [[INITWITHCOPY:%.*]] = bitcast i8* [[WITNESS]] to %swift.opaque* (%swift.opaque*, %swift.opaque*, %swift.type*)*
// CHECK: call %swift.opaque* [[INITWITHCOPY]](
sil @dont_crash : $@convention(thin) (@in P) -> () {
entry(%p : $*P):
%0 = alloc_stack $P
Expand Down
20 changes: 5 additions & 15 deletions test/IRGen/generic_metatypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,11 @@ func protocolTypeof(_ x: Bas) -> Bas.Type {
// CHECK: [[METADATA_ADDR:%.*]] = getelementptr inbounds %T17generic_metatypes3BasP, %T17generic_metatypes3BasP* [[X:%.*]], i32 0, i32 1
// CHECK: [[METADATA:%.*]] = load %swift.type*, %swift.type** [[METADATA_ADDR]]
// CHECK: [[BUFFER:%.*]] = getelementptr inbounds %T17generic_metatypes3BasP, %T17generic_metatypes3BasP* [[X]], i32 0, i32 0
// CHECK: [[METADATA_I8:%.*]] = bitcast %swift.type* [[METADATA]] to i8***
// CHECK-32: [[VW_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[METADATA_I8]], i32 -1
// CHECK-64: [[VW_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[METADATA_I8]], i64 -1
// CHECK: [[VW:%.*]] = load i8**, i8*** [[VW_ADDR]]
// CHECK: [[PROJECT_ADDR:%.*]] = getelementptr inbounds i8*, i8** [[VW]], i32 2
// CHECK-32: [[PROJECT_PTR:%.*]] = load i8*, i8** [[PROJECT_ADDR]], align 4
// CHECK-64: [[PROJECT_PTR:%.*]] = load i8*, i8** [[PROJECT_ADDR]], align 8
// CHECK-32: [[PROJECT:%.*]] = bitcast i8* [[PROJECT_PTR]] to %swift.opaque* ([12 x i8]*, %swift.type*)*
// CHECK-64: [[PROJECT:%.*]] = bitcast i8* [[PROJECT_PTR]] to %swift.opaque* ([24 x i8]*, %swift.type*)*
// CHECK-32: [[PROJECTION:%.*]] = call %swift.opaque* [[PROJECT]]([12 x i8]* [[BUFFER]], %swift.type* [[METADATA]])
// CHECK-64: [[PROJECTION:%.*]] = call %swift.opaque* [[PROJECT]]([24 x i8]* [[BUFFER]], %swift.type* [[METADATA]])
// CHECK: [[METATYPE:%.*]] = call %swift.type* @swift_getDynamicType(%swift.opaque* [[PROJECTION]], %swift.type* [[METADATA]], i1 true)
// CHECK: [[T0:%.*]] = getelementptr inbounds %T17generic_metatypes3BasP, %T17generic_metatypes3BasP* [[X]], i32 0, i32 2
// CHECK-32: [[WTABLE:%.*]] = load i8**, i8*** [[T0]], align 4
// CHECK-64: [[WTABLE:%.*]] = load i8**, i8*** [[T0]], align 8
// CHECK: [[VALUE_ADDR:%.*]] = call %swift.opaque* @__swift_project_boxed_opaque_existential_1({{.*}} [[BUFFER]], %swift.type* [[METADATA]])
// CHECK: [[METATYPE:%.*]] = call %swift.type* @swift_getDynamicType(%swift.opaque* [[VALUE_ADDR]], %swift.type* [[METADATA]], i1 true)
// CHECK: [[WTABLE_ADDR:%.*]] = getelementptr inbounds %T17generic_metatypes3BasP, %T17generic_metatypes3BasP* %0, i32 0, i32 2
// CHECK: [[WTABLE:%.*]] = load i8**, i8*** [[WTABLE_ADDR]]
// CHECK: call void @__swift_destroy_boxed_opaque_existential_1(%T17generic_metatypes3BasP* %0)
// CHECK: [[T0:%.*]] = insertvalue { %swift.type*, i8** } undef, %swift.type* [[METATYPE]], 0
// CHECK: [[T1:%.*]] = insertvalue { %swift.type*, i8** } [[T0]], i8** [[WTABLE]], 1
// CHECK: ret { %swift.type*, i8** } [[T1]]
Expand Down
20 changes: 5 additions & 15 deletions test/IRGen/generic_metatypes_arm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,11 @@ func protocolTypeof(_ x: Bas) -> Bas.Type {
// CHECK: [[METADATA_ADDR:%.*]] = getelementptr inbounds %T17generic_metatypes3BasP, %T17generic_metatypes3BasP* [[X:%.*]], i32 0, i32 1
// CHECK: [[METADATA:%.*]] = load %swift.type*, %swift.type** [[METADATA_ADDR]]
// CHECK: [[BUFFER:%.*]] = getelementptr inbounds %T17generic_metatypes3BasP, %T17generic_metatypes3BasP* [[X]], i32 0, i32 0
// CHECK: [[METADATA_I8:%.*]] = bitcast %swift.type* [[METADATA]] to i8***
// CHECK-32: [[VW_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[METADATA_I8]], i32 -1
// CHECK-64: [[VW_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[METADATA_I8]], i64 -1
// CHECK: [[VW:%.*]] = load i8**, i8*** [[VW_ADDR]]
// CHECK: [[PROJECT_ADDR:%.*]] = getelementptr inbounds i8*, i8** [[VW]], i32 2
// CHECK-32: [[PROJECT_PTR:%.*]] = load i8*, i8** [[PROJECT_ADDR]], align 4
// CHECK-64: [[PROJECT_PTR:%.*]] = load i8*, i8** [[PROJECT_ADDR]], align 8
// CHECK-32: [[PROJECT:%.*]] = bitcast i8* [[PROJECT_PTR]] to %swift.opaque* ([12 x i8]*, %swift.type*)*
// CHECK-64: [[PROJECT:%.*]] = bitcast i8* [[PROJECT_PTR]] to %swift.opaque* ([24 x i8]*, %swift.type*)*
// CHECK-32: [[PROJECTION:%.*]] = call %swift.opaque* [[PROJECT]]([12 x i8]* [[BUFFER]], %swift.type* [[METADATA]])
// CHECK-64: [[PROJECTION:%.*]] = call %swift.opaque* [[PROJECT]]([24 x i8]* [[BUFFER]], %swift.type* [[METADATA]])
// CHECK: [[METATYPE:%.*]] = call %swift.type* @swift_getDynamicType(%swift.opaque* [[PROJECTION]], %swift.type* [[METADATA]], i1 true)
// CHECK: [[T0:%.*]] = getelementptr inbounds %T17generic_metatypes3BasP, %T17generic_metatypes3BasP* [[X]], i32 0, i32 2
// CHECK-32: [[WTABLE:%.*]] = load i8**, i8*** [[T0]], align 4
// CHECK-64: [[WTABLE:%.*]] = load i8**, i8*** [[T0]], align 8
// CHECK: [[VALUE_ADDR:%.*]] = call %swift.opaque* @__swift_project_boxed_opaque_existential_1({{.*}} [[BUFFER]], %swift.type* [[METADATA]])
// CHECK: [[METATYPE:%.*]] = call %swift.type* @swift_getDynamicType(%swift.opaque* [[VALUE_ADDR]], %swift.type* [[METADATA]], i1 true)
// CHECK: [[WTABLE_ADDR:%.*]] = getelementptr inbounds %T17generic_metatypes3BasP, %T17generic_metatypes3BasP* %0, i32 0, i32 2
// CHECK: [[WTABLE:%.*]] = load i8**, i8*** [[WTABLE_ADDR]]
// CHECK: call void @__swift_destroy_boxed_opaque_existential_1(%T17generic_metatypes3BasP* %0)
// CHECK: [[T0:%.*]] = insertvalue { %swift.type*, i8** } undef, %swift.type* [[METATYPE]], 0
// CHECK: [[T1:%.*]] = insertvalue { %swift.type*, i8** } [[T0]], i8** [[WTABLE]], 1
// CHECK: ret { %swift.type*, i8** } [[T1]]
Expand Down
68 changes: 55 additions & 13 deletions test/IRGen/global_resilience.sil
Original file line number Diff line number Diff line change
Expand Up @@ -103,27 +103,69 @@ bb0:
return %tuple : $()
}

// CHECK-LABEL: define {{.*}} @testOtherGlobal
sil @testOtherGlobal : $@convention(thin) () -> () {
bb0:
// CHECK: [[METADATA:%.*]] = call %swift.type* @_T016resilient_struct4SizeVMa()
// CHECK: call %swift.opaque* @__swift_allocate_value_buffer(%swift.type* %0, %swift.opaque* bitcast ([{{.*}} x i8]* @otherGlobal to %swift.opaque*))
alloc_global @otherGlobal

// CHECK: [[METADATA_ADDR:%.*]] = bitcast %swift.type* [[METADATA]] to i8***
// CHECK: [[VWT_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[METADATA_ADDR]], [[INT]] -1
// CHECK: [[VWT:%.*]] = load i8**, i8*** [[VWT_ADDR]]
// CHECK: [[WITNESS_PTR:%.*]] = getelementptr inbounds i8*, i8** [[VWT]], i32 11
// CHECK: [[WITNESS:%.*]] = load i8*, i8** [[WITNESS_PTR]]
// CHECK: [[allocateBuffer:%.*]] = bitcast i8* [[WITNESS]] to %swift.opaque* ([[BUFFER]]*, %swift.type*)*
// CHECK: [[VALUE:%.*]] = call %swift.opaque* [[allocateBuffer]]([[BUFFER]]* @otherGlobal, %swift.type* [[METADATA]])
alloc_global @otherGlobal

// CHECK: [[WITNESS_PTR:%.*]] = getelementptr inbounds i8*, i8** [[VWT]], i32 2
// CHECK: [[WITNESS:%.*]] = load i8*, i8** [[WITNESS_PTR]]
// CHECK: [[projectBuffer:%.*]] = bitcast i8* [[WITNESS]] to %swift.opaque* ([[BUFFER]]*, %swift.type*)*
// CHECK: [[VALUE:%.*]] = call %swift.opaque* [[projectBuffer]]([[BUFFER]]* @otherGlobal, %swift.type* [[METADATA]])
// CHECK: call %swift.opaque* @__swift_project_value_buffer(%swift.type* %0, %swift.opaque* bitcast ([{{.*}} x i8]* @otherGlobal to %swift.opaque*))
%addr = global_addr @otherGlobal : $*Size

%tuple = tuple ()

// CHECK: ret void
return %tuple : $()
}

// CHECK-LABEL: define linkonce_odr hidden %swift.opaque* @__swift_allocate_value_buffer(%swift.type*, %swift.opaque*)
// CHECK: entry:
// CHECK: [[CAST:%.*]] = bitcast %swift.type* %0 to i8***
// CHECK: [[VWT_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[CAST]], {{.*}} -1
// CHECK: [[VWT:%.*]] = load i8**, i8*** [[VWT_ADDR]]
// CHECK: [[FLAGS_ADDR:%.*]] = getelementptr inbounds i8*, i8** %.valueWitnesses, i32 18
// CHECK: [[FLAGSWITNESS:%.*]] = load i8*, i8** [[FLAGS_ADDR]]
// CHECK: [[FLAGS:%.*]] = ptrtoint i8* [[FLAGSWITNESS]] to i{{.*}}
// CHECK: [[ISNOTINLINE:%.*]] = and {{.*}} [[FLAGS]], 131072
// CHECK: [[ISINLINE:%.*]] = icmp eq {{.*}} [[ISNOTINLINE]], 0
// CHECK: br i1 [[ISINLINE]], label %done, label %outline.allocateValueInBuffer
//
// CHECK: outline.allocateValueInBuffer:
// CHECK: [[CAST:%.*]] = bitcast %swift.type* %0 to i8***
// CHECK: [[VWT_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[CAST]], {{.*}} -1
// CHECK: [[VWT:%.*]] = load i8**, i8*** [[VWT_ADDR]]
// CHECK: [[SIZE_ADDR:%.*]] = getelementptr inbounds i8*, i8** [[VWT]], i32 17
// CHECK: [[SIZEWITNESS:%.*]] = load i8*, i8** [[SIZE_ADDR]]
// CHECK: [[SIZE:%.*]] = ptrtoint i8* [[SIZEWITNESS]]
// CHECK: [[ALIGN:%.*]] = and {{.*}} [[FLAGS]], 65535
// CHECK: [[PTR:%.*]] = call noalias i8* @swift_rt_swift_slowAlloc({{.*}} [[SIZE]], {{.*}} [[ALIGN]])
// CHECK: [[ADDR:%.*]] = bitcast %swift.opaque* %1 to i8**
// CHECK: store i8* [[PTR]], i8** [[ADDR]]
// CHECK: [[OUTLINEADDR:%.*]] = bitcast i8* [[PTR]] to %swift.opaque*
// CHECK: br label %done
//
// CHECK: done:
// CHECK: [[PHI:%.*]] = phi %swift.opaque* [ %1, %entry ], [ [[OUTLINEADDR]], %outline.allocateValueInBuffer ]
// CHECK: ret %swift.opaque* [[PHI]]


// CHECK-LABEL: define linkonce_odr hidden %swift.opaque* @__swift_project_value_buffer(%swift.type*, %swift.opaque*)
// CHECK: [[CAST:%.*]] = bitcast %swift.type* %0 to i8***
// CHECK: [[VWT_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[CAST]], {{.*}} -1
// CHECK: [[VWT:%.*]] = load i8**, i8*** [[VWT_ADDR]]
// CHECK: [[FLAGS_ADDR:%.*]] = getelementptr inbounds i8*, i8** %.valueWitnesses, i32 18
// CHECK: [[FLAGSWITNESS:%.*]] = load i8*, i8** [[FLAGS_ADDR]]
// CHECK: [[FLAGS:%.*]] = ptrtoint i8* [[FLAGSWITNESS]] to i{{.*}}
// CHECK: [[ISNOTINLINE:%.*]] = and {{.*}} [[FLAGS]], 131072
// CHECK: [[ISINLINE:%.*]] = icmp eq {{.*}} [[ISNOTINLINE]], 0
// CHECK: br i1 [[ISINLINE]], label %done, label %outline.projectValueInBuffer
//
// CHECK: outline.projectValueInBuffer:
// CHECK: [[CAST:%.*]] = bitcast %swift.opaque* %1 to %swift.opaque**
// CHECK: [[PTR_TO_BUFFER:%.*]] = load %swift.opaque*, %swift.opaque** [[CAST]]
// CHECK: br label %done
//
// CHECK: done:
// CHECK: [[PHI:%.*]] = phi %swift.opaque* [ %1, %entry ], [ [[PTR_TO_BUFFER]], %outline.projectValueInBuffer ]
// CHECK: ret %swift.opaque* [[PHI]]
8 changes: 4 additions & 4 deletions test/IRGen/witness_table_multifile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
// CHECK-LABEL: define hidden swiftcc void @_T023witness_table_multifile3baryyF
func bar() {
// CHECK: call swiftcc void @_T023witness_table_multifile2goAA1P_pyF
// CHECK: [[BUFFER:%[0-9]+]] = call %swift.opaque* %projectBuffer
// CHECK-NEXT: [[WITNESS_TABLE_ADDR:%[0-9]+]] = getelementptr inbounds [[P_WITNESS_TABLE]], [[P_WITNESS_TABLE]]* %0, i32 0, i32 2
// CHECK-NEXT: [[WITNESS_TABLE:%[A-Za-z0-9_-]+]] = load i8**, i8*** [[WITNESS_TABLE_ADDR]]
// CHECK: [[WITNESS_TABLE_ADDR:%[0-9]+]] = getelementptr inbounds [[P_WITNESS_TABLE]], [[P_WITNESS_TABLE]]* %0, i32 0, i32 2
// CHECK: [[WITNESS_TABLE:%[A-Za-z0-9_-]+]] = load i8**, i8*** [[WITNESS_TABLE_ADDR]]
// CHECK: [[BUFFER:%[0-9]+]] = call %swift.opaque* @__swift_project_boxed_opaque_existential_1
// CHECK-NEXT: getelementptr inbounds i8*, i8** [[WITNESS_TABLE]], i32 3
go().foo()
}
Expand All @@ -16,4 +16,4 @@ func bar() {
// when they're only used as types.
func useAProtocol() -> ProtocolOnlyUsedAsAType? {
return nil
}
}
2 changes: 1 addition & 1 deletion test/SILGen/address_only_types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func address_only_materialize() -> Int {
// CHECK: [[TEMP_PROJ:%[0-9]+]] = open_existential_addr immutable_access [[TEMP]] : $*Unloadable to $*[[OPENED:@opened(.*) Unloadable]]
// CHECK: [[FOO_METHOD:%[0-9]+]] = witness_method $[[OPENED]], #Unloadable.foo!1
// CHECK: [[RET:%[0-9]+]] = apply [[FOO_METHOD]]<[[OPENED]]>([[TEMP_PROJ]])
// CHECK: destroy_addr [[TEMP_PROJ]]
// CHECK: destroy_addr [[TEMP]]
// CHECK: dealloc_stack [[TEMP]]
// CHECK: return [[RET]]
}
Expand Down
6 changes: 3 additions & 3 deletions test/SILGen/existential_erasure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ func throwingFunc() throws -> Bool { return true }
func PQtoP() {
// CHECK: [[PQ_PAYLOAD:%.*]] = open_existential_addr immutable_access [[PQ:%.*]] : $*P & Q to $*[[OPENED_TYPE:@opened(.*) P & Q]]
// CHECK: [[P_PAYLOAD:%.*]] = init_existential_addr [[P:%.*]] : $*P, $[[OPENED_TYPE]]
// CHECK: copy_addr [take] [[PQ_PAYLOAD]] to [initialization] [[P_PAYLOAD]]
// CHECK: deinit_existential_addr [[PQ]]
// CHECK: copy_addr [[PQ_PAYLOAD]] to [initialization] [[P_PAYLOAD]]
// CHECK: destroy_addr [[PQ]]
// CHECK-NOT: destroy_addr [[P]]
// CHECK-NOT: destroy_addr [[P_PAYLOAD]]
// CHECK-NOT: destroy_addr [[PQ]]
// CHECK-NOT: deinit_existential_addr [[PQ]]
// CHECK-NOT: destroy_addr [[PQ_PAYLOAD]]
useP(makePQ())
}
Expand Down
4 changes: 2 additions & 2 deletions test/SILGen/function_conversion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ func convExistentialTrivial(_ t2: @escaping (Q) -> Trivial, t3: @escaping (Q?) -
// CHECK: alloc_stack $Q
// CHECK-NEXT: open_existential_addr immutable_access %1 : $*P
// CHECK-NEXT: init_existential_addr %3 : $*Q
// CHECK-NEXT: copy_addr [take] {{.*}} to [initialization] {{.*}}
// CHECK-NEXT: copy_addr {{.*}} to [initialization] {{.*}}
// CHECK-NEXT: apply
// CHECK-NEXT: init_existential_addr
// CHECK-NEXT: store
// CHECK: deinit_existential_addr
// CHECK: destroy_addr
// CHECK: return

// ==== Existential metatypes
Expand Down
3 changes: 1 addition & 2 deletions test/SILGen/functions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ func calls(_ i:Int, j:Int, k:Int) {
// CHECK: [[PMETHOD:%[0-9]+]] = witness_method $[[OPENED]], #SomeProtocol.method!1
// CHECK: [[I:%[0-9]+]] = load [trivial] [[IADDR]]
// CHECK: apply [[PMETHOD]]<[[OPENED]]>([[I]], [[PVALUE]])
// CHECK: destroy_addr [[PVALUE]]
// CHECK: deinit_existential_addr [[TEMP]]
// CHECK: destroy_addr [[TEMP]]
// CHECK: dealloc_stack [[TEMP]]
p.method(i)

Expand Down
Loading

0 comments on commit 343193f

Please sign in to comment.