[llvm-commits] [patch] Change how we handle mandatory unwind tables

Rafael Ávila de Espíndola rafael.espindola at gmail.com
Mon May 23 11:44:32 PDT 2011


Currently the llvm codegen uses the option unwind-tables to decide if it
should produce unwind tables for all functions, even those that are
marked nounwind.

On the clang side, clang sets that option if unwind tables are mandatory
for that particular ABI.

This is inconvenient because llc will not produce unwind tables if not
given the correct option by the user. More importantly, LTO will always
get this wrong on x86-64.

One way to fix this would be to move the logic from Clang's codegen to
LLVM's codegen, but we would still have problems with:

$ clang -fno-asynchronous-unwind-tables -c -emit-llvm test.c
$ clang test.o -o test

I think this shows that the "needs unwind info" bit needs to be explicit
in the IL. What the attached patches do is:

*) Remove the option from CodeGen, it now uses only the nounwind
attribute to decide if a eh_frame entry is needed.
*) Change clang to not introduce nounwind if the ABI mandates it.
*) Add a new entry to TargetData so that -prune-eh knows if it must not
add nounwind attributes.

Adding this to TargetData is a bit strange, but I am not sure where else
to put it.

The change to prune-eh also removes some optimization opportunities.
Preventing adding nounwind can prevent converting an invoke to a call.

The prune-eh issue can be fixed by adding a new attribute, noehframe.
With the new attribute nounwind would keep its current meaning of "no
exception will unwind past this" and noehframe would be the more strict
"nothing (debuggers, profilers) will try to unwind past this".

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm.patch
Type: text/x-patch
Size: 10935 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110523/05a9b810/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang.patch
Type: text/x-patch
Size: 2541 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110523/05a9b810/attachment-0001.bin>


More information about the llvm-commits mailing list