mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-03-04 18:38:37 +00:00
Add BUILTIN_EXPECT Support/Compiler macro.
- Use for exceptional buffer conditions in raw_ostream:write to shave off a cycle or two. - Please rename if you have a better one. llvm-svn: 67103
This commit is contained in:
parent
970d2828f4
commit
7c9dba0950
@ -29,6 +29,12 @@
|
||||
#define ATTRIBUTE_USED
|
||||
#endif
|
||||
|
||||
#if (__GNUC__ >= 4)
|
||||
#define BUILTIN_EXPECT(EXPR, VALUE) __builtin_expect((EXPR), (VALUE))
|
||||
#else
|
||||
#define BUILTIN_EXPECT(EXPR, VALUE) (EXPR)
|
||||
#endif
|
||||
|
||||
// C++ doesn't support 'extern template' of template specializations. GCC does,
|
||||
// but requires __extension__ before it. In the header, use this:
|
||||
// EXTERN_TEMPLATE_INSTANTIATION(class foo<bar>);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "llvm/System/Program.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/Config/config.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include <ostream>
|
||||
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
@ -142,7 +143,7 @@ raw_ostream &raw_ostream::write(unsigned char C) {
|
||||
|
||||
raw_ostream &raw_ostream::write(const char *Ptr, unsigned Size) {
|
||||
// Group exceptional cases into a single branch.
|
||||
if (OutBufCur+Size > OutBufEnd) {
|
||||
if (BUILTIN_EXPECT(OutBufCur+Size > OutBufEnd, false)) {
|
||||
if (Unbuffered) {
|
||||
write_impl(Ptr, Size);
|
||||
return *this;
|
||||
|
Loading…
x
Reference in New Issue
Block a user