https://llvm.org/bugs/show_bug.cgi?id=23280
Bug ID: 23280
Summary: objectsize should not be lowered to unknown before
inlining
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Scalar Optimizations
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
This will output 2 with `gcc -O2` but (size_t)-1 with Clang:
#include <stdio.h>
#include <stdlib.h>
static inline __attribute__((always_inline)) size_t object_size(char *p) {
return __builtin_object_size(p, 0);
}
int main(int argc, char **argv) {
char buf[2];
printf("%zu\n", object_size(buf));
return 0;
}
This means that _FORTIFY_SOURCE buffer size checks do not currently work with
Clang because it lowers the __builtin_object_size calls to (size_t)-1 before
the wrappers are inlined into the call sites. This will also break other
compelling use cases for this feature. It makes a lot of sense to lower it to a
*known* value pre-inlining to get more work done in the early function passes,
but replacing it with -1 before then isn't good.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs