[llvm] 91ef7cb - [IR] Trivial cleanups in Use. NFC.

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Fri May 15 10:15:39 PDT 2020


Author: Jay Foad
Date: 2020-05-15T18:14:45+01:00
New Revision: 91ef7cb508b66ad937d2357e155be2c7850490b9

URL: https://github.com/llvm/llvm-project/commit/91ef7cb508b66ad937d2357e155be2c7850490b9
DIFF: https://github.com/llvm/llvm-project/commit/91ef7cb508b66ad937d2357e155be2c7850490b9.diff

LOG: [IR] Trivial cleanups in Use. NFC.

Remove Use::setPrev. It provided no value because it had the same
accessibility as the underlying field Prev, and there was no
corresponding setNext anyway.

Simplify Use::removeFromList.

Added: 
    

Modified: 
    llvm/include/llvm/IR/Use.h
    llvm/include/llvm/IR/Value.h
    llvm/lib/IR/Value.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/Use.h b/llvm/include/llvm/IR/Use.h
index 6bb958c173bf..917db2679c55 100644
--- a/llvm/include/llvm/IR/Use.h
+++ b/llvm/include/llvm/IR/Use.h
@@ -96,21 +96,18 @@ class Use {
   Use **Prev = nullptr;
   User *Parent = nullptr;
 
-  void setPrev(Use **NewPrev) { Prev = NewPrev; }
-
   void addToList(Use **List) {
     Next = *List;
     if (Next)
-      Next->setPrev(&Next);
-    setPrev(List);
-    *List = this;
+      Next->Prev = &Next;
+    Prev = List;
+    *Prev = this;
   }
 
   void removeFromList() {
-    Use **StrippedPrev = Prev;
-    *StrippedPrev = Next;
+    *Prev = Next;
     if (Next)
-      Next->setPrev(StrippedPrev);
+      Next->Prev = Prev;
   }
 };
 

diff  --git a/llvm/include/llvm/IR/Value.h b/llvm/include/llvm/IR/Value.h
index f7dc53430154..47f311f1ead6 100644
--- a/llvm/include/llvm/IR/Value.h
+++ b/llvm/include/llvm/IR/Value.h
@@ -837,7 +837,7 @@ template <class Compare> void Value::sortUseList(Compare Cmp) {
 
   // Fix the Prev pointers.
   for (Use *I = UseList, **Prev = &UseList; I; I = I->Next) {
-    I->setPrev(Prev);
+    I->Prev = Prev;
     Prev = &I->Next;
   }
 }

diff  --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp
index cf5474018713..665527094933 100644
--- a/llvm/lib/IR/Value.cpp
+++ b/llvm/lib/IR/Value.cpp
@@ -831,12 +831,12 @@ void Value::reverseUseList() {
   while (Current) {
     Use *Next = Current->Next;
     Current->Next = Head;
-    Head->setPrev(&Current->Next);
+    Head->Prev = &Current->Next;
     Head = Current;
     Current = Next;
   }
   UseList = Head;
-  Head->setPrev(&UseList);
+  Head->Prev = &UseList;
 }
 
 bool Value::isSwiftError() const {


        


More information about the llvm-commits mailing list