[LLVMdev] Alignments in LLVM IR

Reid Kleckner rnk at google.com
Tue Apr 15 21:05:56 PDT 2014


On Tue, Apr 15, 2014 at 5:41 PM, Duncan P. N. Exon Smith <
dexonsmith at apple.com> wrote:

>
> On 2014-Apr-15, at 3:41, Jera Hensel <jera.hensel at gmail.com> wrote:
>
> > - Do alignments provide additional semantics to be obeyed by the
> compiler or are they just hints that can be ignored?
>
> Depends on where the alignment is used.  For stores [1] it's a hint, as
> John and Tim said.  For global variables [2] it's an additional semantic.
>
> [1]: http://llvm.org/docs/LangRef.html#store-instruction
> [2]: http://llvm.org/docs/LangRef.html#global-variables


'align' on stores is not a hint: "Overestimating the alignment results in
undefined behavior."

Unaligned stores can trap on some ISAs (not many that matter), but I
believe we also try to use this information to optimize %b to zero here:
store i32* %p, i32 0, align 4
%i = ptrtoint i32* %p to i64
%b = and i64 %i, i64 3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140415/61a24895/attachment.html>


More information about the llvm-dev mailing list