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
Issue with passing a variable to a function from the PARENT scope #214
Comments
Hmm I think I see what could go wrong, can you provide a small test case for the over optimisation ? |
Ok I did some tests, variable is not discarded, but the scope is changed. |
glx22
added a commit
to glx22/nml
that referenced
this issue
May 4, 2021
glx22
added a commit
to glx22/nml
that referenced
this issue
May 4, 2021
glx22
added a commit
that referenced
this issue
May 4, 2021
Andrew350
pushed a commit
to Andrew350/nml
that referenced
this issue
May 5, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Apologies in advance for any misuse of terminology here...
Note: I am using PR #173 to build, but I don't think that affects this
When trying to pass a variable to a function which exists in the PARENT scope of the feature I'm calling from, I could only make it work by using a dummy switch in-between (or else it throws an error, due to being the wrong scope). This isn't a big deal, except it results in nmlc trying to "optimise" the switch (since it isn't doing anything except sending the variable), which results in the variable being apparently discarded and the callback failing to work properly.
I was able to work around this by making the dummy switch do some garbage operation (in this case store a value to a temp register) to prevent the "optimising" and make it work, but it seems like this shouldn't be necessary. Example below of what I'm doing:
Am I just doing this completely wrong? Is there a better way to do this without the use of a dummy switch? It's a bit hard to tell since there doesn't seem to be any obvious documentation on this feature, so I'm just taking shots in the dark here.
If this is "correct", it would seem that perhaps nmlc is being a bit overzealous with it's optimizations in this case, and that function calls should be ignored somehow. But I'd appreciate any advice to get me on the right track if not 🙂
The text was updated successfully, but these errors were encountered: