-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal: remove the double-meaning of
mMove
(#968)
## Summary Don't use a special `move` magic form for the `seq`/`string` sink implementation, but instead emit the required code directly. This moves decision making out the code generators, fixes a MIR-level issue, and is a preparation for MIR improvements. ## Details For the `=sink` implementation of `seq`s and `string`s, `liftdestructors` emitted a special `mMove` call that the C code generator then expanded into the C equivalent of: ```nim if not samePayload(a, b): =destroy(a) a = b ``` The problem is with how the generated `move` call looked: `move(a, b, =destroy(a))`. The `CgNode` IR for the call has to have the same shape, but this required special-casing in `mirgen` and the resulting MIR code also doesn't properly represent the actual behaviour (the `=destroy(a)` call is not unconditionally evaluated), which could interfere with MIR analysis. In order to correctly represent the behaviour at the MIR level, the `liftdestructors` lifting emits the above code directly, without overloading the `mMove` magic. Since how the payload comparison works is currently backend dependent, the new internal-only `mSamePayload` magic is introduced, which the C generator then lowers into a comparison of the payload pointers.
- Loading branch information
Showing
4 changed files
with
25 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters