Skip to content

Commit 874b577

Browse files
authored
[IRGen] Use EnumImplStrategy to generate getEnumTag function for layo… (#66707)
* [IRGen] Use EnumImplStrategy to generate getEnumTag function for layout strings rdar://110794898 The implementation in TypeLayout seems to have a bug causing wrong tags to be returned on 32 bit systems. * Don't use unsupported types in tests
1 parent 13a29a0 commit 874b577

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

lib/IRGen/TypeLayout.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "FixedTypeInfo.h"
1616
#include "GenOpaque.h"
1717
#include "IRGen.h"
18+
#include "GenEnum.h"
1819
#include "GenExistential.h"
1920
#include "GenericArguments.h"
2021
#include "IRGenFunction.h"
@@ -510,7 +511,8 @@ llvm::Function *createFixedEnumLoadTag(IRGenModule &IGM,
510511
auto castEnumPtr = IGF.Builder.CreateBitCast(enumPtr, enumType);
511512
auto enumAddr = typeInfo->getAddressForPointer(castEnumPtr);
512513

513-
auto tag = entry.getEnumTag(IGF, enumAddr);
514+
auto &strategy = getEnumImplStrategy(IGM, entry.ty);
515+
auto tag = strategy.emitGetEnumTag(IGF, entry.ty, enumAddr);
514516
IGF.Builder.CreateRet(tag);
515517
});
516518

test/Interpreter/Inputs/layout_string_witnesses_types.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ public enum SinglePayloadEnumManyXI {
454454
case empty4
455455
case empty5
456456
case empty6
457-
case nonEmpty(Builtin.Int127, SimpleClass)
457+
case nonEmpty(Builtin.Int63, SimpleClass)
458458
}
459459

460460
public struct PrespecializedStruct<T> {

test/Interpreter/layout_string_witnesses_static.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend -enable-experimental-feature LayoutStringValueWitnesses -enable-layout-string-value-witnesses -enable-type-layout -parse-stdlib -emit-module -emit-module-path=%t/layout_string_witnesses_types.swiftmodule %S/Inputs/layout_string_witnesses_types.swift
2+
// RUN: %target-swift-frontend -enable-experimental-feature LayoutStringValueWitnesses -enable-layout-string-value-witnesses -parse-stdlib -emit-module -emit-module-path=%t/layout_string_witnesses_types.swiftmodule %S/Inputs/layout_string_witnesses_types.swift
33

44
// NOTE: We have to build this as dylib to turn private external symbols into local symbols, so we can observe potential issues with linkage
5-
// RUN: %target-build-swift-dylib(%t/%target-library-name(layout_string_witnesses_types)) -Xfrontend -enable-experimental-feature -Xfrontend LayoutStringValueWitnesses -Xfrontend -enable-layout-string-value-witnesses -Xfrontend -enable-type-layout -Xfrontend -parse-stdlib -parse-as-library %S/Inputs/layout_string_witnesses_types.swift
5+
// RUN: %target-build-swift-dylib(%t/%target-library-name(layout_string_witnesses_types)) -Xfrontend -enable-experimental-feature -Xfrontend LayoutStringValueWitnesses -Xfrontend -enable-layout-string-value-witnesses -Xfrontend -parse-stdlib -parse-as-library %S/Inputs/layout_string_witnesses_types.swift
66
// RUN: %target-codesign %t/%target-library-name(layout_string_witnesses_types)
77
// RUN: %target-swift-frontend -enable-experimental-feature LayoutStringValueWitnesses -enable-layout-string-value-witnesses -enable-library-evolution -emit-module -emit-module-path=%t/layout_string_witnesses_types_resilient.swiftmodule %S/Inputs/layout_string_witnesses_types_resilient.swift
88
// RUN: %target-build-swift -g -Xfrontend -enable-experimental-feature -Xfrontend LayoutStringValueWitnesses -Xfrontend -enable-layout-string-value-witnesses -Xfrontend -enable-library-evolution -c -parse-as-library -o %t/layout_string_witnesses_types_resilient.o %S/Inputs/layout_string_witnesses_types_resilient.swift

0 commit comments

Comments
 (0)