The Kaleidoscope example here: http://llvm.org/docs/tutorial/LangImpl7.html#adjustments defines a CreateEntryBlockAlloca() helper function that "ensures that the allocas are created in the entry block of the function." It's kid of implied, but I thought I'd ask explicitly: *must* alloca instructions be created in the entry block of a function? - Paul
On 3/29/12 11:32 AM, Paul J. Lucas wrote:> The Kaleidoscope example here: > > http://llvm.org/docs/tutorial/LangImpl7.html#adjustments > > defines a CreateEntryBlockAlloca() helper function that "ensures that the allocas are created in the entry block of the function." > > It's kid of implied, but I thought I'd ask explicitly: *must* alloca instructions be created in the entry block of a function?I believe that an alloca can occur in any basic block, but I think code generation is more efficient if the allocas are in the entry block (the code generator can insert a single instruction to adjust the stack pointer, thus allocating all stack objects in the entry block with a single machine instruction). -- John T.> > - Paul > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
On Mar 29, 2012, at 9:45 AM, John Criswell <criswell at illinois.edu> wrote:> On 3/29/12 11:32 AM, Paul J. Lucas wrote: >> The Kaleidoscope example here: >> >> http://llvm.org/docs/tutorial/LangImpl7.html#adjustments >> >> defines a CreateEntryBlockAlloca() helper function that "ensures that the allocas are created in the entry block of the function." >> >> It's kid of implied, but I thought I'd ask explicitly: *must* alloca instructions be created in the entry block of a function? > > I believe that an alloca can occur in any basic block, but I think code > generation is more efficient if the allocas are in the entry block (the > code generator can insert a single instruction to adjust the stack > pointer, thus allocating all stack objects in the entry block with a > single machine instruction).Correct :) -eric