-
Notifications
You must be signed in to change notification settings - Fork 55
Compiler: force zero initialization of local variables #383
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
base: master
Are you sure you want to change the base?
Conversation
|
The generated C code creates something like this for integers:
I was surprised that this was allowed at all, but I think it would be more readable to just generate
and only generate braces for structs, etc I did measure the performance and saw no change |
|
I agree this PR needs polishing to this regard. My goal is for you to test the performance impact. |
48daab1 to
a33c80a
Compare
|
It should easily opt out zero init, already at -O1. This works fine here at least: https://godbolt.org/z/M4sTEr5zv |
Redundant initialization seems easy to handle. How about this one: |
|
That's something that would require |
Indeed |
|
It would be an optimization, but none that the compiler can do without inlining the functions. If it did, then the zero init would be removed I'm sure. Unused local variables are zero init:ed but -O1 will just remove them no problem. |
I agree with this approach and that's what I would like to achieve through static analysis in many cases. |
15351ae to
0990889
Compare
9ebb3a6 to
1e4ddb0
Compare
ca76deb to
3fda833
Compare
* make all local variables zero-initialized except if tagged as `@(noinit)` * update tests
@(noinit)