Skip to content

Commit 7884892

Browse files
committed
[SIL] Fix alloc_box cloning.
Previously, all the flags were dropped upon cloning.
1 parent 3dbeeba commit 7884892

File tree

2 files changed

+64
-3
lines changed

2 files changed

+64
-3
lines changed

include/swift/SIL/SILCloner.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -970,9 +970,9 @@ SILCloner<ImplClass>::visitAllocBoxInst(AllocBoxInst *Inst) {
970970
Inst,
971971
getBuilder().createAllocBox(
972972
Loc, this->getOpType(Inst->getType()).template castTo<SILBoxType>(),
973-
VarInfo, DoesNotHaveDynamicLifetime,
974-
/*reflection*/ false, DoesNotUseMoveableValueDebugInfo,
975-
/*skipVarDeclAssert*/ true));
973+
VarInfo, Inst->hasDynamicLifetime(), Inst->emitReflectionMetadata(),
974+
Inst->usesMoveableValueDebugInfo(),
975+
/*skipVarDeclAssert*/ true, Inst->hasPointerEscape()));
976976
}
977977

978978
template<typename ImplClass>

test/SIL/cloning.sil

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,67 @@ sil [ossa] @caller_begin_borrow_lexical : $@convention(thin) () -> () {
5252
return %res : $()
5353
}
5454

55+
sil [ossa] [always_inline] @callee_alloc_box : $@convention(thin) () -> () {
56+
%b1 = alloc_box ${ var X }
57+
dealloc_box %b1 : ${ var X }
58+
%b2 = alloc_box [dynamic_lifetime] ${ var X }
59+
dealloc_box %b2 : ${ var X }
60+
%b3 = alloc_box [reflection] ${ var X }
61+
dealloc_box %b3 : ${ var X }
62+
%b4 = alloc_box [pointer_escape] ${ var X }
63+
dealloc_box %b4 : ${ var X }
64+
%b5 = alloc_box [moveable_value_debuginfo] ${ var X }
65+
dealloc_box %b5 : ${ var X }
66+
%b6 = alloc_box [dynamic_lifetime] [reflection] ${ var X }
67+
dealloc_box %b6 : ${ var X }
68+
%b7 = alloc_box [dynamic_lifetime] [pointer_escape] ${ var X }
69+
dealloc_box %b7 : ${ var X }
70+
%b8 = alloc_box [dynamic_lifetime] [moveable_value_debuginfo] ${ var X }
71+
dealloc_box %b8 : ${ var X }
72+
%b9 = alloc_box [reflection] [pointer_escape] ${ var X }
73+
dealloc_box %b9 : ${ var X }
74+
%b10 = alloc_box [reflection] [moveable_value_debuginfo] ${ var X }
75+
dealloc_box %b10 : ${ var X }
76+
%b11 = alloc_box [pointer_escape] [moveable_value_debuginfo] ${ var X }
77+
dealloc_box %b11 : ${ var X }
78+
%b12 = alloc_box [reflection] [pointer_escape] [moveable_value_debuginfo] ${ var X }
79+
dealloc_box %b12 : ${ var X }
80+
%b13 = alloc_box [dynamic_lifetime] [pointer_escape] [moveable_value_debuginfo] ${ var X }
81+
dealloc_box %b13 : ${ var X }
82+
%b14 = alloc_box [dynamic_lifetime] [reflection] [moveable_value_debuginfo] ${ var X }
83+
dealloc_box %b14 : ${ var X }
84+
%b15 = alloc_box [dynamic_lifetime] [reflection] [pointer_escape] ${ var X }
85+
dealloc_box %b15 : ${ var X }
86+
%b16 = alloc_box [dynamic_lifetime] [reflection] [pointer_escape] [moveable_value_debuginfo] ${ var X }
87+
dealloc_box %b16 : ${ var X }
88+
%res = tuple ()
89+
return %res : $()
90+
}
91+
92+
// CHECK-LABEL: sil [ossa] @caller_alloc_box{{.*}} {
93+
// CHECK: alloc_box
94+
// CHECK: alloc_box [dynamic_lifetime]
95+
// CHECK: alloc_box [reflection]
96+
// CHECK: alloc_box [pointer_escape]
97+
// CHECK: alloc_box [moveable_value_debuginfo]
98+
// CHECK: alloc_box [dynamic_lifetime] [reflection]
99+
// CHECK: alloc_box [dynamic_lifetime] [pointer_escape]
100+
// CHECK: alloc_box [dynamic_lifetime] [moveable_value_debuginfo]
101+
// CHECK: alloc_box [reflection] [pointer_escape]
102+
// CHECK: alloc_box [reflection] [moveable_value_debuginfo]
103+
// CHECK: alloc_box [pointer_escape] [moveable_value_debuginfo]
104+
// CHECK: alloc_box [reflection] [pointer_escape] [moveable_value_debuginfo]
105+
// CHECK: alloc_box [dynamic_lifetime] [pointer_escape] [moveable_value_debuginfo]
106+
// CHECK: alloc_box [dynamic_lifetime] [reflection] [moveable_value_debuginfo]
107+
// CHECK: alloc_box [dynamic_lifetime] [reflection] [pointer_escape]
108+
// CHECK: alloc_box [dynamic_lifetime] [reflection] [pointer_escape] [moveable_value_debuginfo]
109+
// CHECK-LABEL: } // end sil function 'caller_alloc_box'
110+
sil [ossa] @caller_alloc_box : $@convention(thin) () -> () {
111+
%callee = function_ref @callee_alloc_box : $@convention(thin) () -> ()
112+
%res = apply %callee() : $@convention(thin) () -> ()
113+
return %res : $()
114+
}
115+
55116
sil [ossa] @callee_alloc_stack : $@convention(thin) () -> () {
56117
%instance = alloc_stack $Builtin.NativeObject
57118
dealloc_stack %instance : $*Builtin.NativeObject

0 commit comments

Comments
 (0)