issues with my DYNAMIC_STACKALLOC impl

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

a-bad.ll (5.01 KB)

a-good.ll (5.01 KB)

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