llvm.org GIT mirror llvm / 38f4dd7
Add fast path for raw_ostream output of strings. - Particularly nice for small constant strings, which get optimized down nicely. On a synthetic benchmark writing out "hello" in a loop, this is about 2x faster with gcc and 3x faster with llvm-gcc. llc on insn-attrtab.bc from 403.gcc is about .5% faster. - I tried for a fancier solution which wouldn't increase code size as much (by trying to match constant arrays), but can't quite make it fly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68396 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 10 years ago
1 changed file(s) with 11 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
118118 }
119119
120120 raw_ostream &operator<<(const char *Str) {
121 write(Str, strlen(Str));
121 // Inline fast path, particulary for constant strings where a
122 // sufficiently smart compiler will simplify strlen.
123
124 unsigned Size = strlen(Str);
125
126 // Make sure we can use the fast path.
127 if (OutBufCur+Size > OutBufEnd)
128 return write(Str, Size);
129
130 memcpy(OutBufCur, Str, Size);
131 OutBufCur += Size;
122132 return *this;
123133 }
124134