File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,12 @@ static bool seemsUseful(SILInstruction *I) {
81
81
if (isa<DebugValueInst>(I))
82
82
return isa<SILFunctionArgument>(I->getOperand (0 ))
83
83
|| isa<SILUndef>(I->getOperand (0 ));
84
+
85
+
86
+ // Don't delete allocation instructions in DCE.
87
+ if (isa<AllocRefInst>(I) || isa<AllocRefDynamicInst>(I)) {
88
+ return true ;
89
+ }
84
90
85
91
return false ;
86
92
}
Original file line number Diff line number Diff line change @@ -1196,3 +1196,20 @@ sil [ossa] @dont_dce_lexical_phi : $() -> () {
1196
1196
return %retval : $()
1197
1197
}
1198
1198
1199
+ class KlassWithDeinit {
1200
+ init()
1201
+ deinit
1202
+ }
1203
+
1204
+ // DCE should not delete dead allocations, leave it to DOE
1205
+ // CHECK-LABEL: sil [ossa] @dont_delete_allocation :
1206
+ // CHECK: alloc_ref
1207
+ // CHECK-LABEL: } // end sil function 'dont_delete_allocation'
1208
+ sil [ossa] @dont_delete_allocation : $@convention(thin) () -> () {
1209
+ bb0:
1210
+ %a = alloc_ref $KlassWithDeinit
1211
+ destroy_value %a : $KlassWithDeinit
1212
+ %t = tuple ()
1213
+ return %t : $()
1214
+ }
1215
+
You can’t perform that action at this time.
0 commit comments