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

Duncan Sands baldrick at free.fr
Mon May 23 12:50:49 PDT 2011


Hi Rafael,

> 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.

"nounwind" means that no exceptions will be thrown.  Thus exception handling
tables are not needed.  However "unwind-tables", aka register moves and other
info that is important for debugging are still useful.  The term "unwind" is
overloaded here :)

Ciao, Duncan.

>
> 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
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list