[pypy-commit] pypy ssa-flow: Assign variable names more locally

rlamy noreply at buildbot.pypy.org
Wed Nov 12 19:43:14 CET 2014


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: ssa-flow
Changeset: r74492:fa7224bd0d4e
Date: 2013-08-16 01:53 +0100
http://bitbucket.org/pypy/pypy/changeset/fa7224bd0d4e/

Log:	Assign variable names more locally

diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -487,10 +487,6 @@
         else:
             newstate = currentstate.copy()
             newblock = SpamBlock(newstate)
-            varnames = self.pycode.co_varnames
-            for name, w_value in zip(varnames, newstate.mergeable):
-                if isinstance(w_value, Variable):
-                    w_value.rename(name)
             # unconditionally link the current block to the newblock
             outputargs = currentstate.getoutputargs(newstate)
             link = Link(outputargs, newblock)
@@ -929,6 +925,8 @@
         w_newvalue = self.popvalue()
         assert w_newvalue is not None
         self.locals_stack_w[varindex] = w_newvalue
+        if isinstance(w_newvalue, Variable):
+            w_newvalue.rename(self.getlocalvarname(varindex))
 
     def STORE_GLOBAL(self, nameindex):
         varname = self.getname_u(nameindex)
diff --git a/rpython/flowspace/framestate.py b/rpython/flowspace/framestate.py
--- a/rpython/flowspace/framestate.py
+++ b/rpython/flowspace/framestate.py
@@ -13,7 +13,7 @@
         newstate = []
         for w in self.mergeable:
             if isinstance(w, Variable):
-                w = Variable()
+                w = Variable(w)
             newstate.append(w)
         return FrameState(newstate, self.blocklist, self.next_instr)
 
@@ -66,14 +66,14 @@
 
 def union(w1, w2):
     "Union of two variables or constants."
+    if w1 == w2:
+        return w1
     if w1 is None or w2 is None:
         return None  # if w1 or w2 is an undefined local, we "kill" the value
                      # coming from the other path and return an undefined local
     if isinstance(w1, Variable) or isinstance(w2, Variable):
         return Variable()  # new fresh Variable
     if isinstance(w1, Constant) and isinstance(w2, Constant):
-        if w1 == w2:
-            return w1
         # FlowSignal represent stack unrollers in the stack.
         # They should not be merged because they will be unwrapped.
         # This is needed for try:except: and try:finally:, though


More information about the pypy-commit mailing list