Hi, 1. Does the alignment of the pointer returned by an AllocaInst depend on the instructions before it in the basic block? The 1st snippet below aligns 'a' correctly, while the 2nd one doesnt. (the method handle_args, only prints out the values of arguments, and returns argv unchanged). define i32 @main(i32 %argc, i8** %argv) nounwind { entry: %argc_addr = alloca i32 ; <i32*> [#uses=1] %argv_addr = alloca i8** ; <i8***> [#uses=2] %retval = alloca i32 ; <i32*> [#uses=1] %a = alloca [100 x i32], align 512 ; <[100 x i32]*> [#uses=2] %0 = call i8* @handle_args(i32 %argc, i8** %argv) ; <i8*> [#uses=1] %argv_temp = bitcast i8* %0 to i8** ; <i8**> [#uses=1] define i32 @main(i32 %argc, i8** %argv) nounwind { entry: %argc_addr = alloca i32 ; <i32*> [#uses=1] %argv_addr = alloca i8** ; <i8***> [#uses=2] %retval = alloca i32 ; <i32*> [#uses=1] %0 = call i8* @handle_args(i32 %argc, i8** %argv) ; <i8*> [#uses=1] %argv_temp = bitcast i8* %0 to i8** ; <i8**> [#uses=1] %a = alloca [100 x i32], align 512 ; <[100 x i32]*> [#uses=2] 2. I notice that the setAlignment method for an AllocaInst takes an unsigned. For 64 bit systems, alignment could potentially be larger. Is there a reason why the alignment should be restricted to this size? Thanks in advance Arushi -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100308/0c620801/attachment.html>
On 8 March 2010 19:51, Arushi Aggarwal <arushi987 at gmail.com> wrote:> > 2. I notice that the setAlignment method for an AllocaInst takes an > unsigned. For 64 bit systems, alignment could potentially be larger. Is > there a reason why the alignment should be restricted to this size? > Thanks in advance >Would it ever be practical to align a stack variable to an 8 GiB boundary? I'm curious what use case you could think of for aligning to 64 KiB or more, since the unsigned is guaranteed to allow at least 0x8000.
On Mon, Mar 8, 2010 at 7:50 PM, me22 <me22.ca at gmail.com> wrote:> On 8 March 2010 19:51, Arushi Aggarwal <arushi987 at gmail.com> wrote: > > > > 2. I notice that the setAlignment method for an AllocaInst takes an > > unsigned. For 64 bit systems, alignment could potentially be larger. Is > > there a reason why the alignment should be restricted to this size? > > Thanks in advance > > > > Would it ever be practical to align a stack variable to an 8 GiB > boundary? I'm curious what use case you could think of for aligning > to 64 KiB or more, since the unsigned is guaranteed to allow at least > 0x8000. >I need objects aligned to the closest(largest) power of two boundary and the same case also applies to globals. Arushi -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100308/25878933/attachment.html>
Hello Arushi, Are those listings your entire LLVM Assembly source? If so, you need to use a target datalayout if you have special alignment considerations on your platform. See http://llvm.org/docs/LangRef.html#datalayout for details.> >From: Arushi Aggarwal <arushi987 at gmail.com> >To: LLVM Dev <llvmdev at cs.uiuc.edu> >Sent: Mon, March 8, 2010 6:51:58 PM >Subject: [LLVMdev] Alignment for Alloca Inst in llvm 2.6 > >Hi, > >1. Does the alignment of the pointer returned by an AllocaInst depend on the instructions before it in the basic block? The 1st snippet below aligns 'a' correctly, while the 2nd one doesnt. (the method handle_args, only prints out the values of arguments, and returns argv unchanged). > >define i32 @main(i32 %argc, i8** %argv) nounwind { >entry: > %argc_addr = alloca i32 ; <i32*> [#uses=1] > %argv_addr = alloca i8** ; <i8***> [#uses=2] >> > %retval = alloca i32 ; <i32*> [#uses=1] > %a = alloca [100 x i32], align 512 ; <[100 x i32]*> [#uses=2] > %0 = call i8* @handle_args(i32 %argc, i8** %argv) ; <i8*> [#uses=1] >> > %argv_temp = bitcast i8* %0 to i8** ; <i8**> [#uses=1] > >define i32 @main(i32 %argc, i8** %argv) nounwind { >entry: > %argc_addr = alloca i32 ; <i32*> [#uses=1] >> > %argv_addr = alloca i8** ; <i8***> [#uses=2] > %retval = alloca i32 ; <i32*> [#uses=1] > %0 = call i8* @handle_args(i32 %argc, i8** %argv) ; <i8*> [#uses=1] >> > %argv_temp = bitcast i8* %0 to i8** ; <i8**> [#uses=1] > %a = alloca [100 x i32], align 512 ; <[100 x i32]*> [#uses=2] > > > > >2. I notice that the setAlignment method for an AllocaInst takes an unsigned. For 64 bit systems, alignment could potentially be larger. Is there a reason why the alignment should be restricted to this size? > > >Thanks in advance > > >Arushi-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100308/d7e28c45/attachment.html>