Mark the growing path in SmallVector::push_back as cold.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sat, 26 Apr 2014 20:10:49 +0000 (20:10 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sat, 26 Apr 2014 20:10:49 +0000 (20:10 +0000)
It's vital for performance that the cold path of push_back isn't inlined.

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

include/llvm/ADT/SmallVector.h

index 791d03c64913a4ee7f2b2f9069f3f5b661e1903f..df46f919118aeba9b9a5e7c6d5c323ad36cf0e9d 100644 (file)
@@ -223,14 +223,14 @@ protected:
 
 public:
   void push_back(const T &Elt) {
 
 public:
   void push_back(const T &Elt) {
-    if (this->EndX >= this->CapacityX)
+    if (LLVM_UNLIKELY(this->EndX >= this->CapacityX))
       this->grow();
     ::new ((void*) this->end()) T(Elt);
     this->setEnd(this->end()+1);
   }
 
   void push_back(T &&Elt) {
       this->grow();
     ::new ((void*) this->end()) T(Elt);
     this->setEnd(this->end()+1);
   }
 
   void push_back(T &&Elt) {
-    if (this->EndX >= this->CapacityX)
+    if (LLVM_UNLIKELY(this->EndX >= this->CapacityX))
       this->grow();
     ::new ((void*) this->end()) T(::std::move(Elt));
     this->setEnd(this->end()+1);
       this->grow();
     ::new ((void*) this->end()) T(::std::move(Elt));
     this->setEnd(this->end()+1);
@@ -327,7 +327,7 @@ protected:
   }
 public:
   void push_back(const T &Elt) {
   }
 public:
   void push_back(const T &Elt) {
-    if (this->EndX >= this->CapacityX)
+    if (LLVM_UNLIKELY(this->EndX >= this->CapacityX))
       this->grow();
     memcpy(this->end(), &Elt, sizeof(T));
     this->setEnd(this->end()+1);
       this->grow();
     memcpy(this->end(), &Elt, sizeof(T));
     this->setEnd(this->end()+1);