Skip to content

Commit 22349bc

Browse files
committed
Use intptr_t instead of ssize_t and more test fixes
1 parent 96bfaaf commit 22349bc

File tree

5 files changed

+25
-10
lines changed

5 files changed

+25
-10
lines changed

include/swift/Runtime/Metadata.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ SWIFT_RUNTIME_EXPORT
10591059
void swift_initRawStructMetadata(StructMetadata *self,
10601060
StructLayoutFlags structLayoutFlags,
10611061
const TypeLayout *likeType,
1062-
ssize_t count,
1062+
intptr_t count,
10631063
RawLayoutFlags rawLayoutFlags);
10641064

10651065
/// Check if the given generic arguments are valid inputs for the generic type

include/swift/Runtime/RuntimeFunctions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2825,7 +2825,7 @@ FUNCTION(GenericInstantiateLayoutString,
28252825
// void swift_initRawStructMetadata(Metadata *structType,
28262826
// StructLayoutFlags structLayoutFlags,
28272827
// const TypeLayout *likeType,
2828-
// ssize_t count,
2828+
// intptr_t count,
28292829
// RawLayoutFlags rawLayoutFlags);
28302830
FUNCTION(InitRawStructMetadata,
28312831
swift_initRawStructMetadata,

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5682,7 +5682,7 @@ GenericTypeParamDecl *GenericTypeParamDecl::create(
56825682

56835683
auto numTypeReprs = 0;
56845684

5685-
if (opaqueTypeRepr)
5685+
if (isOpaqueType)
56865686
numTypeReprs = 1;
56875687

56885688
auto numSourceLocs = 0;

stdlib/public/runtime/Metadata.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3030,7 +3030,7 @@ SWIFT_RUNTIME_EXPORT
30303030
void swift::swift_initRawStructMetadata(StructMetadata *structType,
30313031
StructLayoutFlags structLayoutFlags,
30323032
const TypeLayout *likeTypeLayout,
3033-
ssize_t count,
3033+
intptr_t count,
30343034
RawLayoutFlags rawLayoutFlags) {
30353035
auto vwtable = getMutableVWTableForInit(structType, structLayoutFlags);
30363036

@@ -3042,21 +3042,36 @@ void swift::swift_initRawStructMetadata(StructMetadata *structType,
30423042
auto extraInhabitantCount = likeTypeLayout->extraInhabitantCount;
30433043

30443044
if (isRawLayoutArray(rawLayoutFlags)) {
3045-
stride *= std::min(count, (ssize_t)0);
3045+
// Our count value may be negative, so use 0 if that's the case.
3046+
stride *= std::max(count, (intptr_t)0);
30463047
size = stride;
30473048
}
30483049

30493050
vwtable->size = size;
30503051
vwtable->stride = stride;
30513052
vwtable->flags = ValueWitnessFlags()
30523053
.withAlignmentMask(alignMask)
3053-
.withCopyable(false);
3054+
.withCopyable(false)
3055+
.withBitwiseTakable(true); // All raw layouts are assumed
3056+
// to be bitwise takable unless
3057+
// movesAsLike is present.
30543058
vwtable->extraInhabitantCount = extraInhabitantCount;
30553059

30563060
if (shouldRawLayoutMoveAsLike(rawLayoutFlags)) {
30573061
vwtable->flags = vwtable->flags
3058-
.withBitwiseTakable(likeTypeLayout->flags.isBitwiseTakable())
3062+
.withBitwiseTakable(likeTypeLayout->flags.isBitwiseTakable());
3063+
}
3064+
3065+
// If the calculated size of this raw layout type is available to be put in
3066+
// value buffers, then set the inline storage bit if our like type is also
3067+
// able to be put into inline storage.
3068+
if (size <= NumWords_ValueBuffer) {
3069+
vwtable->flags = vwtable->flags
30593070
.withInlineStorage(likeTypeLayout->flags.isInlineStorage());
3071+
} else {
3072+
// Otherwise, we're too big to fit in inline storage regardless of the like
3073+
// type's ability to be put in inline storage.
3074+
vwtable->flags = vwtable->flags.withInlineStorage(false);
30603075
}
30613076
}
30623077

test/IRGen/raw_layout.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ entry(%0 : $*Cell<T>):
428428

429429
// CHECK-LABEL: define {{.*}} void @"$s10raw_layout18ConcreteMoveAsLikeVwxx"(ptr {{.*}} %object, ptr %ConcreteMoveAsLike)
430430
// CHECK: [[OBJ_CELL:%.*]] = getelementptr inbounds %T10raw_layout18ConcreteMoveAsLikeV, ptr %object, i32 0, i32 0
431-
// CHECK: {{invoke void|invoke ptr|call ptr}} @{{.*}}(ptr [[OBJ_CELL]])
431+
// CHECK: {{invoke void|invoke ptr|call void}} @{{.*}}(ptr [[OBJ_CELL]])
432432

433433
//===----------------------------------------------------------------------===//
434434
// ConcreteMoveAsLike initializeWithTake
@@ -555,7 +555,7 @@ entry(%0 : $*Cell<T>):
555555
// CHECK: [[NEW_I:%.*]] = add {{i64|i32}} [[I]], 1
556556
// CHECK: store {{i64|i32}} [[NEW_I]], ptr [[I_ALLOCA]]
557557
// CHECK: [[OBJECT:%.*]] = getelementptr inbounds %TSo24NonBitwiseTakableCXXTypeV, ptr [[OBJ_VECTOR]], {{i64|i32}} [[I]]
558-
// CHECK-NEXT: {{invoke void|invoke ptr|call ptr}} @{{.*}}(ptr [[OBJECT]])
558+
// CHECK-NEXT: {{invoke void|invoke ptr|call void}} @{{.*}}(ptr [[OBJECT]])
559559

560560
// This may or may not be in the loop_br
561561
// CHECK: [[EQ_CMP:%.*]] = icmp eq {{i64|i32}} [[NEW_I]], 2
@@ -747,7 +747,7 @@ entry(%0 : $*Cell<T>):
747747
// CHECK: [[NEW_I:%.*]] = add {{i64|i32}} [[I]], 1
748748
// CHECK: store {{i64|i32}} [[NEW_I]], ptr [[I_ALLOCA]]
749749
// CHECK: [[OBJECT:%.*]] = getelementptr inbounds %TSo24NonBitwiseTakableCXXTypeV, ptr [[OBJ_VECTOR]], {{i64|i32}} [[I]]
750-
// CHECK-NEXT: {{invoke void|invoke ptr|call ptr}} @{{.*}}(ptr [[OBJECT]])
750+
// CHECK-NEXT: {{invoke void|invoke ptr|call void}} @{{.*}}(ptr [[OBJECT]])
751751

752752
// This may or may not be in the loop_br
753753
// CHECK: [[EQ_CMP:%.*]] = icmp eq {{i64|i32}} [[NEW_I]], 4

0 commit comments

Comments
 (0)