Skip to content

Commit cb2a766

Browse files
committed
Handle existential_metatype in moveonlytype eliminator
1 parent 11696cd commit cb2a766

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/SILOptimizer/Mandatory/MoveOnlyWrappedTypeEliminator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ struct SILMoveOnlyWrappedTypeEliminatorVisitor
198198
NO_UPDATE_NEEDED(ClassMethod)
199199
NO_UPDATE_NEEDED(FixLifetime)
200200
NO_UPDATE_NEEDED(AddressToPointer)
201+
NO_UPDATE_NEEDED(ExistentialMetatype)
201202
#undef NO_UPDATE_NEEDED
202203

203204
bool eliminateIdentityCast(SingleValueInstruction *svi) {

test/SILOptimizer/moveonly_type_eliminator.sil

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ struct KlassPair {
3636

3737
sil @use_klass : $@convention(thin) (@guaranteed Klass) -> ()
3838

39+
protocol Error {}
40+
3941
///////////
4042
// Tests //
4143
///////////
@@ -599,3 +601,15 @@ bb0(%x : @owned $Klass):
599601
%retval = tuple ()
600602
return %retval : $()
601603
}
604+
605+
// CHECK-LABEL: sil [ossa] @existential_metatype : $@convention(thin) (@guaranteed any Error) -> @thick any Error.Type {
606+
// CHECK: [[EM:%.*]] = existential_metatype $@thick any Error.Type, {{%.*}} : $any Error
607+
// CHECK: return [[EM]] : $@thick any Error.Type
608+
// CHECK-LABEL: } // end sil function 'existential_metatype'
609+
sil [ossa] @existential_metatype : $@convention(thin) (@guaranteed any Error) -> @thick any Error.Type {
610+
bb0(%x : @guaranteed $any Error):
611+
%y = copyable_to_moveonlywrapper [guaranteed] %x : $any Error
612+
%em = existential_metatype $@thick any Error.Type, %y : $@moveOnly (any Error)
613+
debug_value %em : $@thick any Error.Type, var, name "s", argno 1, expr op_deref
614+
return %em : $@thick any Error.Type
615+
}

0 commit comments

Comments
 (0)