def _optimize_final_module_legacy_pm(self):

        """
        Internal: optimize this library's final module using llvm's legacy pass manager
        """
        mpm_cheap = self._codegen._module_pass_manager_legacy(
                                    loop_vectorize=self._codegen._loopvect,
                                    slp_vectorize=False,
                                    opt=self._codegen._opt_level,
                                    cost="cheap")

        mpm_full = self._codegen._module_pass_manager_legacy()

        cheap_name = "Module passes (cheap optimization for refprune)"
        with self._recorded_timings.record_legacy(cheap_name):
            # A cheaper optimisation pass is run first to try and get as many
            # refops into the same function as possible via inlining
            mpm_cheap.run(self._final_module)
        # Refop pruning is then run on the heavily inlined function
        if not config.LLVM_REFPRUNE_PASS:
            self._final_module = remove_redundant_nrt_refct(self._final_module)
        full_name = "Module passes (full optimization)"
        with self._recorded_timings.record_legacy(full_name):
            # The full optimisation suite is then run on the refop pruned IR
            mpm_full.run(self._final_module)

        Internal: optimize this library's final module using llvm's legacy pass manager
        
numba/core/codegen.py