[AMDGPU] Preserve resource requirements through call-graph cycles (#221625)
When a function closes a cycle in the call graph, the cycle's register
counts are flattened to a constant (#142766), which drops callees whose
symbols are not defined yet, and the flags drop the cyclic callee
entirely. A kernel can then get too few VGPRs and no dynamic stack for
a function it reaches through the cycle.
Flatten the function's whole max() or or() expression instead: fold the
constants, skip the function's own symbol and keep the symbols that are
not defined yet. Named barrier counts in a cycle are flattened the same
way instead of using the module maximum.
The private segment size also drops the cyclic callee, so set
has_recursion in that case to request a dynamic stack on code object V5
and later. Since that sets has_recursion for more kernels, restore the
V5 check on the dynamic stack bit (D134714), which #94788 dropped, so V4
object files no longer set that reserved bit.