-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
cgen: remove unused code generated for unwrapping temp var from callexpr (detect unused return value from CallExpr) #22769
cgen: remove unused code generated for unwrapping temp var from callexpr (detect unused return value from CallExpr) #22769
Conversation
About 40 unused option tmp var data access removed from .c file of cmd/v
|
Why are they marked with +, instead of -? |
My |
oh, ok |
Is there a performance impact? |
I think this could be handled if the |
Yes, with this new flag |
I haven't noticed perf impacts. |
@felipensp What I have in mind does not require |
I'm working on it to set the flag about value usage in parse-time... removing the checker sets right now. |
You can not do it reliably in the parser, since it does not have the complete type info. For example, you can have a call to a function declared in another .v file in the same module, that may not be parsed yet, and you will not know if the current call expression returns something or not. In the checker, since all the .v files are already parsed, the table is filled with all the symbols declared in all of them, and you so you know for sure what every call expression refers to. |
I think we're talking about different thing. I mean about knowing wether the value is being used or not in the code, not about expr types checking. This is my objective here. |
And how do you know if the type of the returned value is other than void? |
My goal is not check the returned type but if the possible return value is used or not. |
If you have just |
I guess for the purpose of code generation, just having a plain (except for |
Anyway, I did some performance checks, and there is not indeed a perceivable performance difference between the change here and on master, and the generated code is cleaner here. Excellent work. |
This PR adds a flag on
ast.CallExpr
to state about its return value is used. Using such information we can handle better the temporary storage for returning values or not.Huly®: V_0.6-21216