<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div class="">Someone more knowledgable can correct me if I’m wrong here… </div>
<div class=""><br class="">
</div>
<div class=""> As I understand it the alignment attribute on any pointer argument in a call is telling the compiler something about the alignment of that pointer, and that is all. It doesn’t know/understand/care about anything else about the call. </div>
<div class=""><br class="">
</div>
<div class=""> So, in the case of memcpy/memmove/memset I would expect that the alignment argument attribute, if you provide one, has to be correct for the value of the pointer argument it is being attached to. I would also expect that whether the memmove/memcpy/memset
 is doing a 0-length operation or not is entirely immaterial to the alignment of its pointer args.</div>
<div class=""><br class="">
</div>
<div class=""> As an aside: The alignment attributes on the source/dest of a memcpy/memmove/memset intrinsic are entirely optional. </div>
<div class=""><br class="">
</div>
<div class="">-Daniel</div>
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Apr 2, 2018, at 10:59 AM, Ralf Jung <<a href="mailto:post@ralfj.de" class="">post@ralfj.de</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Hi
 Daniel,</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">a
 quick question (and kind-of a follow-up to</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class=""><</span><a href="https://lists.llvm.org/pipermail/llvm-dev/2017-July/115665.html" 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-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://lists.llvm.org/pipermail/llvm-dev/2017-July/115665.html</a><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">>):
  Do the</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">pointers
 have to be aligned even if the size is 0?  It would be nice to have</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">this
 stated explicitly in the LangRef.</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Kind
 regards,</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Ralf</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">On
 26.03.2018 22:43, Daniel Neilson via llvm-dev wrote:</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<blockquote type="cite" 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-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
Hi all,<br class="">
 A quick note just to let people know that as of this past Friday my go at this<br class="">
work has been fully landed. It ended up being a back-burner item, so it took<br class="">
longer than I would have liked to get completed. None the less, the changes made<br class="">
were:<br class="">
1) The IRBuilders in LLVM, Clang, and Polly were all updated to create only the<br class="">
new form of the memory intrinsics.<br class="">
2) All LLVM passes to understand the new forms of the intrinsics; modulo the<br class="">
notes below.<br class="">
3) The IRBuilder APIs for creating the old-style memcpy/memmove/memset forms and<br class="">
the MemIntrinsicInst API for getting/setting the old generic/conservative<br class="">
alignment have all been eliminated.<br class="">
<br class="">
 There are a few places where the LLVM pass updates were conservative, and could<br class="">
potentially be made more aggressive by a motivated individual — list below. <br class="">
<br class="">
 All that remains is for interested folk to enhance lowering of small<br class="">
memcpy/memmove into load/store sequences. The lowering in SelectionDAG currently<br class="">
just conservatively uses the MinAlign() of the source & dest alignments as the<br class="">
alignment for the loads and stores. I suspect that we could do better by<br class="">
teaching the lowering that the source & dest can have different alignments.<br class="">
<br class="">
 Note that, also, the createMem[Cpy|Move]Loop type functions used in the<br class="">
LowerMemIntrinsics pass are also now invoked with different source & dest<br class="">
alignments by LowerMemIntrinsics, rather than the same alignment for both, so<br class="">
these helpers will now be invoked with more information than they have in the<br class="">
past; I’m guessing that it’s possible they could do better with this<br class="">
information. For example, createMemMoveLoop() doesn’t even use the alignments<br class="">
it’s given at all right now, and the neither of the createMemCpyLoop*()<br class="">
functions try to set the alignments on the loads & stores it creates.<br class="">
<br class="">
Passes that have conservative alignments after updating:<br class="">
- SelectionDAG<br class="">
- AArch64FastISel<br class="">
- ARMFastISel<br class="">
- MemorySanitizer<br class="">
- MemCpyOpt : Call slot optimization<br class="">
- InlineFunction :  HandleByValArgumentInit<br class="">
- LowerMemIntrinsics (see note above)<br class="">
<br class="">
Cheers,<br class="">
 Daniel<br class="">
<br class="">
---<br class="">
Daniel Neilson, Ph.D.<br class="">
Azul Systems<br class="">
<br class="">
<br class="">
<blockquote type="cite" class="">On Jan 2, 2018, at 2:11 PM, Daniel Neilson via llvm-dev<br class="">
<<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><span class="Apple-converted-space"> </span><<a href="mailto:llvm-dev@lists.llvm.org" class="">mailto:llvm-dev@lists.llvm.org</a>>> wrote:<br class="">
<br class="">
Good day all,<br class="">
 I’ve spent a few days resurrecting the circa-2015 work on removing the<br class="">
explicit alignment argument (4th arg) from the @llvm.memcpy/memmove/memset<br class="">
intrinsics in favour of using the alignment attribute on the pointer args of<br class="">
calls to the intrinsic. This work was first proposed back in August 2015 by<br class="">
Lang Hames:<br class="">
<a href="http://lists.llvm.org/pipermail/llvm-dev/2015-August/089384.html" class="">http://lists.llvm.org/pipermail/llvm-dev/2015-August/089384.html</a>   (item 2)<br class="">
 and an attempt at landing the work was made by Pete Cooper in November 2015,<br class="">
but then backed out due to unspecified bot failures:<br class="">
<a href="http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151109/312083.html" class="">http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151109/312083.html</a><br class="">
<br class="">
 I’ve prepared changes for LLVM, Clang, and Polly that are now up for review:<br class="">
*<span class="Apple-converted-space"> </span><a href="https://reviews.llvm.org/D41675" class="">https://reviews.llvm.org/D41675</a>   (LLVM part)<br class="">
* <a href="https://reviews.llvm.org/D41676" class="">https://reviews.llvm.org/D41676</a>   (polly part)<br class="">
* <a href="https://reviews.llvm.org/D41677" class="">https://reviews.llvm.org/D41677</a>   (Clang part)<br class="">
<br class="">
 Importantly for those maintaining downstream users of the LLVM API, this<br class="">
changes the prototypes for the @llvm.memcpy/memmove/memset intrinsics and<br class="">
changes the IRBuilder API for creating memcpy and memmove calls.<br class="">
<br class="">
For example, IR which used to read:<br class="">
     call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 100, i32 4,<br class="">
i1 false)<br class="">
will now read<br class="">
     call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src,<br class="">
i32 100, i1 false)<br class="">
<br class="">
 The LLVM change includes auto upgrade of the old IR. However, match<br class="">
expressions in IR tests and calls to IRBuilder’s CreateMemCpy & CreateMemMove<br class="">
will need to be updated.<br class="">
<br class="">
 My plan is to post another note to the list when the change is landed, and<br class="">
stable.<br class="">
<br class="">
 Comments? Concerns?<br class="">
<br class="">
-Daniel<br class="">
<br class="">
---<br class="">
Daniel Neilson, Ph.D.<br class="">
Azul Systems<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
LLVM Developers mailing list<br class="">
<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><span class="Apple-converted-space"> </span><<a href="mailto:llvm-dev@lists.llvm.org" class="">mailto:llvm-dev@lists.llvm.org</a>><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class="">
</blockquote>
<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
LLVM Developers mailing list<br class="">
<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></blockquote>
</div>
</blockquote>
</div>
<br class="">
</body>
</html>