diff options
author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-05-12 23:52:24 +0000 |
---|---|---|
committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-05-12 23:52:24 +0000 |
commit | a1d39ba940498283f16a3b83507d2e68e269e270 (patch) | |
tree | ac2e0bc23727ab8bbd02d4d9a9b4a3693e48c619 /llvm/lib/CodeGen | |
parent | 89fe570958f8b82df9a9c3b4c251ecba9753272a (diff) | |
download | bcm5719-llvm-a1d39ba940498283f16a3b83507d2e68e269e270.tar.gz bcm5719-llvm-a1d39ba940498283f16a3b83507d2e68e269e270.zip |
[Statepoints] Support for "patchable" statepoints.
Summary:
This change adds two new parameters to the statepoint intrinsic, `i64 id`
and `i32 num_patch_bytes`. `id` gets propagated to the ID field
in the generated StackMap section. If the `num_patch_bytes` is
non-zero then the statepoint is lowered to `num_patch_bytes` bytes of
nops instead of a call (the spill and reload code remains unchanged).
A non-zero `num_patch_bytes` is useful in situations where a language
runtime requires complete control over how a call is lowered.
This change brings statepoints one step closer to patchpoints. With
some additional work (that is not part of this patch) it should be
possible to get rid of `TargetOpcode::STATEPOINT` altogether.
PlaceSafepoints generates `statepoint` wrappers with `id` set to
`0xABCDEF00` (the old default value for the ID reported in the stackmap)
and `num_patch_bytes` set to `0`. This can be made more sophisticated
later.
Reviewers: reames, pgavlin, swaroop.sridhar, AndyAyers
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D9546
llvm-svn: 237214
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp | 17 | ||||
-rw-r--r-- | llvm/lib/CodeGen/StackMaps.cpp | 5 |
2 files changed, 13 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp index 29f4b0ae182..7a809f4239f 100644 --- a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp @@ -583,11 +583,6 @@ void SelectionDAGBuilder::LowerStatepoint( // Construct the actual GC_TRANSITION_START, STATEPOINT, and GC_TRANSITION_END // nodes with all the appropriate arguments and return values. - // TODO: Currently, all of these operands are being marked as read/write in - // PrologEpilougeInserter.cpp, we should special case the VMState arguments - // and flags to be read-only. - SmallVector<SDValue, 40> Ops; - // Call Node: Chain, Target, {Args}, RegMask, [Glue] SDValue Chain = CallNode->getOperand(0); @@ -634,6 +629,16 @@ void SelectionDAGBuilder::LowerStatepoint( Glue = GCTransitionStart.getValue(1); } + // TODO: Currently, all of these operands are being marked as read/write in + // PrologEpilougeInserter.cpp, we should special case the VMState arguments + // and flags to be read-only. + SmallVector<SDValue, 40> Ops; + + // Add the <id> and <numBytes> constants. + Ops.push_back(DAG.getTargetConstant(ISP.getID(), getCurSDLoc(), MVT::i64)); + Ops.push_back( + DAG.getTargetConstant(ISP.getNumPatchBytes(), getCurSDLoc(), MVT::i32)); + // Calculate and push starting position of vmstate arguments // Get number of arguments incoming directly into call node unsigned NumCallRegArgs = @@ -657,7 +662,7 @@ void SelectionDAGBuilder::LowerStatepoint( pushStackMapConstant(Ops, *this, CS.getCallingConv()); // Add a constant argument for the flags - uint64_t Flags = cast<ConstantInt>(CS.getArgument(2))->getZExtValue(); + uint64_t Flags = ISP.getFlags(); assert( ((Flags & ~(uint64_t)StatepointFlags::MaskAll) == 0) && "unknown flag used"); diff --git a/llvm/lib/CodeGen/StackMaps.cpp b/llvm/lib/CodeGen/StackMaps.cpp index a7868329e4d..b5a961dfec1 100644 --- a/llvm/lib/CodeGen/StackMaps.cpp +++ b/llvm/lib/CodeGen/StackMaps.cpp @@ -370,9 +370,8 @@ void StackMaps::recordStatepoint(const MachineInstr &MI) { // Record all the deopt and gc operands (they're contiguous and run from the // initial index to the end of the operand list) const unsigned StartIdx = opers.getVarIdx(); - recordStackMapOpers(MI, 0xABCDEF00, - MI.operands_begin() + StartIdx, MI.operands_end(), - false); + recordStackMapOpers(MI, opers.getID(), MI.operands_begin() + StartIdx, + MI.operands_end(), false); } /// Emit the stackmap header. |