Improve one of the comments in COWArrayOpts.

This commit is contained in:
Andrew Trick
2020-01-29 10:23:18 -08:00
parent ffa6bf4729
commit 17d9d20275

View File

@@ -849,11 +849,16 @@ bool COWArrayOpt::hoistMakeMutable(ArraySemanticsCall MakeMutable,
// Check whether we can hoist make_mutable based on the operations that are
// in the loop.
// Note that in this case we don't verify that the array buffer is not aliased
// and therefore we must be conservative if the make_mutable is executed
// conditionally (i.e. doesn't dominate all exit blocks).
// The test SILOptimizer/cowarray_opt.sil: dont_hoist_if_executed_conditionally
// shows the problem.
//
// Hoisting make_mutable releases the original array storage. If an alias of
// that storage is accessed on any path reachable from the loop header that
// doesn't already pass through the make_mutable, then hoisting is
// illegal. hasLoopOnlyDestructorSafeArrayOperations checks that the array
// storage is not accessed within the loop. However, this does not include
// paths exiting the loop. Rather than analyzing code outside the loop, simply
// check that the original make_mutable dominates all exits. The test
// SILOptimizer/cowarray_opt.sil: dont_hoist_if_executed_conditionally shows
// the problem.
if (hasLoopOnlyDestructorSafeArrayOperations() && dominatesExits) {
// Done. We can hoist the make_mutable.
// We still need the array uses later to check if we can add loads to