<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000'><br><hr id="zwchr"><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><b>From: </b>"Pete Cooper" <peter_cooper@apple.com><br><b>To: </b>"Hal Finkel" <hfinkel@anl.gov><br><b>Cc: </b>"Lang Hames" <lhames@apple.com>, "LLVM Commits" <llvm-commits@lists.llvm.org>, cfe-commits@lists.llvm.org<br><b>Sent: </b>Monday, September 28, 2015 12:46:36 PM<br><b>Subject: </b>Re: [PATCH] Change memcpy/memmove/memset to have dest and source alignment<br><br>
Hey Hal<div class=""><br class=""></div><div class="">Thanks for the review. I really appreciate it given the scale of this.<br class=""><div><blockquote class=""><div class="">On Sep 25, 2015, at 1:13 PM, Hal Finkel <<a href="mailto:hfinkel@anl.gov" class="" target="_blank">hfinkel@anl.gov</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hi Pete,<br class=""><br class="">Thanks for working on this.<br class=""><br class="">+ class IntegerAlignment {<br class="">+ private:<br class="">+ uint64_t Align;<br class=""><br class="">You explain in the patch summary why this is here, but please add a comment with the explanation as well.<br class=""></div></div></blockquote>Will do. Good catch.<br class=""><blockquote class=""><div class=""><div class=""><br class="">Regarding the auto-upgrade, are we going to run into problems if we separate our the 'volatile' tag for the source and the destination as Lang had suggested? If we're going to do that, should we do it all at the same time? Does it change the need for the IntegerAlignment class?<br class=""></div></div></blockquote>Luckily I think this will be easier as its just an addition, unlike this patch which is moving things around to attributes. I’m also pretty confident about using sed to auto-upgrade all the tests with the volatile flag. Its much easier to sed for the ‘i1 [true|false])’ at the end of the call and just duplicate that piece, than it is to extract the alignment out from the middle and print it back out as an attribute.</div><div><br class=""></div><div>Saying that, there will be similar churn on things like the IRBuilder, and we may want some way to (temporarily at the least) make sure that everyone is forced to consider whether they want to set both isVolatile flags given that they set one of them. A few possibilities are:</div><div><br class=""></div></div><blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;" class=""><div class=""><div>// Bad, because we don’t know whether current users who set isDestVolatile to true also want source volatility too</div></div><div class=""><div>Create(..., bool isDestVolatile = false, bool isSrcVolatile = false) </div></div><div class=""><div><br class=""></div></div><div class=""><div>// Better, all current users will have to change anyway, and then we know they all care about src/dest volatility</div></div><div class=""><div>Create(…, std::pair<bool, bool> isDestSrcVolatile = std::pair<bool, bool>(false, false))</div></div><div class=""><div><br class=""></div></div><div class=""><div>// Another option, and we would use an assert perhaps to make sure that if dest is set, then so is src</div></div><div class=""><div>Create(…, Optional<bool> isDestVolatile = None, Optional<bool> isSrcVolatile = None) {</div></div><div class=""><div> assert(isDestVolatile.hasValue() == isSrcVolatile.hasValue());</div></div><div class=""><div> …</div></div></blockquote><div class=""><div><br class=""></div><div>Anyway, I think changes can come later, but just a few ideas there.</div><div id="DWT12398"><blockquote class=""><div class=""><div class=""><br class="">Everything else looks good, and I like the cleanup in AlignmentFromAssumptions :-)<br class=""></div></div></blockquote>Thanks :) Can I take that as a LGTM, or...<br class=""></div></div></blockquote>It seems like I dropped the ball on this. Yes, I recall being fine with them otherwise.<br><br>Thanks again,<br>Hal<br><br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><div class=""><div><blockquote class=""><div class=""><div class=""><br class="">Thanks again,<br class="">Hal<br class=""><br class="">P.S. I find full-context patches in Phabricator much easier than diffs; this does not matter for the automated regression-test updates, but for the code changes, I appreciate patches there.<br class=""></div></div></blockquote>… would you prefer to see the patch in phab first? I’m happy either way. I will leave the test case changes here though, and just put the code in phab if needed and if thats ok.</div><div><br class=""></div><div>Cheers,</div><div>Pete<br class=""><blockquote class=""><div class=""><div class=""><br class=""><hr id="zwchr"><br class=""><blockquote class="">From: "Pete Cooper" <<a href="mailto:peter_cooper@apple.com" class="" target="_blank">peter_cooper@apple.com</a>><br class="">To: "Hal J. Finkel" <<a href="mailto:hfinkel@anl.gov" class="" target="_blank">hfinkel@anl.gov</a>><br class="">Cc: "Lang Hames" <<a href="mailto:lhames@apple.com" class="" target="_blank">lhames@apple.com</a>>, "LLVM Commits" <<a href="mailto:llvm-commits@lists.llvm.org" class="" target="_blank">llvm-commits@lists.llvm.org</a>>, <a href="mailto:cfe-commits@lists.llvm.org" class="" target="_blank">cfe-commits@lists.llvm.org</a><br class="">Sent: Friday, August 28, 2015 5:59:18 PM<br class="">Subject: [PATCH] Change memcpy/memmove/memset to have dest and source alignment<br class=""><br class=""><br class=""><br class="">Hi Hal/Lang<br class=""><br class="">This came out of a discussion here:<br class=""><a href="http://lists.llvm.org/pipermail/llvm-dev/2015-August/089384.html" class="" target="_blank">http://lists.llvm.org/pipermail/llvm-dev/2015-August/089384.html</a><br class=""><br class="">We want to be able to provide alignment for both the source and dest<br class="">of mem intrinsics, instead of the alignment argument which only<br class="">provides the minimum of dest/src.<br class=""><br class="">Instead of adding another argument, I removed the alignment argument<br class="">and added the align attributes to the src/dest pointer arguments.<br class=""><br class="">I’ve updated the MemIntrinsic definition to handle this, and all of<br class="">the code to now call getDestAlignment/getSrcAlignment instead of<br class="">getAlignment. For the few places where it wasn’t clear whether<br class="">dest/src was the right choice, i’ve left a FIXME and I take the<br class="">minimum of dest/src so as to match the current behavior.<br class=""><br class="">I’ve also updated the create methods in the IR builder. There is a<br class="">(temporary) class there to handle the new source alignment<br class="">parameter, as otherwise existing callers of this code could end up<br class="">having the isVolatile bool implicitly converted to the source<br class="">alignment. I’ll remove this once out-of-tree users have had a chance<br class="">to update to this patch.<br class=""><br class="">Tests were updated to automatically strip out the alignment argument<br class="">(the regex find/replace is in the patch). I then ran make check and<br class="">explicitly added back in alignments to all tests which needed it. I<br class="">tried to automatically update tests to transfer alignment to the<br class="">attributes, but that wasn’t feasible due to constant expressions<br class="">confusing regex (turns out regex doesn’t like recursion, which is<br class="">more or less what you need to get balanced braces in gep(bit<br class="">cast(inttoptr())) type expressions which we have in our tests).<br class=""><br class="">There’s also a commit which shows how auto upgrading bitcode is<br class="">handled. There was already a test for llvm 3.2 which called memcpy<br class="">so is used for this. I’ll add tests to upgrade memmove and memset<br class="">prior to committing but just wanted to get the review process<br class="">started. memmove/memset tests will be almost identical to the memcpy<br class="">test we already have. I will use 3.7 as the bitcode generator for<br class="">those tests though.<br class=""><br class="">Finally, for LLVM, i’ve got a patch to show a cleanup of<br class="">AlignmentFromAssumptions now that dest and source alignments can be<br class="">different. This is the only patch which can be committed on its own,<br class="">and after the rest. Everything else here is broken out in to<br class="">separate commits just to try ease the review process.<br class=""><br class="">For clang, the majority of changes are to pass both source and dest<br class="">alignments to the IR Builder. Again I tried to get the right ones<br class="">where I could, but if I didn’t know the code well enough I just pass<br class="">the same value to dest/src to match the current behaviour. clang<br class="">tests were all updated by hand because they all needed to check for<br class="">the alignment attribute being set correctly coming out of codegen.<br class=""><br class="">Finally, this is really just the minimum changes needed to get this<br class="">in tree. I haven’t made any effort to teach LLVM codegen about this.<br class="">That can luckily be done later, and probably independently for most<br class="">backends by their respective owners.<br class=""><br class="">Apologies for the scale of this patch. As you can imagine, there<br class="">wasn’t really a nice way to land this without excessive churn of the<br class="">test cases themselves.<br class=""><br class="">Cheers,<br class="">Pete<br class=""><br class=""><br class=""><br class=""><br class=""><br class=""><br class=""><br class=""><br class=""><br class=""><br class=""></blockquote><br class="">-- <br class="">Hal Finkel<br class="">Assistant Computational Scientist<br class="">Leadership Computing Facility<br class="">Argonne National Laboratory<br class=""></div></div></blockquote></div><br class=""></div></blockquote><br><br><br>-- <br><div><span name="x"></span>Hal Finkel<br>Assistant Computational Scientist<br>Leadership Computing Facility<br>Argonne National Laboratory<span name="x"></span><br></div></div></body></html>