@@ -39,19 +39,15 @@ class FunctionLivenessComputation {
39
39
// / Represents a function which is implementing a vtable or witness table
40
40
// / method.
41
41
struct FuncImpl {
42
- FuncImpl (SILFunction *F, ClassDecl *Cl) : F(F) { Impl. Cl = Cl; }
43
- FuncImpl (SILFunction *F, ProtocolConformance *C) : F(F) { Impl. Conf = C; }
42
+ FuncImpl (SILFunction *F, ClassDecl *Cl) : F(F), Impl(Cl) { }
43
+ FuncImpl (SILFunction *F, ProtocolConformance *C) : F(F), Impl(C) { }
44
44
45
45
// / The implementing function.
46
46
SILFunction *F;
47
47
48
- union {
49
- // / In case of a vtable method.
50
- ClassDecl *Cl;
51
-
52
- // / In case of a witness method.
53
- ProtocolConformance *Conf;
54
- } Impl;
48
+ // / This is a class decl if we are tracking a class_method (i.e. a vtable
49
+ // / method) and a protocol conformance if we are tracking a witness_method.
50
+ PointerUnion<ClassDecl *, ProtocolConformance *> Impl;
55
51
};
56
52
57
53
// / Stores which functions implement a vtable or witness table method.
@@ -303,7 +299,8 @@ class FunctionLivenessComputation {
303
299
304
300
for (FuncImpl &FImpl : mi->implementingFunctions ) {
305
301
if (!isAlive (FImpl.F ) &&
306
- canHaveSameImplementation (FD, MethodCl, FImpl.Impl .Cl )) {
302
+ canHaveSameImplementation (FD, MethodCl,
303
+ FImpl.Impl .get <ClassDecl *>())) {
307
304
makeAlive (FImpl.F );
308
305
} else {
309
306
allImplsAreCalled = false ;
@@ -320,9 +317,10 @@ class FunctionLivenessComputation {
320
317
return ;
321
318
mi->methodIsCalled = true ;
322
319
for (FuncImpl &FImpl : mi->implementingFunctions ) {
323
- if (FImpl.Impl .Conf ) {
324
- SILWitnessTable *WT = Module->lookUpWitnessTable (FImpl.Impl .Conf ,
325
- /* deserializeLazily*/ false );
320
+ if (auto *Conf = FImpl.Impl .dyn_cast <ProtocolConformance *>()) {
321
+ SILWitnessTable *WT =
322
+ Module->lookUpWitnessTable (Conf,
323
+ /* deserializeLazily*/ false );
326
324
if (!WT || isAlive (WT))
327
325
makeAlive (FImpl.F );
328
326
} else {
0 commit comments