[LLVMdev] help

Chris Lattner clattner at apple.com
Fri Jul 16 08:39:41 PDT 2010

On Jul 16, 2010, at 7:40 AM, John Criswell wrote:

>> "The optional constant align argument specifies the alignment of the
>> operation (that is, the alignment of the memory address). A value of 0
>> or an omitted align argument means that the operation has the
>> preferential alignment for the target. It is the responsibility of the
>> code emitter to ensure that the alignment information is correct.
>> Overestimating the alignment results in undefined behavior.
>> Underestimating the alignment may produce less efficient code. An
>> alignment of 1 is always safe."
> After reading the description, I am left wondering why LLVM has this 
> feature and for what it is intended to be used.
> My best guess is that it allows LLVM to generate code for unaligned 
> data.  For example, on a machine that only supports loads of 32-bit 
> values at 4-byte alignment, an LLVM load instruction with an alignment 
> of 1 tells the code generator to insert byte loads and shifting 
> operations to mimic a load from a non-4-byte-aligned memory address.

Right.  It is also useful for indicating when a load has larger alignment than the base requirement, which can be useful for vectorization etc.


More information about the llvm-dev mailing list