]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-115859: Disable the tier 2 redundancy eliminator by default (GH-115860)
authorKen Jin <kenjin@python.org>
Fri, 23 Feb 2024 18:43:52 +0000 (02:43 +0800)
committerGitHub <noreply@github.com>
Fri, 23 Feb 2024 18:43:52 +0000 (18:43 +0000)
Lib/test/test_capi/test_opt.py
Python/optimizer_analysis.c

index 38c6fa4b47d0c9261633e617d70d5cf2129d8dc9..25fc36dec93ddcbe173872012be8df19a4043ca8 100644 (file)
@@ -4,6 +4,7 @@ import sys
 import textwrap
 import unittest
 import gc
+import os
 
 import _testinternalcapi
 
@@ -568,6 +569,8 @@ class TestUops(unittest.TestCase):
         count = ops.count("_GUARD_IS_TRUE_POP") + ops.count("_GUARD_IS_FALSE_POP")
         self.assertLessEqual(count, 2)
 
+
+@unittest.skipIf(os.getenv("PYTHONUOPSOPTIMIZE", default=0) == 0, "Needs uop optimizer to run.")
 class TestUopsOptimization(unittest.TestCase):
 
     def _run_with_optimizer(self, testfunc, arg):
index 9503dcc74656cd8825ece7de3e196e024a349663..47bfc8cf1061d924fe463cbe111394c410d4559d 100644 (file)
@@ -810,9 +810,12 @@ _Py_uop_analyze_and_optimize(
 
     peephole_opt(frame, buffer, buffer_size);
 
-    err = uop_redundancy_eliminator(
-        (PyCodeObject *)frame->f_executable, buffer,
-        buffer_size, curr_stacklen, dependencies);
+    char *uop_optimize = Py_GETENV("PYTHONUOPSOPTIMIZE");
+    if (uop_optimize != NULL && *uop_optimize > '0') {
+        err = uop_redundancy_eliminator(
+            (PyCodeObject *)frame->f_executable, buffer,
+            buffer_size, curr_stacklen, dependencies);
+    }
 
     if (err == 0) {
         goto not_ready;