Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Stop Memsetting Structures. Parent comment
Let's look at a basic common case, as a checklist.
1. All fields are definitely assigned.
2. No functions are called except intrisics.
3. Nothing reads from the object on any control path.
4. Memset happens between creation and first assignment.
We agreed that step 1 is a solved problem, right? Are any of 2-4 difficult? Did I miss any prerequisites for the optimization?
Once you can prove 1-4, isn't the optimization pass as simple as looking for memsets applied to structs, checking 1-4, then deleting the call?
There are no comments on this comment yet.
Let's look at a basic common case, as a checklist.
1. All fields are definitely assigned.
2. No functions are called except intrisics.
3. Nothing reads from the object on any control path.
4. Memset happens between creation and first assignment.
We agreed that step 1 is a solved problem, right? Are any of 2-4 difficult? Did I miss any prerequisites for the optimization?
Once you can prove 1-4, isn't the optimization pass as simple as looking for memsets applied to structs, checking 1-4, then deleting the call?