<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="">
Hi all,
<div class=""> A quick note just to let people know that as of this past Friday my go at this work has been fully landed. It ended up being a back-burner item, so it took longer than I would have liked to get completed. None the less, the changes made were:</div>
<div class="">1) The IRBuilders in LLVM, Clang, and Polly were all updated to create only the new form of the memory intrinsics.</div>
<div class="">2) All LLVM passes to understand the new forms of the intrinsics; modulo the notes below.</div>
<div class="">3) The IRBuilder APIs for creating the old-style memcpy/memmove/memset forms and the MemIntrinsicInst API for getting/setting the old generic/conservative alignment have all been eliminated.</div>
<div class=""><br class="">
</div>
<div class=""> There are a few places where the LLVM pass updates were conservative, and could potentially be made more aggressive by a motivated individual — list below. </div>
<div class=""><br class="">
</div>
<div class=""> All that remains is for interested folk to enhance lowering of small memcpy/memmove into load/store sequences. The lowering in SelectionDAG currently just conservatively uses the MinAlign() of the source & dest alignments as the alignment for
 the loads and stores. I suspect that we could do better by teaching the lowering that the source & dest can have different alignments.</div>
<div class=""><br class="">
</div>
<div class=""> Note that, also, the createMem[Cpy|Move]Loop type functions used in the LowerMemIntrinsics pass are also now invoked with different source & dest alignments by LowerMemIntrinsics, rather than the same alignment for both, so these helpers will
 now be invoked with more information than they have in the past; I’m guessing that it’s possible they could do better with this information. For example, createMemMoveLoop() doesn’t even use the alignments it’s given at all right now, and the neither of the
 createMemCpyLoop*() functions try to set the alignments on the loads & stores it creates.</div>
<div class=""><br class="">
</div>
<div class="">Passes that have conservative alignments after updating:</div>
<div class="">- SelectionDAG</div>
<div class="">- AArch64FastISel</div>
<div class="">- ARMFastISel</div>
<div class="">- MemorySanitizer</div>
<div class="">- MemCpyOpt : Call slot optimization</div>
<div class="">- InlineFunction :  HandleByValArgumentInit</div>
<div class="">- LowerMemIntrinsics (see note above)</div>
<div class=""><br class="">
</div>
<div class="">Cheers,</div>
<div class=""> Daniel</div>
<div class=""><br class="">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="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;">
---</div>
<div style="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;">
Daniel Neilson, Ph.D.</div>
<div style="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;">
Azul Systems</div>
<div style="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;" class="">
<br class="">
</div>
</div>
</div>
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Jan 2, 2018, at 2:11 PM, Daniel Neilson via llvm-dev <<a 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="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div class="">Good day all,</div>
<div class=""> I’ve spent a few days resurrecting the circa-2015 work on removing the explicit alignment argument (4th arg) from the @llvm.memcpy/memmove/memset intrinsics in favour of using the alignment attribute on the pointer args of calls to the intrinsic.
 This work was first proposed back in August 2015 by Lang Hames:</div>
<div 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)</div>
<div class=""> and an attempt at landing the work was made by Pete Cooper in November 2015, but then backed out due to unspecified bot failures:</div>
<div 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></div>
<div class=""><br class="">
</div>
<div class=""> I’ve prepared changes for LLVM, Clang, and Polly that are now up for review:</div>
<div class="">* <a href="https://reviews.llvm.org/D41675" class="">https://reviews.llvm.org/D41675</a>   (LLVM part)</div>
<div class="">* <a href="https://reviews.llvm.org/D41676" class="">https://reviews.llvm.org/D41676</a>   (polly part)</div>
<div class="">* <a href="https://reviews.llvm.org/D41677" class="">https://reviews.llvm.org/D41677</a>   (Clang part)</div>
<div class=""><br class="">
</div>
<div class=""> Importantly for those maintaining downstream users of the LLVM API, this changes the prototypes for the @llvm.memcpy/memmove/memset intrinsics and changes the IRBuilder API for creating memcpy and memmove calls.</div>
<div class=""><br class="">
</div>
<div 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, i1 false)<br class="">
will now read<br class="">
     call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 100, i1 false)</div>
<div class=""><br class="">
</div>
 The LLVM change includes auto upgrade of the old IR. However, match expressions in IR tests and calls to IRBuilder’s CreateMemCpy & CreateMemMove will need to be updated.
<div class=""><br class="">
</div>
<div class=""> My plan is to post another note to the list when the change is landed, and stable.</div>
<div class=""><br class="">
</div>
<div class=""> Comments? Concerns?</div>
<div class=""><br class="">
</div>
<div class="">-Daniel<br class="">
<div class=""><br class="">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="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;" class="">
---</div>
<div style="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;" class="">
Daniel Neilson, Ph.D.</div>
<div style="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;" class="">
Azul Systems</div>
<div style="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;" class="">
<br class="">
</div>
<br class="Apple-interchange-newline">
</div>
<br class="Apple-interchange-newline">
</div>
<br class="">
</div>
</div>
</div>
_______________________________________________<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="">
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>