def _optimize_functions_legacy_pm(self, ll_module):
        """
        Internal: run function-level optimizations inside *ll_module*
        using llvm's legacy pass manager
        """
        # Enforce data layout to enable layout-specific optimizations
        ll_module.data_layout = self._codegen._data_layout
        with self._codegen._function_pass_manager_legacy(ll_module) as fpm:
            # Run function-level optimizations to reduce memory usage and improve
            # module-level optimization.
            for func in ll_module.functions:
                k = f"Function passes on {func.name!r}"
                with self._recorded_timings.record_legacy(k):
                    fpm.initialize()
                    fpm.run(func)
                    fpm.finalize()

        Internal: run function-level optimizations inside *ll_module*
        using llvm's legacy pass manager
        
numba/core/codegen.py