File tree 1 file changed +10
-5
lines changed
lib/SILOptimizer/LoopTransforms
1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -849,11 +849,16 @@ bool COWArrayOpt::hoistMakeMutable(ArraySemanticsCall MakeMutable,
849
849
850
850
// Check whether we can hoist make_mutable based on the operations that are
851
851
// in the loop.
852
- // Note that in this case we don't verify that the array buffer is not aliased
853
- // and therefore we must be conservative if the make_mutable is executed
854
- // conditionally (i.e. doesn't dominate all exit blocks).
855
- // The test SILOptimizer/cowarray_opt.sil: dont_hoist_if_executed_conditionally
856
- // shows the problem.
852
+ //
853
+ // Hoisting make_mutable releases the original array storage. If an alias of
854
+ // that storage is accessed on any path reachable from the loop header that
855
+ // doesn't already pass through the make_mutable, then hoisting is
856
+ // illegal. hasLoopOnlyDestructorSafeArrayOperations checks that the array
857
+ // storage is not accessed within the loop. However, this does not include
858
+ // paths exiting the loop. Rather than analyzing code outside the loop, simply
859
+ // check that the original make_mutable dominates all exits. The test
860
+ // SILOptimizer/cowarray_opt.sil: dont_hoist_if_executed_conditionally shows
861
+ // the problem.
857
862
if (hasLoopOnlyDestructorSafeArrayOperations () && dominatesExits) {
858
863
// Done. We can hoist the make_mutable.
859
864
// We still need the array uses later to check if we can add loads to
You can’t perform that action at this time.
0 commit comments