Skip to content

Commit 511be2a

Browse files
committed
[Statepoints] Fix overalignment of loads in no-realign-stack functions
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. llvm-svn: 367718
1 parent 196931a commit 511be2a

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,20 +1016,27 @@ void SelectionDAGBuilder::visitGCRelocate(const GCRelocateInst &Relocate) {
10161016
return;
10171017
}
10181018

1019-
SDValue SpillSlot =
1020-
DAG.getTargetFrameIndex(*DerivedPtrLocation, getFrameIndexTy());
1019+
unsigned Index = *DerivedPtrLocation;
1020+
SDValue SpillSlot = DAG.getTargetFrameIndex(Index, getFrameIndexTy());
10211021

10221022
// Note: We know all of these reloads are independent, but don't bother to
10231023
// exploit that chain wise. DAGCombine will happily do so as needed, so
10241024
// doing it here would be a small compile time win at most.
10251025
SDValue Chain = getRoot();
10261026

1027-
SDValue SpillLoad =
1028-
DAG.getLoad(DAG.getTargetLoweringInfo().getValueType(DAG.getDataLayout(),
1029-
Relocate.getType()),
1030-
getCurSDLoc(), Chain, SpillSlot,
1031-
MachinePointerInfo::getFixedStack(DAG.getMachineFunction(),
1032-
*DerivedPtrLocation));
1027+
auto &MF = DAG.getMachineFunction();
1028+
auto &MFI = MF.getFrameInfo();
1029+
auto PtrInfo = MachinePointerInfo::getFixedStack(MF, Index);
1030+
auto *LoadMMO =
1031+
MF.getMachineMemOperand(PtrInfo, MachineMemOperand::MOLoad,
1032+
MFI.getObjectSize(Index),
1033+
MFI.getObjectAlignment(Index));
1034+
1035+
auto LoadVT = DAG.getTargetLoweringInfo().getValueType(DAG.getDataLayout(),
1036+
Relocate.getType());
1037+
1038+
SDValue SpillLoad = DAG.getLoad(LoadVT, getCurSDLoc(), Chain,
1039+
SpillSlot, LoadMMO);
10331040

10341041
DAG.setRoot(SpillLoad.getValue(1));
10351042

llvm/test/CodeGen/X86/statepoint-no-realign-stack.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ define <4 x i8 addrspace(1)*> @spillfill_no_realign(<4 x i8 addrspace(1)*> %obj)
9090
; CHECK-NEXT: vzeroupper
9191
; CHECK-NEXT: callq do_safepoint
9292
; CHECK-NEXT: .Ltmp3:
93-
; CHECK-NEXT: vmovaps (%rsp), %ymm0
93+
; CHECK-NEXT: vmovups (%rsp), %ymm0
9494
; CHECK-NEXT: addq $40, %rsp
9595
; CHECK-NEXT: .cfi_def_cfa_offset 8
9696
; CHECK-NEXT: retq

0 commit comments

Comments
 (0)