mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Improve one of the comments in COWArrayOpts.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user