Use a pointer type for target frame indices during statepoint lowering

Summary:
The type of the target frame index is intptr, not the type of the value we're
going to store into it.  Without this change we crash in the attached test case
when trying to type-legalize a TargetFrameIndex.

Patchpoint lowering types the target frame index as intptr as well.

Reviewers: reames, bogner, arsenm

Subscribers: arsenm, mcrosier, llvm-commits

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

llvm-svn: 301566
This commit is contained in:
Sanjoy Das 2017-04-27 17:17:16 +00:00
parent eaaba2b59e
commit 40c32dd9a0
3 changed files with 58 additions and 8 deletions

View File

@ -777,6 +777,11 @@ public:
bool VarArgDisallowed,
bool ForceVoidReturnTy);
/// Returns the type of FrameIndex and TargetFrameIndex nodes.
MVT getFrameIndexTy() {
return DAG.getTargetLoweringInfo().getFrameIndexTy(DAG.getDataLayout());
}
private:
// Terminator instructions.
void visitRet(const ReturnInst &I);

View File

@ -242,7 +242,8 @@ static void reservePreviousStackSlotForValue(const Value *IncomingValue,
// Cache this slot so we find it when going through the normal
// assignment loop.
SDValue Loc = Builder.DAG.getTargetFrameIndex(*Index, Incoming.getValueType());
SDValue Loc =
Builder.DAG.getTargetFrameIndex(*Index, Builder.getFrameIndexTy());
Builder.StatepointLowering.setLocation(Incoming, Loc);
}
@ -343,7 +344,7 @@ spillIncomingStatepointValue(SDValue Incoming, SDValue Chain,
Builder);
int Index = cast<FrameIndexSDNode>(Loc)->getIndex();
// We use TargetFrameIndex so that isel will not select it into LEA
Loc = Builder.DAG.getTargetFrameIndex(Index, Incoming.getValueType());
Loc = Builder.DAG.getTargetFrameIndex(Index, Builder.getFrameIndexTy());
// TODO: We can create TokenFactor node instead of
// chaining stores one after another, this may allow
@ -391,8 +392,10 @@ static void lowerIncomingStatepointValue(SDValue Incoming, bool LiveInOnly,
// This handles allocas as arguments to the statepoint (this is only
// really meaningful for a deopt value. For GC, we'd be trying to
// relocate the address of the alloca itself?)
assert(Incoming.getValueType() == Builder.getFrameIndexTy() &&
"Incoming value is a frame index!");
Ops.push_back(Builder.DAG.getTargetFrameIndex(FI->getIndex(),
Incoming.getValueType()));
Builder.getFrameIndexTy()));
} else if (LiveInOnly) {
// If this value is live in (not live-on-return, or live-through), we can
// treat it the same way patchpoint treats it's "live in" values. We'll
@ -527,8 +530,10 @@ lowerStatepointMetaArgs(SmallVectorImpl<SDValue> &Ops,
SDValue Incoming = Builder.getValue(V);
if (FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(Incoming)) {
// This handles allocas as arguments to the statepoint
assert(Incoming.getValueType() == Builder.getFrameIndexTy() &&
"Incoming value is a frame index!");
Ops.push_back(Builder.DAG.getTargetFrameIndex(FI->getIndex(),
Incoming.getValueType()));
Builder.getFrameIndexTy()));
}
}
@ -949,8 +954,8 @@ void SelectionDAGBuilder::visitGCRelocate(const GCRelocateInst &Relocate) {
return;
}
SDValue SpillSlot = DAG.getTargetFrameIndex(*DerivedPtrLocation,
SD.getValueType());
SDValue SpillSlot =
DAG.getTargetFrameIndex(*DerivedPtrLocation, getFrameIndexTy());
// Be conservative: flush all pending loads
// TODO: Probably we can be less restrictive on this,
@ -958,7 +963,9 @@ void SelectionDAGBuilder::visitGCRelocate(const GCRelocateInst &Relocate) {
SDValue Chain = getRoot();
SDValue SpillLoad =
DAG.getLoad(SpillSlot.getValueType(), getCurSDLoc(), Chain, SpillSlot,
DAG.getLoad(DAG.getTargetLoweringInfo().getValueType(DAG.getDataLayout(),
Relocate.getType()),
getCurSDLoc(), Chain, SpillSlot,
MachinePointerInfo::getFixedStack(DAG.getMachineFunction(),
*DerivedPtrLocation));

View File

@ -50,7 +50,6 @@ target triple = "x86_64-apple-macosx10.11.0"
; STACKMAPS-NEXT: Stack Maps: Loc 3: Constant 55 [encoding: .byte 4, .byte 8, .short 0, .int 55]
; STACKMAPS-NEXT: Stack Maps: has 0 live-out registers
declare i32 @callee_0()
declare i32 @callee_1(i32)
declare i32 @callee_vararg(...)
@ -159,3 +158,42 @@ define void @f_0(i64 %n) {
}
declare void @g_0(i64* %vl)
define void @vector_deopt_bundle(<32 x i64 addrspace(1)*> %val) {
; CHECK-LABEL: _vector_deopt_bundle:
; CHECK: movaps 16(%rbp), %xmm8
; CHECK-NEXT: movaps 32(%rbp), %xmm9
; CHECK-NEXT: movaps 48(%rbp), %xmm10
; CHECK-NEXT: movaps 64(%rbp), %xmm11
; CHECK-NEXT: movaps 80(%rbp), %xmm12
; CHECK-NEXT: movaps 96(%rbp), %xmm13
; CHECK-NEXT: movaps 112(%rbp), %xmm14
; CHECK-NEXT: movaps 128(%rbp), %xmm15
; CHECK-NEXT: movaps %xmm15, 240(%rsp)
; CHECK-NEXT: movaps %xmm14, 224(%rsp)
; CHECK-NEXT: movaps %xmm13, 208(%rsp)
; CHECK-NEXT: movaps %xmm12, 192(%rsp)
; CHECK-NEXT: movaps %xmm11, 176(%rsp)
; CHECK-NEXT: movaps %xmm10, 160(%rsp)
; CHECK-NEXT: movaps %xmm9, 144(%rsp)
; CHECK-NEXT: movaps %xmm8, 128(%rsp)
; CHECK-NEXT: movaps %xmm7, 112(%rsp)
; CHECK-NEXT: movaps %xmm6, 96(%rsp)
; CHECK-NEXT: movaps %xmm5, 80(%rsp)
; CHECK-NEXT: movaps %xmm4, 64(%rsp)
; CHECK-NEXT: movaps %xmm3, 48(%rsp)
; CHECK-NEXT: movaps %xmm2, 32(%rsp)
; CHECK-NEXT: movaps %xmm1, 16(%rsp)
; CHECK-NEXT: movaps %xmm0, (%rsp)
call void @unknown() [ "deopt"(<32 x i64 addrspace(1)*> %val) ]
ret void
; STACKMAPS: Stack Maps: callsite 2882400015
; STACKMAPS-NEXT: Stack Maps: has 4 locations
; STACKMAPS-NEXT: Stack Maps: Loc 0: Constant 0 [encoding: .byte 4, .byte 8, .short 0, .int 0]
; STACKMAPS-NEXT: Stack Maps: Loc 1: Constant 0 [encoding: .byte 4, .byte 8, .short 0, .int 0]
; STACKMAPS-NEXT: Stack Maps: Loc 2: Constant 1 [encoding: .byte 4, .byte 8, .short 0, .int 1]
; STACKMAPS-NEXT: Stack Maps: Loc 3: Indirect 7+0 [encoding: .byte 3, .byte 256, .short 7, .int 0]
; STACKMAPS-NEXT: Stack Maps: has 0 live-out registers
}
declare void @unknown()