]> granicus.if.org Git - llvm/commitdiff
[Statepoints] Fix overalignment of loads in no-realign-stack functions
authorPhilip Reames <listmail@philipreames.com>
Fri, 2 Aug 2019 20:17:37 +0000 (20:17 +0000)
committerPhilip Reames <listmail@philipreames.com>
Fri, 2 Aug 2019 20:17:37 +0000 (20:17 +0000)
This really should have been part of 366765.  For some reason, I forgot to handle the corresponding load side, and the readable test cases (using deopt vs statepoints) turned out to be overly reduced.  Oops.

As seen in the test change, the problem was that we were using a load with alignment expectations rather than the unaligned variant when the stack alignment was less than that prefered type alignment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@367718 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/StatepointLowering.cpp
test/CodeGen/X86/statepoint-no-realign-stack.ll

index beacabe0c20c9f2b829b24ea854eb3fe9fcfbbe9..fad98b6f50dc182cfe0c7219d1c8268c4e6386a2 100644 (file)
@@ -1016,20 +1016,27 @@ void SelectionDAGBuilder::visitGCRelocate(const GCRelocateInst &Relocate) {
     return;
   }
 
-  SDValue SpillSlot =
-    DAG.getTargetFrameIndex(*DerivedPtrLocation, getFrameIndexTy());
+  unsigned Index = *DerivedPtrLocation;
+  SDValue SpillSlot = DAG.getTargetFrameIndex(Index, getFrameIndexTy());
 
   // Note: We know all of these reloads are independent, but don't bother to
   // exploit that chain wise.  DAGCombine will happily do so as needed, so
   // doing it here would be a small compile time win at most.
   SDValue Chain = getRoot();
 
-  SDValue SpillLoad =
-      DAG.getLoad(DAG.getTargetLoweringInfo().getValueType(DAG.getDataLayout(),
-                                                           Relocate.getType()),
-                  getCurSDLoc(), Chain, SpillSlot,
-                  MachinePointerInfo::getFixedStack(DAG.getMachineFunction(),
-                                                    *DerivedPtrLocation));
+  auto &MF = DAG.getMachineFunction();
+  auto &MFI = MF.getFrameInfo();
+  auto PtrInfo = MachinePointerInfo::getFixedStack(MF, Index);
+  auto *LoadMMO =
+    MF.getMachineMemOperand(PtrInfo, MachineMemOperand::MOLoad, 
+                            MFI.getObjectSize(Index),
+                            MFI.getObjectAlignment(Index));
+
+  auto LoadVT = DAG.getTargetLoweringInfo().getValueType(DAG.getDataLayout(),
+                                                         Relocate.getType());
+
+  SDValue SpillLoad = DAG.getLoad(LoadVT, getCurSDLoc(), Chain,
+                                  SpillSlot, LoadMMO);
 
   DAG.setRoot(SpillLoad.getValue(1));
 
index 0a1c244fde35652f0656c23719cfaf8256b3d59f..40e721bfa80f39cb0fd6d150ee80e0a15acd1da8 100644 (file)
@@ -90,7 +90,7 @@ define <4 x i8 addrspace(1)*> @spillfill_no_realign(<4 x i8 addrspace(1)*> %obj)
 ; CHECK-NEXT:    vzeroupper
 ; CHECK-NEXT:    callq do_safepoint
 ; CHECK-NEXT:  .Ltmp3:
-; CHECK-NEXT:    vmovaps (%rsp), %ymm0
+; CHECK-NEXT:    vmovups (%rsp), %ymm0
 ; CHECK-NEXT:    addq $40, %rsp
 ; CHECK-NEXT:    .cfi_def_cfa_offset 8
 ; CHECK-NEXT:    retq