Extract functionality to `lang::ir::utils` (#1392)

19 jobs for master in 1 minute and 5 seconds (queued for 5 seconds)