This function is declared in multiple places. The instances inside `compiler` are slightly different to those in `compiler-cli`. So this commit consolidates them into two reusable functions. PR Close #41080
This function is declared in multiple places. The instances inside `compiler` are slightly different to those in `compiler-cli`. So this commit consolidates them into two reusable functions. PR Close #41080