[LLVMdev] Alignments in LLVM IR

Jera Hensel jera.hensel at gmail.com
Tue Apr 15 03:41:10 PDT 2014


Hello,

I am currently writing my Master's Thesis on a topic regarding the analysis of memory safety and termination of LLVM programs. This includes alignments in LLVM IR, but I am not sure if I understand their semantics correctly. I have written a program (see attachment) which uses the instruction

  store i32 1, i32* %7, align 4

to store an integer at an address that I forced to be uneven, and compiled it with clang. The result is that the integer is stored exactly there, which I expected for alignment 1 but not for alignment 4. Changing the alignment to any other size does not have any effect.

This leads to my questions:

- Do alignments provide additional semantics to be obeyed by the compiler or are they just hints that can be ignored?
- What is the semantics of alignments from the perspective of an IR analyzer as opposed to an IR emitter?
- Can you give me an example where wrong alignments lead to undefined behavior?

Kind regards,
Jera

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test1.c
Type: application/octet-stream
Size: 206 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140415/668a682d/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test1.ll
Type: application/octet-stream
Size: 2082 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140415/668a682d/attachment-0001.obj>


More information about the llvm-dev mailing list