[llvm] r251029 - Use ArrayRef instead of pointer and size. NFC

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 22 09:35:58 PDT 2015


Author: ctopper
Date: Thu Oct 22 11:35:56 2015
New Revision: 251029

URL: http://llvm.org/viewvc/llvm-project?rev=251029&view=rev
Log:
Use ArrayRef instead of pointer and size. NFC

Modified:
    llvm/trunk/include/llvm/Transforms/InstCombine/InstCombineWorklist.h
    llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp

Modified: llvm/trunk/include/llvm/Transforms/InstCombine/InstCombineWorklist.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/InstCombine/InstCombineWorklist.h?rev=251029&r1=251028&r2=251029&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/InstCombine/InstCombineWorklist.h (original)
+++ llvm/trunk/include/llvm/Transforms/InstCombine/InstCombineWorklist.h Thu Oct 22 11:35:56 2015
@@ -60,13 +60,13 @@ public:
   /// AddInitialGroup - Add the specified batch of stuff in reverse order.
   /// which should only be done when the worklist is empty and when the group
   /// has no duplicates.
-  void AddInitialGroup(Instruction *const *List, unsigned NumEntries) {
+  void AddInitialGroup(ArrayRef<Instruction *> List) {
     assert(Worklist.empty() && "Worklist must be empty to add initial group");
-    Worklist.reserve(NumEntries+16);
-    WorklistMap.resize(NumEntries);
-    DEBUG(dbgs() << "IC: ADDING: " << NumEntries << " instrs to worklist\n");
-    for (unsigned Idx = 0; NumEntries; --NumEntries) {
-      Instruction *I = List[NumEntries-1];
+    Worklist.reserve(List.size()+16);
+    WorklistMap.resize(List.size());
+    DEBUG(dbgs() << "IC: ADDING: " << List.size() << " instrs to worklist\n");
+    unsigned Idx = 0;
+    for (Instruction *I : reverse(List)) {
       WorklistMap.insert(std::make_pair(I, Idx++));
       Worklist.push_back(I);
     }

Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=251029&r1=251028&r2=251029&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Thu Oct 22 11:35:56 2015
@@ -2945,8 +2945,7 @@ static bool AddReachableCodeToWorklist(B
   // of the function down.  This jives well with the way that it adds all uses
   // of instructions to the worklist after doing a transformation, thus avoiding
   // some N^2 behavior in pathological cases.
-  ICWorklist.AddInitialGroup(&InstrsForInstCombineWorklist[0],
-                             InstrsForInstCombineWorklist.size());
+  ICWorklist.AddInitialGroup(InstrsForInstCombineWorklist);
 
   return MadeIRChange;
 }




More information about the llvm-commits mailing list