dplassgit / d2lang

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

DeadAssignmentOperator fails for long temps? #339

Closed dplassgit closed 3 weeks ago

dplassgit commented 4 weeks ago

In this snippet _n__inline__0 is a Long temp (I think) but it never gets optimized out by the DeadAssignmentOperator.

_n__inline__0 = 10 [INT const]
printf("%s\n", 10 [INT const])
__temp4__inline__0 = 10 [INT const] + 1 [INT const]
__temp2 = __temp4__inline__0
printf("%s\n", __temp2)
goto __after_proc_shortProc_3
shortProc(n: INT) {
printf("%s\n", n: INT (#0))
__temp4 = n: INT (#0) + 1 [INT const]
return __temp4
end shortProc
__after_proc_shortProc_3:
exit(0)
dplassgit commented 3 weeks ago

This is WAI. At the "goto" it clears all known assignments because the state won't be known anymore.