[LLVMdev] [cfe-dev] Unwind behaviour in Clang/LLVM

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon Feb 10 06:44:06 PST 2014


On 10 February 2014 03:44, Renato Golin <renato.golin at linaro.org> wrote:
> On 10 February 2014 02:59, Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote:
>> It has to be an attribute because of LTO. You can LTO a file compiled
>> with -fasynchronous-unwind-tables and one with
>> -fno-asynchronous-unwind-tables. That is why we have the uwtable
>> attribute.
>
> Hi Rafael,
>
> I've removed the -arm-disable-ehabi flag already, and I'm planning on
> using the uwtable attribute to determine if we need to emit the unwind
> tables or not, just like DwarfCFIException. What is the real semantics
> of uwtable?

Just that: unwind tables are output for the function, even if nothing
else seems to say they are necessary.

> I don't see that attribute too often, but I still see tables being
> emitted in x86_64.

Strange. I see it even with simple C testcases:

void bar(void);
void zed(void) {  bar();}

produces

define void @zed() #0 ....
attributes #0 = { nounwind uwtable...

>The rules on what to emit in beginFunction() are a
> bit convoluted, and I guess that's because uwtables' semantics is not
> definite. I was hoping for something a bit stronger, because we do
> lose a lot of information in the back-end, such as what exception
> style is has (depending on the target, language, flags).
>
> Is there any definitive explanation on the complete semantics of
> uwtables and nounwind? I could be wrong, but from what I can see,
> beginFunction() is based on circumstantial behaviour, not explicit
> semantics.

I agree that the logic in there seems a bit odd. What is called
shouldEmitMoves should probably include all possible
reasons for printing the unwind tables. We should probably also use
uwtable to guard the emission of other table formats
as you propose.

The semantics uwtable is just "make sure it is possible to unwind past
this function". It doesn't include anything more,
like the ability to run destructors. It is used for ABIs that require
it for use in debuggers and profilers.

I am not too sure about nounwind. I think it is more about using
unwind for control flow in the language. Having it allows us
to prune information used for exception handling.

> cheers,
> --renato

Cheers,
Rafael




More information about the llvm-dev mailing list