<div dir="ltr">Patch is certainly welcome.<div><br></div><div>David</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 10, 2016 at 2:46 AM, Strahinja Petrovic <span dir="ltr"><<a href="mailto:strahinja.petrovic@rt-rk.com" target="_blank">strahinja.petrovic@rt-rk.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<br>
Thank you for replies. I'm using trunk version. I have problem in
some tests with this behaviour. I also have fix for this problem
just need an opinion if this should be fixed in clang. I can post
patch on phabricator if you want to take a look.<br>
<br>
Thanks,<br>
Strahinja<div><div class="h5"><br>
<br>
<div>On 09.02.2016. 20:32, George Burgess IV
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Hi!
<div><br>
</div>
<div>This is an artifact of how LLVM works. Essentially, LLVM
detects that `var` is unused and deletes it before it tries to
lower the `llvm.objectsize` (which is what clang lowers
`__builtin_object_size` to) call to a constant. While this
isn't ideal, I don't think it realistically a problem, because
`var` must be otherwise unused for this behavior to occur, and
the whole purpose of objectsize functions (so far) is to
insert bounds checks when a variable is used.</div>
<div><br>
</div>
<div>If this quirk is causing real problems for you, please let
me know and I'll see what I can do about fixing it. :)</div>
<div><br>
</div>
<div>Thanks for pointing this out!</div>
<div>George</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Feb 9, 2016 at 11:06 AM,
Xinliang David Li <span dir="ltr"><<a href="mailto:xinliangli@gmail.com" target="_blank">xinliangli@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">What version of clang/LLVM are you using?
George (cc'ed ) has improved __builtin_object_size
support in Clang recently.<span><font color="#888888">
<div><br>
</div>
<div>David</div>
</font></span></div>
<div>
<div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Feb 9, 2016 at 6:37
AM, Strahinja Petrovic via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I have question about __builtin_object_size
behaviour. LLVM for __builtin_object_size
function doesn't calculate correct value when
pointer is used only in __builtin_object_size
function call, and never after that. For this
case LLVM as result generates 0 or -1 depends of
second argument of __builtin_object_size
function. Is this correct behaviour or it should
work as gcc (gcc calculates correct value for
this case) ?<br>
<br>
Example for this issue:<br>
<br>
include <assert.h><br>
int main() {<br>
struct V { char buf1[10];<br>
int b;<br>
char buf2[10];<br>
} var;<br>
<br>
char *p = &var.buf1[1], *q =
&var.b;<br>
assert (__builtin_object_size (p, 0)
== sizeof (var) - 1);<br>
return 0;<br>
}<br>
<br>
Thanks,<br>
Strahinja<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
<br>
</div></div></div>
</blockquote></div><br></div>