Create function segments and emit unwind info of them.
A segment must be less than 1MB and no prolog or epilog can cross segments boundary.
Reference: https://docs.microsoft.com/en-us/cpp/build/arm64-exception-handling#function-fragments
TODOs:
- Enable packed unwind info (.pdata only) for multi-segment functions. (currently only enabled for functions less than 1MB, that is: functions have one segment)
- Emit packed unwind info (.pdata only) for segments that have neithor prolog nor epilog.
These two will be done in next patch (WIP).
- Handle functions that requires more than 255 (0xFF) words to encode all prolog and epilogs unwind op or have more than 65535 (0xFFFF) epilogs.
This one needs some change as we need to move counting code words for epilog earlier in the current process. We may not see either case in practice, IMHO.
- Shrink Wrapping where some stack ops are moved out of prolog/epilog and put in different segment. See example 2 of above link.
- Align directive or aligning loops where we cannot reliably compute function size.
4 and 5 are kind of future work, I'm think about what to do as well as getting test cases for them.
Can you add a comment about what the int64_t is here? It's not obvious to me on the first read through the code.