[PATCH] D19299: lower __builtin_expect() directly to prof metadata instead of LLVM intrinsic
Sanjay Patel via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 26 11:14:10 PDT 2016
spatel abandoned this revision.
spatel added a comment.
Abandoning.
The feedback on the dev list was that handling the builtin_expect() in clang is ugly, so it's better to pay a small cost in LLVM to do it.
Note that the current llvm.expect lowering pass doesn't actually work for anything but the simplest cases. The pass needs to be enhanced to handle patterns like:
int foo(int x, int y) {
if (__builtin_expect(x, 20) > 10) return 234; // expected value is not 1
return 2;
}
or:
int foo(int n) {
int b = __builtin_expect(n, 1); // expect is not directly used in comparison
if (b) return 24;
return 234;
}
Currently, the llvm.expect is discarded in these cases without generating any metadata.
http://reviews.llvm.org/D19299
More information about the cfe-commits
mailing list