[llvm] r207331 - Mark the growing path in SmallVector::push_back as cold.
Benjamin Kramer
benny.kra at googlemail.com
Sat Apr 26 13:10:50 PDT 2014
Author: d0k
Date: Sat Apr 26 15:10:49 2014
New Revision: 207331
URL: http://llvm.org/viewvc/llvm-project?rev=207331&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/ADT/SmallVector.h
Modified: llvm/trunk/include/llvm/ADT/SmallVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SmallVector.h?rev=207331&r1=207330&r2=207331&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/SmallVector.h (original)
+++ llvm/trunk/include/llvm/ADT/SmallVector.h Sat Apr 26 15:10:49 2014
@@ -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);
More information about the llvm-commits
mailing list