[RS4GC] Remove a redundant linear search, NFCI
authorSanjoy Das <sanjoy@playingwithpointers.com>
Tue, 20 Oct 2015 01:06:31 +0000 (01:06 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Tue, 20 Oct 2015 01:06:31 +0000 (01:06 +0000)
Since LiveVariables is uniqued (we just created it from a `DenseSet`),
`FindIndex(LiveVariables, LiveVariables[i])` is always `i`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250786 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/RewriteStatepointsForGC.cpp

index 2001b071f78afbf7683319c326655faf258304c8..6be71dc3d94c433ea53ce3e8649a5f5abd7cb945 100644 (file)
@@ -1342,8 +1342,7 @@ static void CreateGCRelocates(ArrayRef<Value *> LiveVariables,
     // Generate the gc.relocate call and save the result
     Value *BaseIdx =
       Builder.getInt32(LiveStart + FindIndex(LiveVariables, BasePtrs[i]));
-    Value *LiveIdx =
-      Builder.getInt32(LiveStart + FindIndex(LiveVariables, LiveVariables[i]));
+    Value *LiveIdx = Builder.getInt32(LiveStart + i);
 
     // only specify a debug name if we can give a useful one
     CallInst *Reloc = Builder.CreateCall(