Compiler: force zero initialization of local variables#383
Compiler: force zero initialization of local variables#383chqrlie wants to merge 1 commit intoc2lang:masterfrom
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
df45c0f to
6fbbe10
Compare
f070ea4 to
ed67ea4
Compare
b877495 to
66c54d1
Compare
6bfb102 to
d7f3855
Compare
0dc24c2 to
e7e0679
Compare
c3d5805 to
9273f3a
Compare
87e2c6e to
8111e23
Compare
* make all local variables zero-initialized except if tagged as `@(noinit)` * update tests
@(noinit)