[llvm-commits] Win64 pseudo instruction patch

Anton Korobeynikov anton at korobeynikov.info
Fri Aug 13 02:35:05 PDT 2010


Hello, Cameron

> Attached is a patch which fixes some more of the Win64 ABI code gen.  Added support for the Windows 64 pseudo instructions like WINTAILJMPd64 and WINCALL64pcrel32.
>
> Also, updated a little bit of the coff-dump.py tool to dump the AMD64 relocations.  Updated COFF.h to list the AMD64 relocations.
>
> Still a bit more to do before Win64 COFFs work...
Please next time submit unrelated changes (e.g. MC changes vs tail
call stuff changes) as separate patches for the sake of easier review.

>+  bool AfterFPPop = Opc == X86::TAILJMPm64 || Opc == X86::TAILJMPm ||
>+                    Opc == X86::WINTAILJMPm64;
Is it possible to factor out the predicates of such sort into some
external predicate function? Something like "IsTAILJUMPMemOpcode()" or
whatever?

>-  } else if (Subtarget->isTargetWin64()) {
>-    // We need to always allocate 32 bytes as register spill area.
>-    // FIXME: We might reuse these 32 bytes for leaf functions.
>-    StackSize += 32;
>-    MFI->setStackSize(StackSize);
>   }
As I already mentioned, this part is invalid. Consider the following
case: you have two functions A and B with A calling B. B does regs
dump into register save area. Since you haven't allocated the space on
stack for register save area then B will clobber 16 bytes on local
frame of A. This is definitely not what you will want.

>-             RetOpcode == X86::TCRETURNmi64) {
>-    bool isMem = RetOpcode == X86::TCRETURNmi || RetOpcode == X86::TCRETURNmi64;
>+             RetOpcode == X86::TCRETURNmi64 ||
>+             RetOpcode == X86::WINTCRETURNri64 || RetOpcode == X86::WINTCRETURNdi64 ||
>+             RetOpcode == X86::WINTCRETURNmi64) {
>+    bool isMem = RetOpcode == X86::TCRETURNmi || RetOpcode == X86::TCRETURNmi64 ||
>+                 RetOpcode == X86::WINTCRETURNmi64;
Same as above.

> +      if (RetOpcode == X86::TCRETURNdi)
> +        Opcode = X86::TAILJMPd;
> +      else
> +        Opcode = (IsWin64 ? X86::WINTAILJMPd64 : X86::TAILJMPd64);
Also deserves some helper for such mapping? E.g. "TailCallIMapImmOpcode" ?

-- 
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University




More information about the llvm-commits mailing list