Skip to content

[6.0][IRGen] Fix emitPrimitiveLoadPayloadAndExtraTag for CVW #75271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/IRGen/GenEnum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,7 @@ namespace {
// In CVW we have to mask the extra bits, which requires us to make
// this cast here, otherwise LLVM would optimize away the bit mask.
if (projectedBits.getElementType()->getIntegerBitWidth() < 8) {
projectedBits = IGF.Builder.CreateElementBitCast(addr, IGM.Int8Ty);
projectedBits = IGF.Builder.CreateElementBitCast(projectedBits, IGM.Int8Ty);
}
extraTag = IGF.Builder.CreateLoad(projectedBits);
auto maskBits = llvm::PowerOf2Ceil(NumExtraTagValues) - 1;
Expand Down
4 changes: 2 additions & 2 deletions test/Interpreter/Inputs/layout_string_witnesses_types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@ public enum MultiPayloadError {
}

public enum TwoPayloadInner {
case x(AnyObject)
case y(Int)
case x(Int)
case y(AnyObject)
}

public enum TwoPayloadOuter {
Expand Down
4 changes: 2 additions & 2 deletions test/Interpreter/layout_string_witnesses_static.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1294,12 +1294,12 @@ func testNestedTwoPayload() {
let ptr = UnsafeMutablePointer<TwoPayloadOuter>.allocate(capacity: 1)

do {
let x = TwoPayloadOuter.y(TwoPayloadInner.x(SimpleClass(x: 23)))
let x = TwoPayloadOuter.y(TwoPayloadInner.y(SimpleClass(x: 23)))
testInit(ptr, to: x)
}

do {
let y = TwoPayloadOuter.y(TwoPayloadInner.x(SimpleClass(x: 1)))
let y = TwoPayloadOuter.y(TwoPayloadInner.y(SimpleClass(x: 1)))

// CHECK: Before deinit
print("Before deinit")
Expand Down