File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -1659,8 +1659,18 @@ bool TempRValueOptPass::collectLoads(
1659
1659
1660
1660
// Check if there is another function argument, which is inout which might
1661
1661
// modify the source of the copy_addr.
1662
- // If we would remove the copy_addr in this case, it would result in an
1663
- // exclusivity violation.
1662
+ //
1663
+ // When a use of the temporary is an apply, then we need to prove that the
1664
+ // function called by the apply cannot modify the temporary's source
1665
+ // value. By design, this should be handled by
1666
+ // `checkNoSourceModification`. However, this would be too conservative
1667
+ // since it's common for the apply to have an @out argument, and alias
1668
+ // analysis cannot prove that the @out does not alias with `src`. Instead,
1669
+ // `checkNoSourceModification` always avoids analyzing the current use, so
1670
+ // applies need to be handled here. We already know that an @out cannot
1671
+ // alias with `src` because the `src` value must be initialized at the point
1672
+ // of the call. Hence, it is sufficient to check specifically for another
1673
+ // @inout that might alias with `src`.
1664
1674
auto calleeConv = apply.getSubstCalleeConv ();
1665
1675
unsigned calleeArgIdx = apply.getCalleeArgIndexOfFirstAppliedArg ();
1666
1676
for (Operand &operand : apply.getArgumentOperands ()) {
You can’t perform that action at this time.
0 commit comments