In the insrtuction %1 = load i32** %y_addr, align 4 what is the meaning of align 4?? Can anyone explain? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100716/ef433d43/attachment.html>
You may want first to give a look at the existing documentation: http://www.llvm.org/docs/LangRef.html#i_load A second step could be googling for "memory alignment". -- Arnaud de Grandmaison ________________________________ From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of RAJWINDER SINGH Sent: Friday, July 16, 2010 9:36 AM To: llvmdev at cs.uiuc.edu Subject: [LLVMdev] help In the insrtuction %1 = load i32** %y_addr, align 4 what is the meaning of align 4?? Can anyone explain? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100716/836fb9b5/attachment.html>
> In the insrtuction > %1 = load i32** %y_addr, align 4 > what is the meaning of align 4?? > Can anyone explain? >From http://llvm.org/docs/LangRef.html#i_load :"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." -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University
Anton Korobeynikov wrote:>> In the insrtuction >> %1 = load i32** %y_addr, align 4 >> what is the meaning of align 4?? >> Can anyone explain? >> > >From http://llvm.org/docs/LangRef.html#i_load : > > "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. Is my guess correct, or does this alignment feature fulfill other needs? -- John T.