[llvm-bugs] [Bug 28834] New: @llvm.objectsize treats allocsize differently than allocas.
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Aug 3 13:39:37 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=28834
Bug ID: 28834
Summary: @llvm.objectsize treats allocsize differently than
allocas.
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: ASSIGNED
Severity: normal
Priority: P
Component: Global Analyses
Assignee: george.burgess.iv at gmail.com
Reporter: george.burgess.iv at gmail.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
For the purposes of evaluating `@llvm.objectsize(%p)`, we're meant to treat `%p
= call i8* @foo(i32 5)` the same as `%p = alloca i8, i32 5` (assuming @foo has
the allocsize attribute).
This seems not to be the case. Given:
```
void bos(char *a, char *b) {
g0 = __builtin_object_size(a, 0);
g1 = __builtin_object_size(b, 1);
}
void bos1() {
char cs[5], cz[8];
bos(cs, cz);
}
```
We generate (with clang trunk, -O2):
```
define void @bos1() {
entry:
store i32 5, i32* @g0, align 4
store i32 8, i32* @g1, align 4
ret void
}
```
Which is good. Given its allocsize equivalent:
```
// N.B. alloc_size DNE in clang yet.
void *malloc2(int n) __attribute((alloc_size(1)));
void allocsize(int a, int b) {
void *p = malloc2(a);
g0 = __builtin_object_size(p, 0);
void *v = malloc2(b);
g1 = __builtin_object_size(v, 1);
}
void allocsize1() {
allocsize(5, 8);
}
```
We get:
```
define void @allocsize1() {
entry:
store i32 -1, i32* @g0, align 4
store i32 -1, i32* @g1, align 4
ret void
}
```
...Those -1s should be 5 and 8.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160803/c99f5aec/attachment.html>
More information about the llvm-bugs
mailing list