def _optimize_final_module(self):

        """
        Internal: optimize this library's final module.
        """

        if config.USE_LLVM_LEGACY_PASS_MANAGER:
            self._optimize_final_module_legacy_pm()
            return


        mpm_cheap, mpb_cheap =  self._codegen._module_pass_manager(
                                           loop_vectorize=self._codegen._loopvect,
                                           slp_vectorize=False,
                                           opt=self._codegen._opt_level,
                                           cost="cheap")

        mpm_full, mpb_full = self._codegen._module_pass_manager()
        cheap_name = "Module passes (cheap optimization for refprune)"
        with self._recorded_timings.record(cheap_name, mpb_cheap):
            # 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, mpb_cheap)
        # 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(full_name, mpb_full):
            # The full optimisation suite is then run on the refop pruned IR
            mpm_full.run(self._final_module, mpb_full)

        Internal: optimize this library's final module.
        
numba/core/codegen.py