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/include | |
| 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/include')
| -rw-r--r-- | llvm/include/llvm/CodeGen/StackMaps.h | 26 | ||||
| -rw-r--r-- | llvm/include/llvm/IR/IRBuilder.h | 12 | ||||
| -rw-r--r-- | llvm/include/llvm/IR/Intrinsics.td | 3 | ||||
| -rw-r--r-- | llvm/include/llvm/IR/Statepoint.h | 27 |
4 files changed, 42 insertions, 26 deletions
diff --git a/llvm/include/llvm/CodeGen/StackMaps.h b/llvm/include/llvm/CodeGen/StackMaps.h index c6d097b916f..46a773f74aa 100644 --- a/llvm/include/llvm/CodeGen/StackMaps.h +++ b/llvm/include/llvm/CodeGen/StackMaps.h @@ -85,8 +85,8 @@ public: /// MI-level Statepoint operands /// /// Statepoint operands take the form: -/// <num call arguments>, <call target>, [call arguments], -/// <StackMaps::ConstantOp>, <calling convention>, +/// <id>, <num patch bytes >, <num call arguments>, <call target>, +/// [call arguments], <StackMaps::ConstantOp>, <calling convention>, /// <StackMaps::ConstantOp>, <statepoint flags>, /// <StackMaps::ConstantOp>, <num other args>, [other args], /// [gc values] @@ -94,10 +94,7 @@ class StatepointOpers { private: // These values are aboolute offsets into the operands of the statepoint // instruction. - enum { - NCallArgsPos = 0, - CallTargetPos = 1 - }; + enum { IDPos, NBytesPos, NCallArgsPos, CallTargetPos, MetaEnd }; // These values are relative offests from the start of the statepoint meta // arguments (i.e. the end of the call arguments). @@ -114,20 +111,15 @@ public: /// Get starting index of non call related arguments /// (calling convention, statepoint flags, vm state and gc state). unsigned getVarIdx() const { - return MI->getOperand(NCallArgsPos).getImm() + 2; + return MI->getOperand(NCallArgsPos).getImm() + MetaEnd; } - /// Returns the index of the operand containing the number of non-gc non-call - /// arguments. - unsigned getNumVMSArgsIdx() const { - return getVarIdx() + NumVMSArgsOffset; - } + /// Return the ID for the given statepoint. + uint64_t getID() const { return MI->getOperand(IDPos).getImm(); } - /// Returns the number of non-gc non-call arguments attached to the - /// statepoint. Note that this is the number of arguments, not the number of - /// operands required to represent those arguments. - unsigned getNumVMSArgs() const { - return MI->getOperand(getNumVMSArgsIdx()).getImm(); + /// Return the number of patchable bytes the given statepoint should emit. + uint32_t getNumPatchBytes() const { + return MI->getOperand(NBytesPos).getImm(); } /// Returns the target of the underlying call. diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h index 7224496c204..e78c63c51d7 100644 --- a/llvm/include/llvm/IR/IRBuilder.h +++ b/llvm/include/llvm/IR/IRBuilder.h @@ -447,7 +447,8 @@ public: /// \brief Create a call to the experimental.gc.statepoint intrinsic to /// start a new statepoint sequence. - CallInst *CreateGCStatepointCall(Value *ActualCallee, + CallInst *CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes, + Value *ActualCallee, ArrayRef<Value *> CallArgs, ArrayRef<Value *> DeoptArgs, ArrayRef<Value *> GCArgs, @@ -456,7 +457,8 @@ public: // \brief Conveninence function for the common case when CallArgs are filled // in using makeArrayRef(CS.arg_begin(), CS.arg_end()); Use needs to be // .get()'ed to get the Value pointer. - CallInst *CreateGCStatepointCall(Value *ActualCallee, ArrayRef<Use> CallArgs, + CallInst *CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes, + Value *ActualCallee, ArrayRef<Use> CallArgs, ArrayRef<Value *> DeoptArgs, ArrayRef<Value *> GCArgs, const Twine &Name = ""); @@ -464,7 +466,8 @@ public: /// brief Create an invoke to the experimental.gc.statepoint intrinsic to /// start a new statepoint sequence. InvokeInst * - CreateGCStatepointInvoke(Value *ActualInvokee, BasicBlock *NormalDest, + CreateGCStatepointInvoke(uint64_t ID, uint32_t NumPatchBytes, + Value *ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef<Value *> InvokeArgs, ArrayRef<Value *> DeoptArgs, ArrayRef<Value *> GCArgs, const Twine &Name = ""); @@ -473,7 +476,8 @@ public: // makeArrayRef(CS.arg_begin(), CS.arg_end()); Use needs to be .get()'ed to // get the Value *. InvokeInst * - CreateGCStatepointInvoke(Value *ActualInvokee, BasicBlock *NormalDest, + CreateGCStatepointInvoke(uint64_t ID, uint32_t NumPatchBytes, + Value *ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef<Use> InvokeArgs, ArrayRef<Value *> DeoptArgs, ArrayRef<Value *> GCArgs, const Twine &Name = ""); diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td index d778fbede0b..1442b64762f 100644 --- a/llvm/include/llvm/IR/Intrinsics.td +++ b/llvm/include/llvm/IR/Intrinsics.td @@ -528,7 +528,8 @@ def int_experimental_patchpoint_i64 : Intrinsic<[llvm_i64_ty], // These are documented in docs/Statepoint.rst def int_experimental_gc_statepoint : Intrinsic<[llvm_i32_ty], - [llvm_anyptr_ty, llvm_i32_ty, + [llvm_i64_ty, llvm_i32_ty, + llvm_anyptr_ty, llvm_i32_ty, llvm_i32_ty, llvm_vararg_ty]>; def int_experimental_gc_result : Intrinsic<[llvm_any_ty], [llvm_i32_ty]>; diff --git a/llvm/include/llvm/IR/Statepoint.h b/llvm/include/llvm/IR/Statepoint.h index 57ae90f6d15..cd09618e3ee 100644 --- a/llvm/include/llvm/IR/Statepoint.h +++ b/llvm/include/llvm/IR/Statepoint.h @@ -74,16 +74,35 @@ public: typedef typename CallSiteTy::arg_iterator arg_iterator; enum { - ActualCalleePos = 0, - NumCallArgsPos = 1, - CallArgsBeginPos = 3, + IDPos = 0, + NumPatchBytesPos = 1, + ActualCalleePos = 2, + NumCallArgsPos = 3, + FlagsPos = 4, + CallArgsBeginPos = 5, }; /// Return the underlying CallSite. CallSiteTy getCallSite() { return StatepointCS; } uint64_t getFlags() const { - return cast<ConstantInt>(StatepointCS.getArgument(2))->getZExtValue(); + return cast<ConstantInt>(StatepointCS.getArgument(FlagsPos)) + ->getZExtValue(); + } + + /// Return the ID associated with this statepoint. + uint64_t getID() { + const Value *IDVal = StatepointCS.getArgument(IDPos); + return cast<ConstantInt>(IDVal)->getZExtValue(); + } + + /// Return the number of patchable bytes associated with this statepoint. + uint32_t getNumPatchBytes() { + const Value *NumPatchBytesVal = StatepointCS.getArgument(NumPatchBytesPos); + uint64_t NumPatchBytes = + cast<ConstantInt>(NumPatchBytesVal)->getZExtValue(); + assert(isInt<32>(NumPatchBytes) && "should fit in 32 bits!"); + return NumPatchBytes; } /// Return the value actually being called or invoked. |

