From: Benjamin Kramer Date: Sat, 26 Apr 2014 20:10:49 +0000 (+0000) Subject: Mark the growing path in SmallVector::push_back as cold. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=708d6805654d9296937d8f8751e660909c41912a Mark the growing path in SmallVector::push_back as cold. 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 --- diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h index 791d03c6491..df46f919118 100644 --- a/include/llvm/ADT/SmallVector.h +++ b/include/llvm/ADT/SmallVector.h @@ -223,14 +223,14 @@ protected: 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) { - 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); @@ -327,7 +327,7 @@ protected: } 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);