Can I transfer the alloca in loop to static alloca in functionInfo?

I get a failed case because the alloca instruction in loop in my LLVM IR file. Because this case the backend cannot support the DYNAMIC_STACKALLOCA. Next, I write a simple pass to move alloca in loop to entry block. Now, some case is ok, another is also failed, I am confused about this method is feasible?

If a user calls alloca() in a loop, they expect each call to return a different pointer. If you hoist to the entry block, all the calls return the same pointer. That’s not going to work in general.

The only way to correctly lower dynamic alloca calls is to actually use dynamic allocation. For example, DYNAMIC_STACKALLOCA, or malloc().

You have to expand the alloca, if you cannot prove the alloca is noescape. So, allocate #iterations * alloc_size in the entry then in the loop move the pointer by alloc_size every iteration.