I have a very simple kernel that exposes a bug in the backend I am working on and I cannot figure out how to fix the problem. I've narrowed down the issue to be with dynamic stack allocation. The problem I am having is that if I declare a variable inside of the loop, the code that my backend generates produces incorrect results; however, if I move this declaration outside of the loop the generated code works correctly. I've attached the two files two files. My backend does not have a stack pointer and no memory allocations. So I really can't use any of the approaches of the currently implemented backends. What I would like to do is to just turn all of the stack allocations into register moves to virtual registers. Any tips or hints would be greatly appreciated. Thanks, Micah Villmow Systems Engineer Advanced Technology & Performance Advanced Micro Devices Inc. S1-609 One AMD Place Sunnyvale, CA. 94085 P: 408-749-3966 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090112/b364f607/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: a-bad.ll Type: application/octet-stream Size: 5131 bytes Desc: a-bad.ll URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090112/b364f607/attachment.obj> -------------- next part -------------- A non-text attachment was scrubbed... Name: a-good.ll Type: application/octet-stream Size: 5131 bytes Desc: a-good.ll URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090112/b364f607/attachment-0001.obj>
On Mon, Jan 12, 2009 at 8:26 AM, Villmow, Micah <Micah.Villmow at amd.com> wrote:> I have a very simple kernel that exposes a bug in the backend I am working > on and I cannot figure out how to fix the problem. I've narrowed down the > issue to be with dynamic stack allocation. The problem I am having is that > if I declare a variable inside of the loop, the code that my backend > generates produces incorrect results; however, if I move this declaration > outside of the loop the generated code works correctly.I haven't looked carefully, but alloca's outside of the entry block are treated significantly differently from those outside of it. The issue is that the loop could capture the pointer, so it needs a new memory location every trip through the loop.> I've attached the two files two files. > > My backend does not have a stack pointer and no memory allocations.If you can't do allocation, you shouldn't try to deal with IL with allocas outside of the entry block. -Eli