glsl: implement and use a nir version of function recursion detection
This just implements the existing glsl ir algorithm in nir. Doing the detecting in nir is another step towards converting to NIR at compile time.
Note I don't think this series can be safely enabled until !27108 (merged) lands as detection should be run before function inlining