DmdAnal: Annotate top-level bindings
It might be worth annotating top-level bindings with their demands.
At least for non-exported things we might get useful usage.
[...] it's almost never worth it:
- Top level demands will never be strict, so the most we can hope for is to identify single-entry thunks.
- For exported things we don't see all calls.
- For non-exported things, most are used inside a lambda, so they won't be single entry (unless the lambda is called-once from a top-level thunk).
- Doing an update on a top-level thunk does not cost much anyway.
Hmm. A single-entry top-level thunk does not need to be marked as a CAF, which might help to shrink SRTs?
But call usage on non-exported top-level bindings might also lead to eta expansion opportunities. Most of these opportunities will already be exploited by Call Arity, but who knows if there are other beneficial cases.
(Well, I know, actually: The usage analysis I implemented in my master's thesis annotated top-level bindings and was even more precise than what demand analysis does, but scored only mediocre improvements. But it managed to replace Call Arity in doing so!)