Use intptr_t instead of ssize_t and more test fixes

This commit is contained in:
Alejandro Alonso
2024-08-09 11:17:03 -07:00
parent 96bfaafb14
commit 22349bcfb9
5 changed files with 25 additions and 10 deletions

View File

@@ -1059,7 +1059,7 @@ SWIFT_RUNTIME_EXPORT
void swift_initRawStructMetadata(StructMetadata *self, void swift_initRawStructMetadata(StructMetadata *self,
StructLayoutFlags structLayoutFlags, StructLayoutFlags structLayoutFlags,
const TypeLayout *likeType, const TypeLayout *likeType,
ssize_t count, intptr_t count,
RawLayoutFlags rawLayoutFlags); RawLayoutFlags rawLayoutFlags);
/// Check if the given generic arguments are valid inputs for the generic type /// Check if the given generic arguments are valid inputs for the generic type

View File

@@ -2825,7 +2825,7 @@ FUNCTION(GenericInstantiateLayoutString,
// void swift_initRawStructMetadata(Metadata *structType, // void swift_initRawStructMetadata(Metadata *structType,
// StructLayoutFlags structLayoutFlags, // StructLayoutFlags structLayoutFlags,
// const TypeLayout *likeType, // const TypeLayout *likeType,
// ssize_t count, // intptr_t count,
// RawLayoutFlags rawLayoutFlags); // RawLayoutFlags rawLayoutFlags);
FUNCTION(InitRawStructMetadata, FUNCTION(InitRawStructMetadata,
swift_initRawStructMetadata, swift_initRawStructMetadata,

View File

@@ -5682,7 +5682,7 @@ GenericTypeParamDecl *GenericTypeParamDecl::create(
auto numTypeReprs = 0; auto numTypeReprs = 0;
if (opaqueTypeRepr) if (isOpaqueType)
numTypeReprs = 1; numTypeReprs = 1;
auto numSourceLocs = 0; auto numSourceLocs = 0;

View File

@@ -3030,7 +3030,7 @@ SWIFT_RUNTIME_EXPORT
void swift::swift_initRawStructMetadata(StructMetadata *structType, void swift::swift_initRawStructMetadata(StructMetadata *structType,
StructLayoutFlags structLayoutFlags, StructLayoutFlags structLayoutFlags,
const TypeLayout *likeTypeLayout, const TypeLayout *likeTypeLayout,
ssize_t count, intptr_t count,
RawLayoutFlags rawLayoutFlags) { RawLayoutFlags rawLayoutFlags) {
auto vwtable = getMutableVWTableForInit(structType, structLayoutFlags); auto vwtable = getMutableVWTableForInit(structType, structLayoutFlags);
@@ -3042,7 +3042,8 @@ void swift::swift_initRawStructMetadata(StructMetadata *structType,
auto extraInhabitantCount = likeTypeLayout->extraInhabitantCount; auto extraInhabitantCount = likeTypeLayout->extraInhabitantCount;
if (isRawLayoutArray(rawLayoutFlags)) { if (isRawLayoutArray(rawLayoutFlags)) {
stride *= std::min(count, (ssize_t)0); // Our count value may be negative, so use 0 if that's the case.
stride *= std::max(count, (intptr_t)0);
size = stride; size = stride;
} }
@@ -3050,13 +3051,27 @@ void swift::swift_initRawStructMetadata(StructMetadata *structType,
vwtable->stride = stride; vwtable->stride = stride;
vwtable->flags = ValueWitnessFlags() vwtable->flags = ValueWitnessFlags()
.withAlignmentMask(alignMask) .withAlignmentMask(alignMask)
.withCopyable(false); .withCopyable(false)
.withBitwiseTakable(true); // All raw layouts are assumed
// to be bitwise takable unless
// movesAsLike is present.
vwtable->extraInhabitantCount = extraInhabitantCount; vwtable->extraInhabitantCount = extraInhabitantCount;
if (shouldRawLayoutMoveAsLike(rawLayoutFlags)) { if (shouldRawLayoutMoveAsLike(rawLayoutFlags)) {
vwtable->flags = vwtable->flags vwtable->flags = vwtable->flags
.withBitwiseTakable(likeTypeLayout->flags.isBitwiseTakable()) .withBitwiseTakable(likeTypeLayout->flags.isBitwiseTakable());
}
// If the calculated size of this raw layout type is available to be put in
// value buffers, then set the inline storage bit if our like type is also
// able to be put into inline storage.
if (size <= NumWords_ValueBuffer) {
vwtable->flags = vwtable->flags
.withInlineStorage(likeTypeLayout->flags.isInlineStorage()); .withInlineStorage(likeTypeLayout->flags.isInlineStorage());
} else {
// Otherwise, we're too big to fit in inline storage regardless of the like
// type's ability to be put in inline storage.
vwtable->flags = vwtable->flags.withInlineStorage(false);
} }
} }

View File

@@ -428,7 +428,7 @@ entry(%0 : $*Cell<T>):
// CHECK-LABEL: define {{.*}} void @"$s10raw_layout18ConcreteMoveAsLikeVwxx"(ptr {{.*}} %object, ptr %ConcreteMoveAsLike) // CHECK-LABEL: define {{.*}} void @"$s10raw_layout18ConcreteMoveAsLikeVwxx"(ptr {{.*}} %object, ptr %ConcreteMoveAsLike)
// CHECK: [[OBJ_CELL:%.*]] = getelementptr inbounds %T10raw_layout18ConcreteMoveAsLikeV, ptr %object, i32 0, i32 0 // CHECK: [[OBJ_CELL:%.*]] = getelementptr inbounds %T10raw_layout18ConcreteMoveAsLikeV, ptr %object, i32 0, i32 0
// CHECK: {{invoke void|invoke ptr|call ptr}} @{{.*}}(ptr [[OBJ_CELL]]) // CHECK: {{invoke void|invoke ptr|call void}} @{{.*}}(ptr [[OBJ_CELL]])
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// ConcreteMoveAsLike initializeWithTake // ConcreteMoveAsLike initializeWithTake
@@ -555,7 +555,7 @@ entry(%0 : $*Cell<T>):
// CHECK: [[NEW_I:%.*]] = add {{i64|i32}} [[I]], 1 // CHECK: [[NEW_I:%.*]] = add {{i64|i32}} [[I]], 1
// CHECK: store {{i64|i32}} [[NEW_I]], ptr [[I_ALLOCA]] // CHECK: store {{i64|i32}} [[NEW_I]], ptr [[I_ALLOCA]]
// CHECK: [[OBJECT:%.*]] = getelementptr inbounds %TSo24NonBitwiseTakableCXXTypeV, ptr [[OBJ_VECTOR]], {{i64|i32}} [[I]] // CHECK: [[OBJECT:%.*]] = getelementptr inbounds %TSo24NonBitwiseTakableCXXTypeV, ptr [[OBJ_VECTOR]], {{i64|i32}} [[I]]
// CHECK-NEXT: {{invoke void|invoke ptr|call ptr}} @{{.*}}(ptr [[OBJECT]]) // CHECK-NEXT: {{invoke void|invoke ptr|call void}} @{{.*}}(ptr [[OBJECT]])
// This may or may not be in the loop_br // This may or may not be in the loop_br
// CHECK: [[EQ_CMP:%.*]] = icmp eq {{i64|i32}} [[NEW_I]], 2 // CHECK: [[EQ_CMP:%.*]] = icmp eq {{i64|i32}} [[NEW_I]], 2
@@ -747,7 +747,7 @@ entry(%0 : $*Cell<T>):
// CHECK: [[NEW_I:%.*]] = add {{i64|i32}} [[I]], 1 // CHECK: [[NEW_I:%.*]] = add {{i64|i32}} [[I]], 1
// CHECK: store {{i64|i32}} [[NEW_I]], ptr [[I_ALLOCA]] // CHECK: store {{i64|i32}} [[NEW_I]], ptr [[I_ALLOCA]]
// CHECK: [[OBJECT:%.*]] = getelementptr inbounds %TSo24NonBitwiseTakableCXXTypeV, ptr [[OBJ_VECTOR]], {{i64|i32}} [[I]] // CHECK: [[OBJECT:%.*]] = getelementptr inbounds %TSo24NonBitwiseTakableCXXTypeV, ptr [[OBJ_VECTOR]], {{i64|i32}} [[I]]
// CHECK-NEXT: {{invoke void|invoke ptr|call ptr}} @{{.*}}(ptr [[OBJECT]]) // CHECK-NEXT: {{invoke void|invoke ptr|call void}} @{{.*}}(ptr [[OBJECT]])
// This may or may not be in the loop_br // This may or may not be in the loop_br
// CHECK: [[EQ_CMP:%.*]] = icmp eq {{i64|i32}} [[NEW_I]], 4 // CHECK: [[EQ_CMP:%.*]] = icmp eq {{i64|i32}} [[NEW_I]], 4