{"action":"opened","issue":{"url":"https://api.github.com/repos/CollinReeser/clam/issues/7","labels_url":"https://api.github.com/repos/CollinReeser/clam/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/CollinReeser/clam/issues/7/comments","events_url":"https://api.github.com/repos/CollinReeser/clam/issues/7/events","html_url":"https://github.com/CollinReeser/clam/issues/7","id":55993159,"number":7,"title":"Improve analysis of how much stack space to reserve for stack variables","user":{"login":"CollinReeser","id":639071,"avatar_url":"https://avatars.githubusercontent.com/u/639071?v=3","gravatar_id":"","url":"https://api.github.com/users/CollinReeser","html_url":"https://github.com/CollinReeser","followers_url":"https://api.github.com/users/CollinReeser/followers","following_url":"https://api.github.com/users/CollinReeser/following{/other_user}","gists_url":"https://api.github.com/users/CollinReeser/gists{/gist_id}","starred_url":"https://api.github.com/users/CollinReeser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CollinReeser/subscriptions","organizations_url":"https://api.github.com/users/CollinReeser/orgs","repos_url":"https://api.github.com/users/CollinReeser/repos","events_url":"https://api.github.com/users/CollinReeser/events{/privacy}","received_events_url":"https://api.github.com/users/CollinReeser/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/CollinReeser/clam/labels/codegen","name":"codegen","color":"d4c5f9"},{"url":"https://api.github.com/repos/CollinReeser/clam/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/CollinReeser/clam/labels/typechecking","name":"typechecking","color":"d4c5f9"}],"state":"open","locked":false,"assignee":{"login":"CollinReeser","id":639071,"avatar_url":"https://avatars.githubusercontent.com/u/639071?v=3","gravatar_id":"","url":"https://api.github.com/users/CollinReeser","html_url":"https://github.com/CollinReeser","followers_url":"https://api.github.com/users/CollinReeser/followers","following_url":"https://api.github.com/users/CollinReeser/following{/other_user}","gists_url":"https://api.github.com/users/CollinReeser/gists{/gist_id}","starred_url":"https://api.github.com/users/CollinReeser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CollinReeser/subscriptions","organizations_url":"https://api.github.com/users/CollinReeser/orgs","repos_url":"https://api.github.com/users/CollinReeser/repos","events_url":"https://api.github.com/users/CollinReeser/events{/privacy}","received_events_url":"https://api.github.com/users/CollinReeser/received_events","type":"User","site_admin":false},"milestone":null,"comments":0,"created_at":"2015-01-30T04:20:56Z","updated_at":"2015-01-30T04:20:56Z","closed_at":null,"body":"The current analysis that determines how much stack space to reserve for stack variables is flawed. It will always reserve at least as much stack space as is necessary, but since it only ever increases the amount it will allocate for each variable encountered, but never decreases it (or \"reuses\" allocation) for when a scope within which one or more variables are declares is left, the analysis can allocate far, far more space than is necessary. For example:\r\n```go\r\nfunc main() {\r\n    a := 5;\r\n    if (b := 6; true) {\r\n        c := 7;\r\n    }\r\n    d := 8;\r\n}\r\n```\r\nIn this example, the analysis will determine that 32 bytes of stack space must be reserved, 8 bytes each for `a`, `b`, `c`, and `d`, when in fact only 24 bytes must be allocated, as once the `if` statement is left, only the stack space allocated for `a` is valid. That is, at maximum, only 24 bytes is necessary to keep all valid data in memory. In practice, `d` should reuse the stack space allocated for `b`."}}