summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2016-03-17 01:56:10 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2016-03-17 01:56:10 +0000
commit312038872df0e44d74b3009c4ac03a6ee15d2a86 (patch)
tree7c9736ebae4a8ada9a71bb7dea64a385989ada6c /llvm/lib
parentc291e1fd4fbd5c315412ac78bbd773d1c1019cc3 (diff)
downloadbcm5719-llvm-312038872df0e44d74b3009c4ac03a6ee15d2a86.tar.gz
bcm5719-llvm-312038872df0e44d74b3009c4ac03a6ee15d2a86.zip
[Statepoints] Separate out logic for statepoint directives; NFC
This splits out the logic that maps the `"statepoint-id"` attribute into the actual statepoint ID, and the `"statepoint-num-patch-bytes"` attribute into the number of patchable bytes the statpeoint is lowered into. The new home of this logic is in IR/Statepoint.cpp, and this refactoring will support similar functionality when lowering calls with deopt operand bundles in the future. llvm-svn: 263685
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/IR/Statepoint.cpp25
-rw-r--r--llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp20
2 files changed, 33 insertions, 12 deletions
diff --git a/llvm/lib/IR/Statepoint.cpp b/llvm/lib/IR/Statepoint.cpp
index e56da6beaff..13e8c6312a6 100644
--- a/llvm/lib/IR/Statepoint.cpp
+++ b/llvm/lib/IR/Statepoint.cpp
@@ -53,3 +53,28 @@ bool llvm::isGCResult(ImmutableCallSite CS) {
bool llvm::isGCResult(const Value *V) {
return isGCResult(ImmutableCallSite(V));
}
+
+bool llvm::isStatepointDirectiveAttr(Attribute Attr) {
+ return Attr.hasAttribute("statepoint-id") ||
+ Attr.hasAttribute("statepoint-num-patch-bytes");
+}
+
+StatepointDirectives llvm::parseStatepointDirectivesFromAttrs(AttributeSet AS) {
+ StatepointDirectives Result;
+
+ Attribute AttrID =
+ AS.getAttribute(AttributeSet::FunctionIndex, "statepoint-id");
+ uint64_t StatepointID;
+ if (AttrID.isStringAttribute())
+ if (!AttrID.getValueAsString().getAsInteger(10, StatepointID))
+ Result.StatepointID = StatepointID;
+
+ uint32_t NumPatchBytes;
+ Attribute AttrNumPatchBytes = AS.getAttribute(AttributeSet::FunctionIndex,
+ "statepoint-num-patch-bytes");
+ if (AttrNumPatchBytes.isStringAttribute())
+ if (!AttrNumPatchBytes.getValueAsString().getAsInteger(10, NumPatchBytes))
+ Result.NumPatchBytes = NumPatchBytes;
+
+ return Result;
+}
diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
index 3cdf84456ff..85aaf62fb3c 100644
--- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -1187,8 +1187,7 @@ static AttributeSet legalizeCallAttributes(AttributeSet AS) {
// These attributes control the generation of the gc.statepoint call /
// invoke itself; and once the gc.statepoint is in place, they're of no
// use.
- if (Attr.hasAttribute("statepoint-num-patch-bytes") ||
- Attr.hasAttribute("statepoint-id"))
+ if (isStatepointDirectiveAttr(Attr))
continue;
Ret = Ret.addAttributes(
@@ -1332,17 +1331,14 @@ makeStatepointExplicitImpl(const CallSite CS, /* to replace */
TransitionArgs = TransitionBundle->Inputs;
}
+ StatepointDirectives SD =
+ parseStatepointDirectivesFromAttrs(CS.getAttributes());
+ if (SD.NumPatchBytes)
+ NumPatchBytes = *SD.NumPatchBytes;
+ if (SD.StatepointID)
+ StatepointID = *SD.StatepointID;
+
Value *CallTarget = CS.getCalledValue();
- AttributeSet OriginalAttrs = CS.getAttributes();
- Attribute AttrID = OriginalAttrs.getAttribute(AttributeSet::FunctionIndex,
- "statepoint-id");
- if (AttrID.isStringAttribute())
- AttrID.getValueAsString().getAsInteger(10, StatepointID);
-
- Attribute AttrNumPatchBytes = OriginalAttrs.getAttribute(
- AttributeSet::FunctionIndex, "statepoint-num-patch-bytes");
- if (AttrNumPatchBytes.isStringAttribute())
- AttrNumPatchBytes.getValueAsString().getAsInteger(10, NumPatchBytes);
// Create the statepoint given all the arguments
Instruction *Token = nullptr;
OpenPOWER on IntegriCloud