Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cyclic node flag getting added to sink call [backport:2.0] #24194

Merged
merged 3 commits into from
Sep 29, 2024

Conversation

metagn
Copy link
Collaborator

@metagn metagn commented Sep 27, 2024

Sorry I don't have a test case or issue for this. injectdestructors is supposed to add a final bool argument to =copy and =dup to mark cyclic types, as generated by liftdestructors. Hence this flag is added after every call to genCopy, but genCopy can generate a =sink call when passed the flag IsExplicitSink by nkSinkAsgn. This creates a codegen error, saying the sink received an extra argument. This is fixed by not adding the argument on the flag IsExplicitSink.

This is a followup to #20585 which is on the 2.0 branch, hence this is marked backport.

@metagn metagn changed the title fix cyclic node flag getting added to sink call fix cyclic node flag getting added to sink call [backport:2.0] Sep 27, 2024
@Araq
Copy link
Member

Araq commented Sep 27, 2024

Refactor it so that if IsExplicitSink notin flags: is done once in finishCopy.

@metagn
Copy link
Collaborator Author

metagn commented Sep 28, 2024

Done

@@ -317,8 +317,9 @@ proc isCriticalLink(dest: PNode): bool {.inline.} =
]#
result = dest.kind != nkSym

proc finishCopy(c: var Con; result, dest: PNode; isFromSink: bool) =
if c.graph.config.selectedGC == gcOrc:
proc finishCopy(c: var Con; result, dest: PNode; flags: set[MoveOrCopyFlag]; isFromSink: bool) =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually move the isFromSink to MoveOrCopyFlag.

@Araq Araq merged commit 7974a22 into nim-lang:devel Sep 29, 2024
19 checks passed
Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from 7974a22

Hint: mm: orc; opt: speed; options: -d:release
174575 lines; 8.338s; 654.5MiB peakmem

narimiran pushed a commit that referenced this pull request Sep 30, 2024
Sorry I don't have a test case or issue for this. `injectdestructors` is
supposed to add a final bool argument to `=copy` and `=dup` to mark
cyclic types, as generated by `liftdestructors`. Hence this flag is
added after every call to `genCopy`, but `genCopy` can generate a
`=sink` call when passed the flag `IsExplicitSink` by `nkSinkAsgn`. This
creates a codegen error, saying the sink received an extra argument.
This is fixed by not adding the argument on the flag `IsExplicitSink`.

This is a followup to #20585 which is on the 2.0 branch, hence this is
marked backport.

(cherry picked from commit 7974a22)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants