summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2015-10-20 01:06:28 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2015-10-20 01:06:28 +0000
commitb1942f14cd2b933d618efbc2521f342fffde7589 (patch)
tree3fedaf3b5e07e171cfa0c865c2d67c3ad5418283 /llvm/lib/Transforms/Scalar
parent7ad67640e9ce1b14a1b66eca8d63351d40f3c23c (diff)
downloadbcm5719-llvm-b1942f14cd2b933d618efbc2521f342fffde7589.tar.gz
bcm5719-llvm-b1942f14cd2b933d618efbc2521f342fffde7589.zip
[RS4GC] Clean up `find_index`; NFC
- Bring it up to the LLVM Coding Style - Sink it inside `CreateGCRelocates`, which is its only user llvm-svn: 250785
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
-rw-r--r--llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
index db8254cff64..2001b071f78 100644
--- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -1263,14 +1263,6 @@ normalizeForInvokeSafepoint(BasicBlock *BB, BasicBlock *InvokeParent,
return Ret;
}
-static int find_index(ArrayRef<Value *> livevec, Value *val) {
- auto itr = std::find(livevec.begin(), livevec.end(), val);
- assert(livevec.end() != itr);
- size_t index = std::distance(livevec.begin(), itr);
- assert(index < livevec.size());
- return index;
-}
-
// Create new attribute set containing only attributes which can be transferred
// from original call to the safepoint.
static AttributeSet legalizeCallAttributes(AttributeSet AS) {
@@ -1325,7 +1317,15 @@ static void CreateGCRelocates(ArrayRef<Value *> LiveVariables,
IRBuilder<> Builder) {
if (LiveVariables.empty())
return;
-
+
+ auto FindIndex = [](ArrayRef<Value *> LiveVec, Value *Val) {
+ auto ValIt = std::find(LiveVec.begin(), LiveVec.end(), Val);
+ assert(ValIt != LiveVec.end() && "Val not found in LiveVec!");
+ size_t Index = std::distance(LiveVec.begin(), ValIt);
+ assert(Index < LiveVec.size() && "Bug in std::find?");
+ return Index;
+ };
+
// All gc_relocate are set to i8 addrspace(1)* type. We originally generated
// unique declarations for each pointer type, but this proved problematic
// because the intrinsic mangling code is incomplete and fragile. Since
@@ -1341,9 +1341,9 @@ static void CreateGCRelocates(ArrayRef<Value *> LiveVariables,
for (unsigned i = 0; i < LiveVariables.size(); i++) {
// Generate the gc.relocate call and save the result
Value *BaseIdx =
- Builder.getInt32(LiveStart + find_index(LiveVariables, BasePtrs[i]));
+ Builder.getInt32(LiveStart + FindIndex(LiveVariables, BasePtrs[i]));
Value *LiveIdx =
- Builder.getInt32(LiveStart + find_index(LiveVariables, LiveVariables[i]));
+ Builder.getInt32(LiveStart + FindIndex(LiveVariables, LiveVariables[i]));
// only specify a debug name if we can give a useful one
CallInst *Reloc = Builder.CreateCall(
OpenPOWER on IntegriCloud