On 03/25/2011 10:34 AM, Bernd Schmidt wrote: > I don't know much about the unwinding code. I'm currently thinking about > writing out a cfi_remember_state at the start of the function, restoring > that clean state when necessary at the start of a new block and emitting > the necessary directives to reach the correct state. What directives > should I expect to be required? Can I get by just with cfi_offset and > cfi_def_cfa_offset, or will something else be necessary?
Yes, several things: register, expression, gnu_args_size, perhaps a few more. I think the ideal thing would be a pass while the cfg is still extant that captures the unwind info into notes; these can be recorded at basic block boundaries, so that they persist until the end of compilation. So long as late late compilation passes continue to not move frame-related insns across basic block boundaries, we should be fine. Irritatingly, the exact place to locate this pass is difficult to pin down. Immediately before md_reorg is the last place we have the cfg. But we do strange things in, e.g. ia64 where we rebuild the cfg and run sched_ebb during md_reorg. Of course, ia64 is a bad example because its unwind info is target-specific, and quite a lot of the possible benefit of shrink wrapping is lost via the register windowing. I'm willing to work with you on the problem of cfg-aware unwind info. We have needed this for a really long time; there are existing bugs related to exception handling and !ACCUMULATE_OUTGOING_ARGS that would be fixed by this. r~