<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<br>
<div class="moz-cite-prefix">On 03/29/2016 01:59 PM, Pete Cooper via
llvm-dev wrote:<br>
</div>
<blockquote
cite="mid:00ED8501-1C79-484A-8256-A0ABED6D84B6@apple.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Mar 28, 2016, at 6:02 PM, Pete Cooper via
llvm-dev <<a moz-do-not-send="true"
href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;" class="">
<blockquote type="cite" class="">
<div class=""><br class="Apple-interchange-newline">
On Mar 28, 2016, at 3:12 PM, Chandler Carruth <<a
moz-do-not-send="true"
href="mailto:chandlerc@google.com" class=""><a class="moz-txt-link-abbreviated" href="mailto:chandlerc@google.com">chandlerc@google.com</a></a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">FWIW, I agree with Mehdi that
we should just assert that our types don't get
called with size zero.</div>
</div>
</blockquote>
Yeah, I agree. I’ve tried running the tests with the
assert in place and there’s about 1000 failures across
llvm/clang. I’ll see what I can fix as I would like to
get these to behave. There may be actual logic errors in
some of these cases.<br class="">
</div>
</div>
</blockquote>
Well this is fun. There is a long standing bug in the
SelectionDAG tablegen matcher this has uncovered. Seems that
ComplexPattern’s don’t track MemRefs. It probably (hopefully!)
just causes downstream code to be conservative but its possible
there’s real issues being hidden by this.</div>
<div><br class="">
</div>
<div>The problematic code is something like ‘xop(load) ->
X86XOPrm’ where the resulting X86XOP MachineInstr wouldn’t have
an MachineMemOperand’s, despite being marked as loading from
memory.</div>
<div><br class="">
</div>
<div>Will file a PR so that we can track some of these issues.</div>
</blockquote>
Coming late to this discussion since I just noticed this was talking
about MemRefs...<br>
<br>
We have deep and horrible problems around our handling of
MemoryOperands. As it stands, there does not appear to be a single
invariant which is documented and accepted throughout the various
backends. There are conflicting assumptions in various bits of
code. I tried to clean up some of this a while back and made some
forward progress, but there's a lot of work left to do here. <br>
<blockquote
cite="mid:00ED8501-1C79-484A-8256-A0ABED6D84B6@apple.com"
type="cite">
<div><br class="">
</div>
<div>Pete<br class="">
<blockquote type="cite" class="">
<div class="">
<div style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;" class="">
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div class=""><br class="">
</div>
<div class="">That said, I don't think we can be
terribly cavalier with what we expect from
standard allocator types, operator new, or malloc.
And so I would expect
LLVM_ATTRIBUTE_RETURNS_NOALIAS to not imply
NONNULL, and while it seems reasonable to put
NONNULL on *our* allocate function because of the
assert and the fact that we assume the underlying
allocation routine never produces a null, it
doesn't seem reasonable for any old function with
NOALIAS to have NONNULL inferred.</div>
</div>
</div>
</blockquote>
I agree. I don’t actually know if NOALIAS and NONNULL
were put on this function independently, or if the
committer assumed one implied the other. But I do agree
that they should be independent in general, even if they
happen to both apply here.</div>
<div style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;" class=""><br
class="">
</div>
<div style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;" class="">Cheers,</div>
<div style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;" class="">Pete<br
class="">
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div class=""><br class="">
</div>
<div class="">-Chandler</div>
</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="">On Tue, Mar 22, 2016 at 9:18
PM Mehdi Amini via llvm-dev <<a
moz-do-not-send="true"
href="mailto:llvm-dev@lists.llvm.org" class=""><a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a></a>>
wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin: 0px
0px 0px 0.8ex; border-left-width: 1px;
border-left-color: rgb(204, 204, 204);
border-left-style: solid; padding-left: 1ex;">
<div class="" style="word-wrap: break-word;">
<div class="">
<blockquote type="cite" class="">
<div class="">On Mar 22, 2016, at 5:39 PM,
Pete Cooper via llvm-dev <<a
moz-do-not-send="true"
href="mailto:llvm-dev@lists.llvm.org"
target="_blank" class=""><a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a></a>>
wrote:</div>
<br class="">
<div class="">
<div class="" style="font-family:
Helvetica; font-size: 12px; font-style:
normal; font-variant-ligatures: normal;
font-variant-position: normal;
font-variant-caps: normal;
font-variant-numeric: normal;
font-variant-alternates: normal;
font-variant-east-asian: normal;
font-weight: normal; letter-spacing:
normal; text-align: start; text-indent:
0px; text-transform: none; white-space:
normal; word-spacing: 0px;">
<blockquote type="cite" class="">
<div class=""><br class="">
On Mar 22, 2016, at 5:35 PM, David
Blaikie <<a
moz-do-not-send="true"
href="mailto:dblaikie@gmail.com"
target="_blank" class=""><a class="moz-txt-link-abbreviated" href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a></a>>
wrote:</div>
<br class="">
<div class=""><br class="">
<br class="" style="font-family:
Helvetica; font-size: 12px;
font-style: normal; font-weight:
normal; letter-spacing: normal;
text-align: start; text-indent:
0px; text-transform: none;
white-space: normal; word-spacing:
0px;">
<div class="gmail_quote"
style="font-family: Helvetica;
font-size: 12px; font-style:
normal; font-weight: normal;
letter-spacing: normal;
text-align: start; text-indent:
0px; text-transform: none;
white-space: normal; word-spacing:
0px;">On Tue, Mar 22, 2016 at 5:30
PM, Pete Cooper<span class=""> </span><span
dir="ltr" class=""><<a
moz-do-not-send="true"
href="mailto:peter_cooper@apple.com"
target="_blank" class=""><a class="moz-txt-link-abbreviated" href="mailto:peter_cooper@apple.com">peter_cooper@apple.com</a></a>></span><span
class=""> </span>wrote:<br
class="">
<blockquote class="gmail_quote"
style="margin: 0px 0px 0px
0.8ex; border-left-width: 1px;
border-left-color: rgb(204, 204,
204); border-left-style: solid;
padding-left: 1ex;">
<div class="" style="word-wrap:
break-word;">Hi all
<div class=""><br class="">
</div>
<div class="">(No idea if I
have the correct audience.
Please CC more people as
needed).</div>
<div class=""><br class="">
</div>
<div class="">I have an UBSan
failure in
BumpPtrAllocatorImpl.Allocate.</div>
<div class=""><br class="">
</div>
<div class="">The problem is
that lld requests that we
StringRef::copy an empty
string. This passes a
length of 0 to a
BumpPtrAllocator. The
BumpPtrAllocator happened to
not have anything allocated
yet so the CurPtr is
nullptr, but given that we
need 0 space we think we
have enough space and return
an allocation of size 0 at
address nullptr. This
therefore returns nullptr
from Allocate, but that
method is marked
with LLVM_ATTRIBUTE_RETURNS_NONNULL
and LLVM_ATTRIBUTE_RETURNS_NOALIAS,
both of which aren’t true in
this case.</div>
<div class=""><br class="">
</div>
<div class="">To put this in
code, if I have</div>
<div class=""><br class="">
</div>
<blockquote class=""
style="margin: 0px 0px 0px
40px; border: none; padding:
0px;">
<div class="">BumpPtrAllocator
allocator;</div>
<div class="">StringRef s;</div>
<div class="">s.copy(allocator);</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">then i’m going
to allocate 0 bytes in the
allocator and get a
StringRef(nullptr, 0). Its
a valid StringRef, but an
UBSan failures in the
allocator.</div>
<div class=""><br class="">
</div>
<div class="">Lang and I
looked up malloc behaviour
online as this is fairly
analogous. The answer there
is that you are allowed to
return nullptr, or not, its
implementation defined. So
no help there.</div>
<div class=""><br class="">
</div>
<div class="">So the question
is, how do we want this to
behave in our code?</div>
<div class=""><br class="">
</div>
<div class="">Some options:</div>
<div class="">- Assert that
Allocate never gets a size 0
allocation. So fix
StringRef::copy to see this
case</div>
<div class="">- Remove the
attributes from Allocate but
continue to return nullptr
(or base of the allocator?)
in this case</div>
<div class="">- Keep the
attributes on Allocate and
treat size 0 allocations as
size 1</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">I believe the last
is closer to 'new's behavior -
which I think returns a unique
non-null address (well, unique
amongst current allocations -
can be recycled once deleted) if
I recall correctly.<span
class=""> </span></div>
</div>
</div>
</blockquote>
That’s what I would have expected too.
Its like sizeof(struct {}) which can be
a 1 depending on factors we don’t need
to get in to here.<br class="">
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
</div>
</div>
<div class="" style="word-wrap: break-word;">
<div class="">
<div class="">Well except that if
sizeof(struct{}) is 1, the allocator is
never called with a 0.</div>
<div class=""><br class="">
</div>
<div class="">I would consider forbidding zero
sized allocation in the allocator (assert())
by design (hey we're controlling every
possible uses!), unless there is a real
use-case for that.</div>
<div class=""><br class="">
</div>
<div class="">This would also be in line with
the C++ standard requirement for allocator
which specifies that the result of
"a.allocate(0)" is unspecified (ref: C++14
Table 28 — Allocator requirements).</div>
</div>
</div>
<div class="" style="word-wrap: break-word;">
<div class=""><br class="">
<div class="">-- </div>
<div class="">Mehdi</div>
</div>
</div>
<div class="" style="word-wrap: break-word;">
<div class="">
<div class=""><br class="">
</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div class="" style="font-family:
Helvetica; font-size: 12px; font-style:
normal; font-variant-ligatures: normal;
font-variant-position: normal;
font-variant-caps: normal;
font-variant-numeric: normal;
font-variant-alternates: normal;
font-variant-east-asian: normal;
font-weight: normal; letter-spacing:
normal; text-align: start; text-indent:
0px; text-transform: none; white-space:
normal; word-spacing: 0px;">
<blockquote type="cite" class="">
<div class="">
<div class="gmail_quote"
style="font-family: Helvetica;
font-size: 12px; font-style:
normal; font-weight: normal;
letter-spacing: normal;
text-align: start; text-indent:
0px; text-transform: none;
white-space: normal; word-spacing:
0px;">
<div class="">Can check for
wording if that's
helpful/desired.</div>
</div>
</div>
</blockquote>
No need for my benefit :) I’m in
agreement that this is a good behavior
to go for, but will leave it to others
to say if they’d like the extra detail.</div>
<div class="" style="font-family:
Helvetica; font-size: 12px; font-style:
normal; font-variant-ligatures: normal;
font-variant-position: normal;
font-variant-caps: normal;
font-variant-numeric: normal;
font-variant-alternates: normal;
font-variant-east-asian: normal;
font-weight: normal; letter-spacing:
normal; text-align: start; text-indent:
0px; text-transform: none; white-space:
normal; word-spacing: 0px;"><br class="">
</div>
<div class="" style="font-family:
Helvetica; font-size: 12px; font-style:
normal; font-variant-ligatures: normal;
font-variant-position: normal;
font-variant-caps: normal;
font-variant-numeric: normal;
font-variant-alternates: normal;
font-variant-east-asian: normal;
font-weight: normal; letter-spacing:
normal; text-align: start; text-indent:
0px; text-transform: none; white-space:
normal; word-spacing: 0px;">One thing I
did forget to say is that I’d like to
fix StringRef::copy in all of the above
cases. I think that this method should
always avoid the allocator and return
StringRef(nullptr, 0) when length is 0.
I’ll get a patch up on llvm-commits if
there’s no objections there.</div>
<div class="" style="font-family:
Helvetica; font-size: 12px; font-style:
normal; font-variant-ligatures: normal;
font-variant-position: normal;
font-variant-caps: normal;
font-variant-numeric: normal;
font-variant-alternates: normal;
font-variant-east-asian: normal;
font-weight: normal; letter-spacing:
normal; text-align: start; text-indent:
0px; text-transform: none; white-space:
normal; word-spacing: 0px;"><br class="">
</div>
<div class="" style="font-family:
Helvetica; font-size: 12px; font-style:
normal; font-variant-ligatures: normal;
font-variant-position: normal;
font-variant-caps: normal;
font-variant-numeric: normal;
font-variant-alternates: normal;
font-variant-east-asian: normal;
font-weight: normal; letter-spacing:
normal; text-align: start; text-indent:
0px; text-transform: none; white-space:
normal; word-spacing: 0px;">Thanks,</div>
<div class="" style="font-family:
Helvetica; font-size: 12px; font-style:
normal; font-variant-ligatures: normal;
font-variant-position: normal;
font-variant-caps: normal;
font-variant-numeric: normal;
font-variant-alternates: normal;
font-variant-east-asian: normal;
font-weight: normal; letter-spacing:
normal; text-align: start; text-indent:
0px; text-transform: none; white-space:
normal; word-spacing: 0px;">Pete<br
class="">
<blockquote type="cite" class="">
<div class="">
<div class="gmail_quote"
style="font-family: Helvetica;
font-size: 12px; font-style:
normal; font-weight: normal;
letter-spacing: normal;
text-align: start; text-indent:
0px; text-transform: none;
white-space: normal; word-spacing:
0px;">
<div class=""> </div>
<blockquote class="gmail_quote"
style="margin: 0px 0px 0px
0.8ex; border-left-width: 1px;
border-left-color: rgb(204, 204,
204); border-left-style: solid;
padding-left: 1ex;">
<div class="" style="word-wrap:
break-word;">
<div class=""><br class="">
</div>
<div class="">Thanks,</div>
<div class="">Pete</div>
</div>
</blockquote>
</div>
</div>
</blockquote>
</div>
<br class="" style="font-family:
Helvetica; font-size: 12px; font-style:
normal; font-variant-ligatures: normal;
font-variant-position: normal;
font-variant-caps: normal;
font-variant-numeric: normal;
font-variant-alternates: normal;
font-variant-east-asian: normal;
font-weight: normal; letter-spacing:
normal; text-align: start; text-indent:
0px; text-transform: none; white-space:
normal; word-spacing: 0px;">
<span class="" style="font-family:
Helvetica; font-size: 12px; font-style:
normal; font-variant-ligatures: normal;
font-variant-position: normal;
font-variant-caps: normal;
font-variant-numeric: normal;
font-variant-alternates: normal;
font-variant-east-asian: normal;
font-weight: normal; letter-spacing:
normal; text-align: start; text-indent:
0px; text-transform: none; white-space:
normal; word-spacing: 0px; float: none;
display: inline !important;">_______________________________________________</span><br
class="" style="font-family: Helvetica;
font-size: 12px; font-style: normal;
font-variant-ligatures: normal;
font-variant-position: normal;
font-variant-caps: normal;
font-variant-numeric: normal;
font-variant-alternates: normal;
font-variant-east-asian: normal;
font-weight: normal; letter-spacing:
normal; text-align: start; text-indent:
0px; text-transform: none; white-space:
normal; word-spacing: 0px;">
<span class="" style="font-family:
Helvetica; font-size: 12px; font-style:
normal; font-variant-ligatures: normal;
font-variant-position: normal;
font-variant-caps: normal;
font-variant-numeric: normal;
font-variant-alternates: normal;
font-variant-east-asian: normal;
font-weight: normal; letter-spacing:
normal; text-align: start; text-indent:
0px; text-transform: none; white-space:
normal; word-spacing: 0px; float: none;
display: inline !important;">LLVM
Developers mailing list</span><br
class="" style="font-family: Helvetica;
font-size: 12px; font-style: normal;
font-variant-ligatures: normal;
font-variant-position: normal;
font-variant-caps: normal;
font-variant-numeric: normal;
font-variant-alternates: normal;
font-variant-east-asian: normal;
font-weight: normal; letter-spacing:
normal; text-align: start; text-indent:
0px; text-transform: none; white-space:
normal; word-spacing: 0px;">
<a moz-do-not-send="true"
href="mailto:llvm-dev@lists.llvm.org"
target="_blank" class=""
style="font-family: Helvetica;
font-size: 12px; font-style: normal;
font-variant-ligatures: normal;
font-variant-position: normal;
font-variant-caps: normal;
font-variant-numeric: normal;
font-variant-alternates: normal;
font-variant-east-asian: normal;
font-weight: normal; letter-spacing:
normal; text-align: start; text-indent:
0px; text-transform: none; white-space:
normal; word-spacing: 0px;">llvm-dev@lists.llvm.org</a><br
class="" style="font-family: Helvetica;
font-size: 12px; font-style: normal;
font-variant-ligatures: normal;
font-variant-position: normal;
font-variant-caps: normal;
font-variant-numeric: normal;
font-variant-alternates: normal;
font-variant-east-asian: normal;
font-weight: normal; letter-spacing:
normal; text-align: start; text-indent:
0px; text-transform: none; white-space:
normal; word-spacing: 0px;">
<a moz-do-not-send="true"
href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"
target="_blank" class=""
style="font-family: Helvetica;
font-size: 12px; font-style: normal;
font-variant-ligatures: normal;
font-variant-position: normal;
font-variant-caps: normal;
font-variant-numeric: normal;
font-variant-alternates: normal;
font-variant-east-asian: normal;
font-weight: normal; letter-spacing:
normal; text-align: start; text-indent:
0px; text-transform: none; white-space:
normal; word-spacing: 0px;">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></div>
</blockquote>
</div>
</div>
_______________________________________________<br
class="">
LLVM Developers mailing list<br class="">
<a moz-do-not-send="true"
href="mailto:llvm-dev@lists.llvm.org"
target="_blank" class="">llvm-dev@lists.llvm.org</a><br
class="">
<a moz-do-not-send="true"
href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"
rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br
class="">
</blockquote>
</div>
</div>
</blockquote>
</div>
<br class="" style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;">
<span style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none; display:
inline !important;" class="">_______________________________________________</span><br
style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none; display:
inline !important;" class="">LLVM Developers mailing list</span><br
style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;" class="">
<a moz-do-not-send="true"
href="mailto:llvm-dev@lists.llvm.org" style="font-family:
Helvetica; font-size: 12px; font-style: normal;
font-variant-caps: normal; font-weight: normal;
letter-spacing: normal; orphans: auto; text-align: start;
text-indent: 0px; text-transform: none; white-space:
normal; widows: auto; word-spacing: 0px;
-webkit-text-stroke-width: 0px;" class="">llvm-dev@lists.llvm.org</a><br
style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;" class="">
<a moz-do-not-send="true"
href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"
style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></div>
</blockquote>
</div>
<br class="">
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<br>
</body>
</html>