swift
3fe5e038 - [move-function] Make MandatoryInlining always convert builtin.move -> mark_unresolved_move_addr.

Commit
3 years ago
[move-function] Make MandatoryInlining always convert builtin.move -> mark_unresolved_move_addr. To give a bit more information, currently the way the move function is implemented is that: 1. SILGen emits a builtin "move" that is called within the function _move in the stdlib. 2. Mandatory Inlining today if the final inlined type is address only, inlines builtin "move" as mark_unresolved_move_addr. Otherwise, if the inlined type is loadable, it performs a load [take] + move [diagnostic] + store [init]. 3. In the diagnostic pipeline before any mem optimizations have run, we run the move checker for addresses. This eliminates /all/ mark_unresolved_move_addr as part of emitting diagnostics. In order to make this work, we perform a small optimization before the checker runs that moves the mark_unresolved_move_addr from being on temporary alloc_stacks to the true base underlying address we are trying to move. This optimization is necessary since _move is generic and often times SILGen will emit this temporary that we do not want. 4. Then after we have run the guaranteed mem optimizations, we run the object based move checker emitting diagnostics. This PR changes the scheme above to the following: 1. SILGen emits a builtin "move" that is called within the function _move in the stdlib. 2. Mandatory Inlining inlines builtin "move" as mark_unresolved_move_addr. 3. In the diagnostic pipeline before we have run any mem optimizations and before we have run the actual move address checker, we massage the IR as we do above but in a separate pass where in addition we try to match this pattern: ``` %temporary = alloc_stack $LoadableType store %1 to [init] %temporary : $*LoadableType mark_unresolved_move_addr %temporary to %otherAddr : $*LoadableType destroy_addr %temporary : $*LoadableType ``` and transform it to: ``` %temporary = alloc_stack $LoadableType %2 = move_value [allows_diagnostics] %1 : $*LoadableType store %2 to [init] %temporary : $*LoadableType destroy_addr %temporary : $*LoadableType ``` ensuring that the object move checker will handle this. 4. Then after we have run the guaranteed mem optimizations, we run the object based move checker emitting diagnostics. (cherry picked from commit 4a9c26ff96d5baba5cbc6e0c985629c7b842547e)
Author
Committer
Parents
Loading