[PATCH][MC/X86_64] Implement Win64 exception handling

Kai Nacke kai.nacke at redstar.de
Fri Nov 22 09:06:47 PST 2013


Hi Nico!

On 21.11.2013 16:51, Nico Rieck wrote:
>  >+  case X86::W64ALLOCA:
>  >+    // Occurs if alloca()/call to __chkstk is used. Do nothing.
>  >+    break;
>
> This is wrong for Microsoft's __chkstk which does not adjust the stack
> pointer, so W64ALLOCA has to emit an alloc unwind instruction.

Hm. If I look at the output, then it is wrong for Mingw.


> Your test only checks Mingw's behavior but uses the wrong triple. Please
> check both x86_64-pc-win32 and x86_64-pc-mingw triples.

This is a very good point. I even forgot to enable the exception 
handling for the Mingw case.

> You already reject a few illegal prologue instructions. IMO this should
> be expanded to reject all illegal instructions with a fatal error.
> Currently these just don't emit unwind instructions. This also means
> replacing those asserts.

Again, a good point. We should not generate buggy code.

> Also, LEA instructions to adjust the stack pointer aren't handled.

My understanding is that LEA instructions to adjust the stack pointer 
are invalid in prolog code. But I recheck in MSDN.

>> A consequence of this patch is that Win64 ABI errors become more serious.
>> E.g. because of PR16779 I had to set the test avx-win64-args.ll to XFAIL.
>
> Have you planned to fix PR16779, too?

Well, only if I find a good solution. (I already tried but had no success.)

Thanks for the comments. I update the code soon.

Regards,
Kai



More information about the llvm-commits mailing list