You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/SILOptimizer/cse.sil
+26Lines changed: 26 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1244,6 +1244,32 @@ bb3:
1244
1244
return %20 : $()
1245
1245
}
1246
1246
1247
+
// This test is not a repro but used to show why we need a local Cloner object in CSE::processOpenExistentialRef.
1248
+
// Discussion:
1249
+
// Since the CSE pass can delete instructions and allocate instructions whose state can be cached in the Cloner, we have to use local Cloner object so that we don't accidentally refer to stale state
1250
+
// In this test users of %9 are all cloned and original instructions are deleted. Users of %13 are similarly cloned and original instructions are deleted so the types can be remapped.
1251
+
// Instructions can further get deleted in the main CSE pass as well as during SimplifyInstruction.
1252
+
// For some heap allocation patterns newly allocated instructions can get the same address of a previously allocated instruction, and can end up referring to a stale state in the Cloner.
1253
+
//
1254
+
// CHECK-LABEL: sil @cse_open_existential_ref_local_cloner :
1255
+
// CHECK: open_existential_ref
1256
+
// CHECK-NOT: open_existential_ref
1257
+
// CHECK-LABEL: } // end sil function 'cse_open_existential_ref_local_cloner'
1258
+
sil @cse_open_existential_ref_local_cloner : $@convention(thin) (@guaranteed Proto, Bool) -> () {
1259
+
bb0(%0 : $Proto, %1 : $Bool):
1260
+
%4 = open_existential_ref %0 : $Proto to $@opened("1B68354A-4796-11E6-B7DF-B8E856428C60") Proto
1261
+
%5 = witness_method $@opened("1B68354A-4796-11E6-B7DF-B8E856428C60") Proto, #Proto.doThis, %4 : $@opened("1B68354A-4796-11E6-B7DF-B8E856428C60") Proto : $@convention(witness_method: Proto) <τ_0_0 where τ_0_0 : Proto> (@guaranteed τ_0_0) -> ()
0 commit comments