Skip to content

Commit 6899f34

Browse files
authored
Merge pull request #3948 from swiftwasm/main
2 parents ea54e38 + 451b902 commit 6899f34

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,11 @@ SILInstruction *SILCombiner::visitAllocStackInst(AllocStackInst *AS) {
654654
continue;
655655
}
656656

657+
if (isa<DeinitExistentialAddrInst>(Op->getUser())) {
658+
eraseInstFromFunction(*Op->getUser());
659+
continue;
660+
}
661+
657662
if (!isa<DeallocStackInst>(Op->getUser()))
658663
continue;
659664

test/SILOptimizer/sil_combine_concrete_existential.sil

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,35 @@ bb0(%0 : $ResourceKitProtocol, %1 : $ViewController):
692692
return %19 : $()
693693
}
694694

695+
sil @calleWhichThrows : $@convention(thin) () -> (@out S, @error Error)
696+
697+
// CHECK-LABEL: sil @initExistentialWithDeinitExistential
698+
// CHECK: [[S:%[0-9]+]] = alloc_stack $S
699+
// CHECK-NOT: init_existential_addr
700+
// CHECK: try_apply %{{[0-9]+}}([[S]])
701+
// CHECK: destroy_addr [[S]] : $*S
702+
// CHECK: dealloc_stack [[S]] : $*S
703+
// CHECK: } // end sil function 'initExistentialWithDeinitExistential'
704+
sil @initExistentialWithDeinitExistential : $@convention(thin) () -> @error Error {
705+
bb0:
706+
%4 = alloc_stack $PPP
707+
%5 = function_ref @calleWhichThrows : $@convention(thin) () -> (@out S, @error Error)
708+
%6 = init_existential_addr %4 : $*PPP, $S
709+
try_apply %5(%6) : $@convention(thin) () -> (@out S, @error Error), normal bb1, error bb3
710+
711+
bb1(%8 : $()):
712+
destroy_addr %4 : $*PPP
713+
dealloc_stack %4 : $*PPP
714+
%18 = tuple ()
715+
return %18 : $()
716+
717+
718+
bb3(%20 : $Error):
719+
deinit_existential_addr %4 : $*PPP
720+
dealloc_stack %4 : $*PPP
721+
throw %20 : $Error
722+
}
723+
695724
sil_vtable SubscriptionViewControllerBuilder {}
696725
sil_vtable SubscriptionViewController {}
697726
sil_vtable ViewController {}

utils/gyb_syntax_support/protocolsMap.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
SYNTAX_BUILDABLE_EXPRESSIBLE_AS_CONFORMANCES = {
2+
'AccessorList': [
3+
'AccessorBlock'
4+
],
5+
'CodeBlockItemList': [
6+
'CodeBlock'
7+
],
28
'DeclBuildable': [
39
'CodeBlockItem',
410
'MemberDeclListItem',
@@ -14,6 +20,15 @@
1420
'MemberDeclList': [
1521
'MemberDeclBlock'
1622
],
23+
'FunctionCallExpr': [
24+
'CodeBlockItem',
25+
'ExprBuildable'
26+
],
27+
'SequenceExpr': [
28+
'CodeBlockItem',
29+
'ExprBuildable',
30+
'TupleExprElement'
31+
],
1732
'SimpleTypeIdentifier': [
1833
'TypeAnnotation',
1934
'TypeBuildable',
@@ -24,6 +39,7 @@
2439
'SyntaxBuildable'
2540
],
2641
'TokenSyntax': [
27-
'BinaryOperatorExpr'
42+
'BinaryOperatorExpr',
43+
'DeclModifier'
2844
]
2945
}

0 commit comments

Comments
 (0)