[PATCH] PR8541; X86: Handle unwind.init and eh.return intrinsics.

Pasi Parviainen pasi.parviainen at iki.fi
Tue May 14 17:20:52 PDT 2013


On 15.5.2013 2:26, Jakob Stoklund Olesen wrote:
>
> On May 14, 2013, at 3:14 PM, Pasi Parviainen <pasi.parviainen at iki.fi> wrote:
>
>> On 14.5.2013 21:06, Jakob Stoklund Olesen wrote:
>>>
>>> On Apr 20, 2013, at 1:43 AM, Pasi Parviainen <pasi.parviainen at iki.fi> wrote:
>>>
>>>> Hi,
>>>>
>>>> First patch addresses the problem in PR8541. It forces spilling of affected registers to stack when unwind.init and eh.return intrinsics are encountered.
>>>>
>>>> Second patch is additional patch which relaxes the requirement of frame pointer in functions with eh.return.
>>>>
>>>> Pasi
>>>
>>> Hi Pasi,
>>>
>>> It looks like you actually know what eh.return is supposed to do. Could you explain, please?
>>
>> It is a terminator intrinsic which purpose is to return control flow from a unwinder (libgcc_s) back to a landingpad. For this it needs to provide exception information through registers for the landingpad. These registers must be spilled to stack slots in a prologue and restored only in epilogues containing eh.return intrinsic.
>
> Thanks.
>
> Is it important that the extra registers are not restored in non-eh.return epilogues? If not, a simpler implementation would simply spill all callee-saved registers in eh.return functions. This is essentially the workaround FreeBSD is using now by inserting inline assembly.

Yes, it is important not to restore those registers on non-eh.return 
epilogues, since restoring those registers might destroy return value of 
function on those paths (e.g. X86 uses eax and edx registers for 
exception information, and restoring eax would destroy return value set 
before epilogue).

So considering previous point, workaround used in FreeBSD is also 
flawed, since it is trashing return values on non-eh.return epilogues :)

> When all the epilogues are identical, they are tail-merged, so the generated code should be a bit smaller.

Non-eh.return and eh.return epilogues would be different regardless, 
because eh.return epilogue returns to a different call frame and setting 
this up will make epilogue different.

Pasi



More information about the llvm-commits mailing list