nir: Misc. infinite loop fixes
This MR fixes a bunch of bugs which came up in the context of infinite loops in shaders.
The one patch I'm not so sure about is "nir: Don't infinitely recurse in lower_ssa_defs_to_regs_block". It seems like it'd be cleaner to actually detect back-edges but doing that is easier said than done.