Don't rely on implicit information for statement used-ness. (#46966)
Currently, we were relying on the implicitly passed in sv.currpc
to determine whether a call result type was needed or not. This
is usually correct, but not always. For example, in apply_iterate,
we actually end up calling various `iterate` methods and inspect
their result, so the used-ness of the outer apply_iterate is
irrelevant. Similar examples occur in external packages.
Fix this issue by refactoring the code to thread through an
extra `StmtInfo` object that record used-ness (and potentially
other stmt attributes in the future).