[llvm] r358817 - [X86] Disable argument copy elision for arguments passed via pointers

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 20 08:26:44 PDT 2019


Author: ctopper
Date: Sat Apr 20 08:26:44 2019
New Revision: 358817

URL: http://llvm.org/viewvc/llvm-project?rev=358817&view=rev
Log:
[X86] Disable argument copy elision for arguments passed via pointers

Summary:
If you pass two 1024 bit vectors in IR with AVX2 on Windows 64. Both vectors will be split in four 256 bit pieces. The four pieces of the first argument will be passed indirectly using 4 gprs. The second argument will get passed via pointers in memory.

The PartOffsets stored for the second argument are all in terms of its original 1024 bit size. So the PartOffsets for each piece are 32 bytes apart. So if we consider it for copy elision we'll only load an 8 byte pointer, but we'll move the address 32 bytes. The stack object size we create for the first part is probably wrong too.

This issue was encountered by ISPC. I'm working on getting a reduce test case, but wanted to go ahead and get feedback on the fix.

Reviewers: rnk

Reviewed By: rnk

Subscribers: dbabokin, llvm-commits, hiraditya

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60801

Modified:
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
    llvm/trunk/test/CodeGen/X86/arg-copy-elide-win64.ll

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=358817&r1=358816&r2=358817&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sat Apr 20 08:26:44 2019
@@ -3011,7 +3011,11 @@ X86TargetLowering::LowerMemArgument(SDVa
   }
 
   // This is an argument in memory. We might be able to perform copy elision.
-  if (Flags.isCopyElisionCandidate()) {
+  // If the argument is passed directly in memory without any extension, then we
+  // can perform copy elision. Large vector types, for example, may be passed
+  // indirectly by pointer.
+  if (Flags.isCopyElisionCandidate() &&
+      VA.getLocInfo() != CCValAssign::Indirect && !ExtendedInMem) {
     EVT ArgVT = Ins[i].ArgVT;
     SDValue PartAddr;
     if (Ins[i].PartOffset == 0) {

Modified: llvm/trunk/test/CodeGen/X86/arg-copy-elide-win64.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/arg-copy-elide-win64.ll?rev=358817&r1=358816&r2=358817&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/arg-copy-elide-win64.ll (original)
+++ llvm/trunk/test/CodeGen/X86/arg-copy-elide-win64.ll Sat Apr 20 08:26:44 2019
@@ -13,12 +13,12 @@ define void @baz(<16 x double> %arg, <16
 ; CHECK-NEXT:    vmovaps %xmm6, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
 ; CHECK-NEXT:    andq $-128, %rsp
 ; CHECK-NEXT:    movq 288(%rbp), %rax
-; CHECK-NEXT:    movq 320(%rbp), %r10
 ; CHECK-NEXT:    vmovaps (%rax), %ymm0
-; CHECK-NEXT:    vmovaps (%r10), %ymm1
-; CHECK-NEXT:    movq 352(%rbp), %rax
+; CHECK-NEXT:    movq 296(%rbp), %rax
+; CHECK-NEXT:    vmovaps (%rax), %ymm1
+; CHECK-NEXT:    movq 304(%rbp), %rax
 ; CHECK-NEXT:    vmovaps (%rax), %ymm2
-; CHECK-NEXT:    movq 384(%rbp), %rax
+; CHECK-NEXT:    movq 312(%rbp), %rax
 ; CHECK-NEXT:    vmovaps (%rax), %ymm3
 ; CHECK-NEXT:    vmovaps (%rcx), %ymm4
 ; CHECK-NEXT:    vmovaps (%rdx), %ymm5




More information about the llvm-commits mailing list