https://llvm.org/bugs/show_bug.cgi?id=23301
Bug ID: 23301
Summary: InstCombine: objectsize of alloca optimized to undef
returns unknown
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Scalar Optimizations
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
Reported by Daniel Micay in PR23280:
#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 returns -1 because buf is optimized to undef by InstCombine.
When InstCombine tries to erase an alloca, the isAllocSiteRemovable logic is
smarter than the RAUW-undef logic: when there's a (objectsize (GEP/bitcast
(alloca))), we should look through the alloca users to properly lower the
objectsize calls. We currently just do something like alloca->RAUW(undef).
Perhaps the RAUW-undef logic and isAllocSiteRemovable should match? This would
let the above example print 2 instead of the current -1.
--
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