[llvm-dev] Exception handling support for a target

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Tue Jan 16 05:03:23 PST 2018


On 16 January 2018 at 12:23, 陳韋任 <chenwj.cs97g at g2.nctu.edu.tw> wrote:
> Do we have to emit directives in the epilogue, too? One of my test case fail
> due to the directives in the epilogue have been executed. After removing
>  them from epilogue, the exception is caught as expected.

Emitting directives in the epilogue is hard because the directives
apply to all instructions after in program-counter order. So if you
have an epilogue in the middle of a function and emit CFI directives
saying the registers are back where they were then the unwinder will
think that applies to the rest of the function too.

To fix that you'd have to emit yet more directives in the basic block
immeditately following the epilogue. Most people don't bother with
either because you'd only really need it if you expected to have to
catch an exception in the epilogue (which is impossible on most
platforms).

> Also, the
> directives are also for debug purpose (.debug_frame), right? I guess I only
> have to make sure directives work for exception handling, then debug works
> as well?

Yep. Technically you can stop the debugger in the middle of a prologue
or epilogue, at which point having more fine-grained directives can
help. In practice there's no real reason to do that so people don't
emit directives for it (at least not as a high priority).

Cheers.

Tim.


More information about the llvm-dev mailing list