Skip to content

Commit b4c36aa

Browse files
test: Fix test/IRGen/moveonly_value_functions.sil for 32-bit targets
We cannot assume Int is backed by BuiltIn.Int64 and ptr offset is i64. Co-authored-by: Nate Chandler <[email protected]>
1 parent adf1101 commit b4c36aa

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

test/IRGen/moveonly_value_functions.sil

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,31 @@ import Swift
1414
@_alwaysEmitIntoClient @inlinable deinit
1515
}
1616

17-
sil @$sSp12deinitialize5countSvSi_tF : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (Int, UnsafeMutablePointer<τ_0_0>) -> UnsafeMutableRawPointer
17+
struct Int {
18+
var _value: Builtin.Int64
19+
}
20+
sil @deinit_count : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (moveonly_value_functions.Int, UnsafeMutablePointer<τ_0_0>) -> UnsafeMutableRawPointer
1821

1922
// CHECK-LABEL: define{{.*}} @"$s15Synchronization5_CellVAARi_zrlEfD"(
2023
// CHECK-SAME: ptr %"_Cell<Value>",
2124
// CHECK-SAME: ptr noalias swiftself [[SOURCE:%[0-9]+]]
2225
// CHECK-SAME: )
2326
// CHECK-SAME: {
2427
// CHECK: entry:
25-
// CHECK: [[CELL_VWT_ADDR:%[^,]+]] = getelementptr inbounds ptr, ptr %"_Cell<Value>", i64 -1
28+
// CHECK: [[CELL_VWT_ADDR:%[^,]+]] = getelementptr inbounds ptr, ptr %"_Cell<Value>", [[INT]] -1
2629
// CHECK: %"_Cell<Value>.valueWitnesses" = load ptr, ptr [[CELL_VWT_ADDR]]
2730
// CHECK: [[CELL_SIZE_ADDR:%[^,]+]] = getelementptr inbounds %swift.vwtable, ptr %"_Cell<Value>.valueWitnesses", i32 0, i32 8
28-
// CHECK: %size = load i64, ptr [[CELL_SIZE_ADDR]]
29-
// CHECK: [[DEST:%[^,]+]] = alloca i8, i64 %size
31+
// CHECK: %size = load [[INT]], ptr [[CELL_SIZE_ADDR]]
32+
// CHECK: [[DEST:%[^,]+]] = alloca i8, [[INT]] %size
3033
// CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr [[DEST]])
31-
// CHECK: [[VALUE_METADATA_ADDR:%[^,]+]] = getelementptr inbounds ptr, ptr %"_Cell<Value>", i64 2
34+
// CHECK: [[VALUE_METADATA_ADDR:%[^,]+]] = getelementptr inbounds ptr, ptr %"_Cell<Value>", [[INT]] 2
3235
// CHECK: %Value = load ptr, ptr [[VALUE_METADATA_ADDR]]
33-
// CHECK: [[VALUE_VWT_ADDR:%[^,]+]] = getelementptr inbounds ptr, ptr %Value, i64 -1
36+
// CHECK: [[VALUE_VWT_ADDR:%[^,]+]] = getelementptr inbounds ptr, ptr %Value, [[INT]] -1
3437
// CHECK: %Value.valueWitnesses = load ptr, ptr [[VALUE_VWT_ADDR]]
3538
// CHECK: [[VALUE_INIT_WITH_TAKE_ADDR:%[^,]+]] = getelementptr inbounds ptr, ptr %Value.valueWitnesses, i32 4
3639
// CHECK: %InitializeWithTake = load ptr, ptr [[VALUE_INIT_WITH_TAKE_ADDR]]
3740
// CHECK: call ptr %InitializeWithTake(ptr noalias [[DEST]], ptr noalias [[SOURCE]], ptr %Value)
38-
// CHECK: call swiftcc ptr @"$sSp12deinitialize5countSvSi_tF"(i64 1, ptr [[DEST]], ptr %Value)
41+
// CHECK: call swiftcc ptr @deinit_count(i64 1, ptr [[DEST]], ptr %Value)
3942
// CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr [[DEST]])
4043
// CHECK: }
4144
sil @$s15Synchronization5_CellVAARi_zrlEfD : $@convention(method) <Value where Value : ~Copyable> (@in _Cell<Value>) -> () {
@@ -46,8 +49,8 @@ bb0(%0 : $*_Cell<Value>):
4649
%8 = struct $UnsafeMutablePointer<Value> (%7 : $Builtin.RawPointer)
4750
%9 = integer_literal $Builtin.Int64, 1
4851
%10 = struct $Int (%9 : $Builtin.Int64)
49-
%11 = function_ref @$sSp12deinitialize5countSvSi_tF : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (Int, UnsafeMutablePointer<τ_0_0>) -> UnsafeMutableRawPointer
50-
%12 = apply %11<Value>(%10, %8) : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (Int, UnsafeMutablePointer<τ_0_0>) -> UnsafeMutableRawPointer
52+
%11 = function_ref @deinit_count : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (moveonly_value_functions.Int, UnsafeMutablePointer<τ_0_0>) -> UnsafeMutableRawPointer
53+
%12 = apply %11<Value>(%10, %8) : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (moveonly_value_functions.Int, UnsafeMutablePointer<τ_0_0>) -> UnsafeMutableRawPointer
5154
%13 = tuple ()
5255
dealloc_stack %1 : $*_Cell<Value>
5356
return %13 : $()

0 commit comments

Comments
 (0)