SegregateStackAccesses creates new functions. Iterating over existing
functions while creating new ones is problematic, so we now first
collect all the functions we want to inspect and then process them.
SegregateStackAccesses and PromoteStackPointer were not handling
functions declarated (but not defined) properly.
This commit fixes this, in part by adopting `TaggedFunctionPass`.
We need to prevent DCE from killing `revng_init_local_sp`, since certain
passes downstream might want to introduce new uses of it, and they might
be the first.
`SegregateStackAccesses` will take care of removing it by hand.
Before this commit, calls were marked to push ALAP in the wrong order,
resulting in preventing to actually push them ALAP.
This commit fixes the ordering, reactivating the code motion.
Before this commit, we did not take into consideration that
revng_call_stack_arguments has reference semantics, and we were using
its AddressOf in call sites that were taking the stack arguments.
This commit fixes the problem, bypassing the call to AddressOf when
passing the arguments to calls.
This commit handles the situation in which we have a call site with
stack arguments, but it was not possible to determine the stack height
at the call site.
The solution is to simply ignore stack arguments and emit in the IR a
warning.
Add `ReadOnly` and `InaccessibleMemOnly` attributes to the following
functions:
- `revng_stack_frame`
- `revng_call_stack_arguments`
- `ModelGEP`
- `AddressOf`
This prevents `CSE` from grouping together any of these calls, while
still enabling `DCE` to remove calls that are not used.
Before this commit, SegregateStackAccessesPass always expected to find
calls stack_size_at_call_site markers injected by
InjectStackSizeProbesAtCallSitesPass.
This is not always true, because aggressive LLVM optimizations can
remove dead code.
As an example, if the user or some analysis earlier in the pipeline
wrongly marks registers as non-arguments, the optimization pipeline will
throw away and eliminate everything that descends from the initial
values of those registers.
This commit enables SegregateStackAccessesPass to cope with calls to
stack_size_at_call_site that were eliminated, and keep going just
considering the calls that are still there.