dplassgit / d2lang

D2 is a strongly-typed, statically-typed, (mostly) inferred-type compiled language.
MIT License
6 stars 0 forks source link

When a local is optimized out, the proc shouldn't allocate stack space for it #219

Open dplassgit opened 1 year ago

dplassgit commented 1 year ago

Original source:

f:proc:bool { a='abc' b=null c=a == b return c} println f()

IL code:

goto __after_proc_f_1
_f:
f() {
return false
end f
__after_proc_f_1:
__temp3 = f()
printf("%s", __temp3)
printf("%s", \"\n\")
exit(0)

Used to have 3 local variables in f() and so it still allocates space:

  sub RSP, 32  ; space for locals
dplassgit commented 7 months ago

This is actually blocked on #62