[llvm-dev] Change memcpy/memmove/memset to have dest and source alignment attributes

Daniel Neilson via llvm-dev llvm-dev at lists.llvm.org
Thu Jan 18 21:38:35 PST 2018

On Jan 18, 2018, at 10:48 PM, Chris Lattner <clattner at nondot.org<mailto:clattner at nondot.org>> wrote:

On Jan 18, 2018, at 7:45 AM, Daniel Neilson via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> wrote:

Hi all,
 This change has been reviewed, and appears to be ready to land (review available here if anyone still wants to chime in: https://reviews.llvm.org/D41675 ). The process that we’re going to use for landing this will take a few steps. To wit:

Step 1) Remove align argument, and add align attribute to pointer args.

What does this mean? Are you suggesting that alignment become part of PointerType?  That would introduce lots of problems, because unaligned and aligned pointers would require casts, which then interfere with optimizations.

Bad communication on my part; perhaps, I used non-standard terminology to refer to a CallInst’s parameter attributes. I am not touching the definition of PointerType in any way; I don’t see the need, and I’m not that ambitious. ;-) Currently, a call to @llvm.memcpy might look like this:

  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 100, i32 4, i1 false)

where the ‘i32 4’ argument (2nd last arg) is the minimum alignment of both of the pointer args (%src & %dest). After this change, this same call will instead read:

  call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 100, i1 false)

where we use an align attribute on first two function-call arguments. (i.e CallInst::addParamAttr(0, …) & CallInst::addParamAttr(1, …))

 That is all that this first step is doing. With the caveat that we, temporarily (basically for the purposes of testing the initial change), will require that the alignment attribute on both of the pointer args be the same value. So, nothing like this for now:

  call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %dest, i8* align 4 %src, i32 100, i1 false)

 The alignments-equal restriction will be lifted in step 2, which should happen next week.

 Is that clearer?


Daniel Neilson, Ph.D.
Azul Systems

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180119/fef79da7/attachment.html>

More information about the llvm-dev mailing list