[Statepoints] Clean up PlaceSafepoints.cpp: variable naming.

Use CamelCase.  NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236673 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sanjoy Das
2015-05-06 23:53:19 +00:00
parent 8a86e2564d
commit b82de79bc1

View File

@@ -882,36 +882,35 @@ static Value *ReplaceWithStatepoint(const CallSite &CS, /* to replace */
// immediately before the previous instruction under the assumption that all // immediately before the previous instruction under the assumption that all
// arguments will be available here. We can't insert afterwards since we may // arguments will be available here. We can't insert afterwards since we may
// be replacing a terminator. // be replacing a terminator.
Instruction *insertBefore = CS.getInstruction(); IRBuilder<> Builder(CS.getInstruction());
IRBuilder<> Builder(insertBefore);
// Note: The gc args are not filled in at this time, that's handled by // Note: The gc args are not filled in at this time, that's handled by
// RewriteStatepointsForGC (which is currently under review). // RewriteStatepointsForGC (which is currently under review).
// Create the statepoint given all the arguments // Create the statepoint given all the arguments
Instruction *token = nullptr; Instruction *Token = nullptr;
AttributeSet return_attributes; AttributeSet ReturnAttrs;
if (CS.isCall()) { if (CS.isCall()) {
CallInst *toReplace = cast<CallInst>(CS.getInstruction()); CallInst *ToReplace = cast<CallInst>(CS.getInstruction());
CallInst *Call = Builder.CreateGCStatepointCall( CallInst *Call = Builder.CreateGCStatepointCall(
CS.getCalledValue(), makeArrayRef(CS.arg_begin(), CS.arg_end()), None, CS.getCalledValue(), makeArrayRef(CS.arg_begin(), CS.arg_end()), None,
None, "safepoint_token"); None, "safepoint_token");
Call->setTailCall(toReplace->isTailCall()); Call->setTailCall(ToReplace->isTailCall());
Call->setCallingConv(toReplace->getCallingConv()); Call->setCallingConv(ToReplace->getCallingConv());
// Before we have to worry about GC semantics, all attributes are legal // Before we have to worry about GC semantics, all attributes are legal
AttributeSet new_attrs = toReplace->getAttributes(); AttributeSet OriginalAttrs = ToReplace->getAttributes();
// In case if we can handle this set of sttributes - set up function attrs // In case if we can handle this set of sttributes - set up function attrs
// directly on statepoint and return attrs later for gc_result intrinsic. // directly on statepoint and return attrs later for gc_result intrinsic.
Call->setAttributes(new_attrs.getFnAttributes()); Call->setAttributes(OriginalAttrs.getFnAttributes());
return_attributes = new_attrs.getRetAttributes(); ReturnAttrs = OriginalAttrs.getRetAttributes();
// TODO: handle param attributes // TODO: handle param attributes
token = Call; Token = Call;
// Put the following gc_result and gc_relocate calls immediately after the // Put the following gc_result and gc_relocate calls immediately after the
// the old call (which we're about to delete) // the old call (which we're about to delete)
BasicBlock::iterator next(toReplace); BasicBlock::iterator next(ToReplace);
assert(BB->end() != next && "not a terminator, must have next"); assert(BB->end() != next && "not a terminator, must have next");
next++; next++;
Instruction *IP = &*(next); Instruction *IP = &*(next);
@@ -919,48 +918,47 @@ static Value *ReplaceWithStatepoint(const CallSite &CS, /* to replace */
Builder.SetCurrentDebugLocation(IP->getDebugLoc()); Builder.SetCurrentDebugLocation(IP->getDebugLoc());
} else if (CS.isInvoke()) { } else if (CS.isInvoke()) {
InvokeInst *toReplace = cast<InvokeInst>(CS.getInstruction()); InvokeInst *ToReplace = cast<InvokeInst>(CS.getInstruction());
// Insert the new invoke into the old block. We'll remove the old one in a // Insert the new invoke into the old block. We'll remove the old one in a
// moment at which point this will become the new terminator for the // moment at which point this will become the new terminator for the
// original block. // original block.
Builder.SetInsertPoint(toReplace->getParent()); Builder.SetInsertPoint(ToReplace->getParent());
InvokeInst *invoke = Builder.CreateGCStatepointInvoke( InvokeInst *Invoke = Builder.CreateGCStatepointInvoke(
CS.getCalledValue(), toReplace->getNormalDest(), CS.getCalledValue(), ToReplace->getNormalDest(),
toReplace->getUnwindDest(), makeArrayRef(CS.arg_begin(), CS.arg_end()), ToReplace->getUnwindDest(), makeArrayRef(CS.arg_begin(), CS.arg_end()),
Builder.getInt32(0), None, "safepoint_token"); Builder.getInt32(0), None, "safepoint_token");
// Currently we will fail on parameter attributes and on certain // Currently we will fail on parameter attributes and on certain
// function attributes. // function attributes.
AttributeSet new_attrs = toReplace->getAttributes(); AttributeSet OriginalAttrs = ToReplace->getAttributes();
// In case if we can handle this set of sttributes - set up function attrs // In case if we can handle this set of sttributes - set up function attrs
// directly on statepoint and return attrs later for gc_result intrinsic. // directly on statepoint and return attrs later for gc_result intrinsic.
invoke->setAttributes(new_attrs.getFnAttributes()); Invoke->setAttributes(OriginalAttrs.getFnAttributes());
return_attributes = new_attrs.getRetAttributes(); ReturnAttrs = OriginalAttrs.getRetAttributes();
token = invoke; Token = Invoke;
// We'll insert the gc.result into the normal block // We'll insert the gc.result into the normal block
BasicBlock *normalDest = normalizeBBForInvokeSafepoint( BasicBlock *NormalDest = normalizeBBForInvokeSafepoint(
toReplace->getNormalDest(), invoke->getParent()); ToReplace->getNormalDest(), Invoke->getParent());
Instruction *IP = &*(normalDest->getFirstInsertionPt()); Instruction *IP = &*(NormalDest->getFirstInsertionPt());
Builder.SetInsertPoint(IP); Builder.SetInsertPoint(IP);
} else { } else {
llvm_unreachable("unexpect type of CallSite"); llvm_unreachable("unexpect type of CallSite");
} }
assert(token); assert(Token);
// Handle the return value of the original call - update all uses to use a // Handle the return value of the original call - update all uses to use a
// gc_result hanging off the statepoint node we just inserted // gc_result hanging off the statepoint node we just inserted
// Only add the gc_result iff there is actually a used result // Only add the gc_result iff there is actually a used result
if (!CS.getType()->isVoidTy() && !CS.getInstruction()->use_empty()) { if (!CS.getType()->isVoidTy() && !CS.getInstruction()->use_empty()) {
std::string takenName = std::string TakenName =
CS.getInstruction()->hasName() ? CS.getInstruction()->getName() : ""; CS.getInstruction()->hasName() ? CS.getInstruction()->getName() : "";
CallInst *gc_result = CallInst *GCResult = Builder.CreateGCResult(Token, CS.getType(), TakenName);
Builder.CreateGCResult(token, CS.getType(), takenName); GCResult->setAttributes(ReturnAttrs);
gc_result->setAttributes(return_attributes); return GCResult;
return gc_result;
} else { } else {
// No return value for the call. // No return value for the call.
return nullptr; return nullptr;