[LLVMdev] RFC: llvm-convert.cpp Patch

Duncan Sands baldrick at free.fr
Fri Oct 26 13:07:20 PDT 2007


> llvm.memcpy docs says, " the caller guarantees that both the source  
> and destination pointers are aligned to that boundary.". Would it  
> possible to run into a situation where selecting min. of src and dest  
> alignment will not meet this criteria ?

Since alignments are always powers of 2, the minimum of two alignments
divides both of them.  So no, this is not possible.  However you do
indeed have to be careful - just yesterday I noticed a mistake in LLVM
in which it takes the minimum of an alignment and an object size to
calculate a new alignment, which might be wrong if the object size is
not a power of 2.  Think of an 8 byte aligned pointer to an x86 long double
(which has size 12 on some machines), and update the pointer so it points
to the following long double.  What is the new alignment?  It is not 8,
the minimum of 8 and 12, it is 4.  I will send in a patch if I remember :)

Ciao,

Duncan.



More information about the llvm-dev mailing list