-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Perf/lexer faster slow get char and size #70543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Perf/lexer faster slow get char and size #70543
Conversation
867ef93
to
c9d34da
Compare
Do you have benchmarks? |
See the commit: c9d34da |
Instead of passing the Size by reference, assuming it is initialized, return it alongside the expected char result as a POD. This makes the interface less error prone: previous interface expected the Size reference to be initialized, and it was often forgotten, leading to uninitialized variable usage. This patch fixes the issue. This also generates faster code, as the returned POD (a char and an unsigned) fits in 64 bits. The speedup according to compile time tracker reach -O.7%, with a good number of -0.4%. Details are available on https://llvm-compile-time-tracker.com/compare.php?from=3fe63f81fcb999681daa11b2890c82fda3aaeef5&to=fc76a9202f737472ecad4d6e0b0bf87a013866f3&stat=instructions:u And icing on the cake, on my setup it also shaves 2kB out of libclang-cpp :-)
c9d34da
to
7bbcabd
Compare
@cor3ntin yep, looks better with a small struct, update pushed |
if (C1 != '0') | ||
return false; | ||
char C2 = Lexer::getCharAndSizeNoWarn(Start + Size, Size, LangOpts); | ||
|
||
auto CharAndSize2 = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can reuse CharAndSize
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but I find it less confusing like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't insist!
✅ With the latest revision this PR passed the C/C++ code formatter. |
a20790e
to
3bf6120
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
This patch broke builders like Solaris/amd64 that include |
This breaks building: http://45.33.8.238/linux/121901/step_4.txt Please take a look and revert for now if it takes a while to fix. |
This reverts commit d8f5a18. Breaks build, see: #70543 (comment)
Reverted in 1c876ff for now. |
merges to d346c82 [OpenMP] Associate the KernelEnvironment with the GenericKernelTy (llvm#70383) and reverts to buy time to inegrate it in properly. Also brings in 8f5a18b6e58 Perf/lexer faster slow get char and size (llvm#70543) which is reverted upstream 9 commits later. Change-Id: Idb81b74c26b78bff856d7e4119036918629e47f9
recommited as 8116b6d |
No description provided.