Skip to content

Commit 2bb33ac

Browse files
committed
[IRGen] Fix emitPrimitiveLoadPayloadAndExtraTag for CVW
rdar://131798355 When casting the projectedBits to Int8, we accidetnally passed the base addr instead of the projectedBits. This was causing the wrong bits to be read.
1 parent c5a9738 commit 2bb33ac

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

lib/IRGen/GenEnum.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,7 @@ namespace {
16931693
// In CVW we have to mask the extra bits, which requires us to make
16941694
// this cast here, otherwise LLVM would optimize away the bit mask.
16951695
if (projectedBits.getElementType()->getIntegerBitWidth() < 8) {
1696-
projectedBits = IGF.Builder.CreateElementBitCast(addr, IGM.Int8Ty);
1696+
projectedBits = IGF.Builder.CreateElementBitCast(projectedBits, IGM.Int8Ty);
16971697
}
16981698
extraTag = IGF.Builder.CreateLoad(projectedBits);
16991699
auto maskBits = llvm::PowerOf2Ceil(NumExtraTagValues) - 1;

test/Interpreter/Inputs/layout_string_witnesses_types.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,8 @@ public enum MultiPayloadError {
620620
}
621621

622622
public enum TwoPayloadInner {
623-
case x(AnyObject)
624-
case y(Int)
623+
case x(Int)
624+
case y(AnyObject)
625625
}
626626

627627
public enum TwoPayloadOuter {

test/Interpreter/layout_string_witnesses_static.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1294,12 +1294,12 @@ func testNestedTwoPayload() {
12941294
let ptr = UnsafeMutablePointer<TwoPayloadOuter>.allocate(capacity: 1)
12951295

12961296
do {
1297-
let x = TwoPayloadOuter.y(TwoPayloadInner.x(SimpleClass(x: 23)))
1297+
let x = TwoPayloadOuter.y(TwoPayloadInner.y(SimpleClass(x: 23)))
12981298
testInit(ptr, to: x)
12991299
}
13001300

13011301
do {
1302-
let y = TwoPayloadOuter.y(TwoPayloadInner.x(SimpleClass(x: 1)))
1302+
let y = TwoPayloadOuter.y(TwoPayloadInner.y(SimpleClass(x: 1)))
13031303

13041304
// CHECK: Before deinit
13051305
print("Before deinit")

0 commit comments

Comments
 (0)