Skip to content

Commit 8139c0e

Browse files
committed
Merge remote-tracking branch 'origin/main' into rebranch
2 parents ac50264 + d141404 commit 8139c0e

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

lib/IRGen/GenEnum.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1699,7 +1699,7 @@ namespace {
16991699
projectedBits = IGF.Builder.CreateElementBitCast(projectedBits, IGM.Int8Ty);
17001700
}
17011701
extraTag = IGF.Builder.CreateLoad(projectedBits);
1702-
auto maskBits = llvm::PowerOf2Ceil(NumExtraTagValues) - 1;
1702+
auto maskBits = (1 << ExtraTagBitCount) - 1;
17031703
auto mask = llvm::ConstantInt::get(extraTag->getType(), maskBits);
17041704
extraTag = IGF.Builder.CreateAnd(extraTag, mask);
17051705
} else {

test/Interpreter/Inputs/layout_string_witnesses_types.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,38 @@ public enum TwoPayloadOuter {
629629
case y(TwoPayloadInner)
630630
}
631631

632+
public enum OneExtraTagValue {
633+
public enum E0 {
634+
case a(Bool)
635+
case b(Bool)
636+
}
637+
638+
public enum E1 {
639+
case a(E0)
640+
case b(Bool)
641+
}
642+
public enum E2 {
643+
case a(E1)
644+
case b(Bool)
645+
}
646+
public enum E3 {
647+
case a(E2)
648+
case b(Bool)
649+
}
650+
651+
public enum E4 {
652+
case a(E3)
653+
case b(Bool)
654+
}
655+
656+
case x0(E4, Int8, Int16, Int32)
657+
case x1(E4, Int8, Int16, Int32)
658+
case x2(E4, Int8, Int16, Int32)
659+
case x3(E4, Int8, Int16, Int32)
660+
case y(SimpleClass)
661+
case z
662+
}
663+
632664
@inline(never)
633665
public func consume<T>(_ x: T.Type) {
634666
withExtendedLifetime(x) {}

test/Interpreter/layout_string_witnesses_static.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,35 @@ func testNestedTwoPayload() {
13191319

13201320
testNestedTwoPayload()
13211321

1322+
func testMultiPayloadOneExtraTagValue() {
1323+
let ptr = UnsafeMutablePointer<OneExtraTagValue>.allocate(capacity: 1)
1324+
1325+
do {
1326+
let x = OneExtraTagValue.y(SimpleClass(x: 23))
1327+
testInit(ptr, to: x)
1328+
}
1329+
1330+
do {
1331+
let y = OneExtraTagValue.y(SimpleClass(x: 1))
1332+
1333+
// CHECK: Before deinit
1334+
print("Before deinit")
1335+
1336+
// CHECK-NEXT: SimpleClass deinitialized!
1337+
testAssign(ptr, from: y)
1338+
}
1339+
1340+
// CHECK-NEXT: Before deinit
1341+
print("Before deinit")
1342+
1343+
// CHECK-NEXT: SimpleClass deinitialized!
1344+
testDestroy(ptr)
1345+
1346+
ptr.deallocate()
1347+
}
1348+
1349+
testMultiPayloadOneExtraTagValue()
1350+
13221351
#if os(macOS)
13231352
func testObjc() {
13241353
let ptr = UnsafeMutablePointer<ObjcWrapper>.allocate(capacity: 1)

0 commit comments

Comments
 (0)