[PATCH] D15054: [X86] Better support for the MCU psABI

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 27 20:15:16 PST 2015

rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

Seems reasonable.

Comment at: lib/Target/X86/X86CallingConv.h:46
@@ -44,1 +45,3 @@
+inline bool CC_X86_32_MCUInReg(unsigned &ValNo, MVT &ValVT,
+                                         MVT &LocVT,
Given that it's what ARM does, let's go with it.

Comment at: lib/Target/X86/X86CallingConv.td:603-604
@@ +602,4 @@
+  // The 'nest' parameter, if any, is passed in ECX.
+  CCIfNest<CCAssignToReg<[ECX]>>,
ECX is an allocatable argument register, so this will not implement 'nest' properly. Either ignoring 'nest' completely or giving a fatal error seems like better behavior than having code that looks like it's trying to implement something.

Comment at: lib/Target/X86/X86FastISel.cpp:1105
@@ -1104,4 +1104,3 @@
   // and into %rax. We also do the same with %eax for Win32.
-  if (F.hasStructRetAttr() &&
-      (Subtarget->is64Bit() || Subtarget->isTargetKnownWindowsMSVC())) {
+  if (F.hasStructRetAttr()) {
     unsigned Reg = X86MFInfo->getSRetReturnReg();
Aha, I changed SDag to do the right thing here, but not fastisel. Oops.

Comment at: test/CodeGen/X86/mcu-abi.ll:64-66
@@ +63,5 @@
+; CHECK-NEXT: movl    $48, %ecx
+; CHECK-NEXT: calll   memcpy
+; CHECK-NEXT: movl    %esi, %eax
+; CHECK-NEXT: popl    %esi
+; CHECK-NOT:  retl $4
Idle thought: We should teach LLVM that memcpy returns its first argument, so that we don't have to spill in this kind of situation. :)


More information about the llvm-commits mailing list