[Chapel Merge] Handle variables in the inner loops properly while

Branch: refs/heads/main
Revision: fee983b
Author: e-kayrakli
Link: Unavailable
Log Message:

Merge pull request #19722 from e-kayrakli/gpu-def-in-inner-block

Handle variables in the inner loops properly while creating GPU kernels

This PR fixes a bug that shows up when the inner loops in kernels have variable declarations.

foreach i in 1..10 {
  for j in 1..10 {
    var x;
    ...
  }
}

The outliner was only checking whether a symbol's defpoint's enclosing loop is the order-independent loop we are outlining while determining whether that symbol is an outer symbol that needs to be passed to the kernel as an argument. Obviously, that's too simple of a check because in the snippet above x's enclosing loop is not the loop we are outlining, but it is an inner loop to that.

This PR walks up the tree to figure out whether to pass the symbol by an argument to the kernel.

[Reviewed by @stonea]

Test: