llvm.org GIT mirror llvm / 81b3ceb
[Statepoints] Split the calling convention and statepoint flags operand to STATEPOINT into two separate operands. Differential Revision: http://reviews.llvm.org/D9623 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237166 91177308-0d34-0410-b5e6-96231b3b80d8 Pat Gavlin 4 years ago
5 changed file(s) with 54 addition(s) and 29 deletion(s). Raw diff Collapse all Expand all
482482
483483 Each statepoint generates the following Locations:
484484
485 * Constant which describes the calling convention of the call target. This
486 constant is a valid :ref:`calling convention identifier ` for
487 the version of LLVM used to generate the stackmap. No additional compatibility
488 guarantees are made for this constant over what LLVM provides elsewhere w.r.t.
489 these identifiers.
490 * Constant which describes the flags passed to the statepoint intrinsic
485491 * Constant which describes number of following deopt *Locations* (not
486492 operands)
487493 * Variable number of Locations, one for each deopt parameter listed in
8585 ///
8686 /// Statepoint operands take the form:
8787 /// , , [call arguments],
88 /// , <flags>,
88 /// , <calling convention>,
89 /// , ,
8990 /// , , [other args],
9091 /// [gc values]
9192 class StatepointOpers {
9293 private:
94 // These values are aboolute offsets into the operands of the statepoint
95 // instruction.
9396 enum {
9497 NCallArgsPos = 0,
9598 CallTargetPos = 1
9699 };
97100
101 // These values are relative offests from the start of the statepoint meta
102 // arguments (i.e. the end of the call arguments).
103 enum {
104 CCOffset = 1,
105 FlagsOffset = 3,
106 NumVMSArgsOffset = 5
107 };
108
98109 public:
99110 explicit StatepointOpers(const MachineInstr *MI):
100111 MI(MI) { }
101112
102113 /// Get starting index of non call related arguments
103 /// (statepoint flags, vm state and gc state).
114 /// (calling convention, statepoint flags, vm state and gc state).
104115 unsigned getVarIdx() const {
105116 return MI->getOperand(NCallArgsPos).getImm() + 2;
106117 }
108119 /// Returns the index of the operand containing the number of non-gc non-call
109120 /// arguments.
110121 unsigned getNumVMSArgsIdx() const {
111 return getVarIdx() + 3;
122 return getVarIdx() + NumVMSArgsOffset;
112123 }
113124
114125 /// Returns the number of non-gc non-call arguments attached to the
3636 STATISTIC(NumOfStatepoints, "Number of statepoint nodes encountered");
3737 STATISTIC(StatepointMaxSlotsRequired,
3838 "Maximum number of stack slots required for a singe statepoint");
39
40 static void pushStackMapConstant(SmallVectorImpl& Ops,
41 SelectionDAGBuilder &Builder, uint64_t Value) {
42 SDLoc L = Builder.getCurSDLoc();
43 Ops.push_back(Builder.DAG.getTargetConstant(StackMaps::ConstantOp, L,
44 MVT::i64));
45 Ops.push_back(Builder.DAG.getTargetConstant(Value, L, MVT::i64));
46 }
3947
4048 void StatepointLoweringState::startNewStatepoint(SelectionDAGBuilder &Builder) {
4149 // Consistency check
385393 // such in the stackmap. This is required so that the consumer can
386394 // parse any internal format to the deopt state. It also handles null
387395 // pointers and other constant pointers in GC states
388 Ops.push_back(Builder.DAG.getTargetConstant(StackMaps::ConstantOp,
389 Builder.getCurSDLoc(),
390 MVT::i64));
391 Ops.push_back(Builder.DAG.getTargetConstant(C->getSExtValue(),
392 Builder.getCurSDLoc(),
393 MVT::i64));
396 pushStackMapConstant(Ops, Builder, C->getSExtValue());
394397 } else if (FrameIndexSDNode *FI = dyn_cast(Incoming)) {
395398 // This handles allocas as arguments to the statepoint (this is only
396399 // really meaningful for a deopt value. For GC, we'd be trying to
484487 // lowered. Note that this is the number of *Values* not the
485488 // number of SDValues required to lower them.
486489 const int NumVMSArgs = StatepointSite.getNumTotalVMSArgs();
487 Ops.push_back( Builder.DAG.getTargetConstant(StackMaps::ConstantOp,
488 Builder.getCurSDLoc(),
489 MVT::i64));
490 Ops.push_back(Builder.DAG.getTargetConstant(NumVMSArgs, Builder.getCurSDLoc(),
491 MVT::i64));
490 pushStackMapConstant(Ops, Builder, NumVMSArgs);
492491
493492 assert(NumVMSArgs + 1 == std::distance(StatepointSite.vm_state_begin(),
494493 StatepointSite.vm_state_end()));
661660 RegMaskIt = CallNode->op_end() - 1;
662661 Ops.insert(Ops.end(), CallNode->op_begin() + 2, RegMaskIt);
663662
664 // Add a leading constant argument with the Flags and the calling convention
665 // masked together
666 CallingConv::ID CallConv = CS.getCallingConv();
663 // Add a constant argument for the calling convention
664 pushStackMapConstant(Ops, *this, CS.getCallingConv());
665
666 // Add a constant argument for the flags
667667 uint64_t Flags = cast(CS.getArgument(2))->getZExtValue();
668668 assert(
669669 ((Flags & ~(uint64_t)StatepointFlags::MaskAll) == 0)
670670 && "unknown flag used");
671 const int Shift = 1;
672 static_assert(
673 ((~(uint64_t)0 << Shift) & (uint64_t)StatepointFlags::MaskAll) == 0,
674 "shift width too small");
675 Ops.push_back(DAG.getTargetConstant(StackMaps::ConstantOp, getCurSDLoc(),
676 MVT::i64));
677 Ops.push_back(DAG.getTargetConstant(Flags | ((unsigned)CallConv << Shift),
678 getCurSDLoc(), MVT::i64));
671 pushStackMapConstant(Ops, *this, Flags);
679672
680673 // Insert all vmstate and gcstate arguments
681674 Ops.insert(Ops.end(), LoweredMetaArgs.begin(), LoweredMetaArgs.end());
7171 ; The GC one
7272 ; CHECK: .long .Ltmp1-test
7373 ; CHECK: .short 0
74 ; CHECK: .short 3
74 ; CHECK: .short 4
75 ; SmallConstant (0)
76 ; CHECK: .byte 4
77 ; CHECK: .byte 8
78 ; CHECK: .short 0
79 ; CHECK: .long 0
7580 ; SmallConstant (0)
7681 ; CHECK: .byte 4
7782 ; CHECK: .byte 8
95100 ; The Deopt one
96101 ; CHECK: .long .Ltmp3-test2
97102 ; CHECK: .short 0
98 ; CHECK: .short 3
103 ; CHECK: .short 4
104 ; SmallConstant (0)
105 ; CHECK: .byte 4
106 ; CHECK: .byte 8
107 ; CHECK: .short 0
108 ; CHECK: .long 0
99109 ; SmallConstant (0)
100110 ; CHECK: .byte 4
101111 ; CHECK: .byte 8
9696 ; Constant arguments
9797 ; CHECK: .long .Ltmp1-test
9898 ; CHECK: .short 0
99 ; CHECK: .short 10
99 ; CHECK: .short 11
100 ; SmallConstant (0)
101 ; CHECK: .byte 4
102 ; CHECK: .byte 8
103 ; CHECK: .short 0
104 ; CHECK: .long 0
100105 ; SmallConstant (0)
101106 ; CHECK: .byte 4
102107 ; CHECK: .byte 8
165170 ; Constant arguments
166171 ; CHECK: .long .Ltmp3-test_derived_arg
167172 ; CHECK: .short 0
168 ; CHECK: .short 10
173 ; CHECK: .short 11
169174 ; SmallConstant (0)
170175 ; CHECK: .byte 4
171176 ; CHECK: .byte 8