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 @@ -1203,3 +1203,20 @@ sil [ossa] @dont_dce_lexical_phi : $() -> () {
1203
1203
return %retval : $()
1204
1204
}
1205
1205
1206
+ class KlassWithDeinit {
1207
+ init()
1208
+ deinit
1209
+ }
1210
+
1211
+ // DCE should not delete dead allocations, leave it to DOE
1212
+ // CHECK-LABEL: sil [ossa] @dont_delete_allocation :
1213
+ // CHECK: alloc_ref
1214
+ // CHECK-LABEL: } // end sil function 'dont_delete_allocation'
1215
+ sil [ossa] @dont_delete_allocation : $@convention(thin) () -> () {
1216
+ bb0:
1217
+ %a = alloc_ref $KlassWithDeinit
1218
+ destroy_value %a : $KlassWithDeinit
1219
+ %t = tuple ()
1220
+ return %t : $()
1221
+ }
1222
+
You can’t perform that action at this time.
0 commit comments