It can also reason about control flow. It does constant folding etc, is it at least theoretically possible to do alloc optimization?
Yep but that would probably break predictability. In low level code I wouldn't rely on some malloc being optimized away, and rather write code explicitly without allocations.