[pypy-commit] pypy shadowstack-perf-2: (remi, arigo around) fix for a "corner case" of having a startblock

arigo pypy.commits at gmail.com
Sat Mar 4 06:37:12 EST 2017


Author: Armin Rigo <arigo at tunes.org>
Branch: shadowstack-perf-2
Changeset: r90530:f2ae43e31f49
Date: 2017-03-04 12:35 +0100
http://bitbucket.org/pypy/pypy/changeset/f2ae43e31f49/

Log:	(remi, arigo around) fix for a "corner case" of having a startblock
	that is also reached from the rest of the graph

diff --git a/rpython/memory/gctransform/shadowcolor.py b/rpython/memory/gctransform/shadowcolor.py
--- a/rpython/memory/gctransform/shadowcolor.py
+++ b/rpython/memory/gctransform/shadowcolor.py
@@ -233,6 +233,7 @@
     if not regalloc:
         return
 
+    insert_empty_startblock(graph)
     entrymap = mkentrymap(graph)
     inputvars = {}    # {inputvar: (its block, its index in inputargs)}
     for block in graph.iterblocks():
diff --git a/rpython/memory/gctransform/test/test_shadowcolor.py b/rpython/memory/gctransform/test/test_shadowcolor.py
--- a/rpython/memory/gctransform/test/test_shadowcolor.py
+++ b/rpython/memory/gctransform/test/test_shadowcolor.py
@@ -671,6 +671,26 @@
     add_enter_leave_roots_frame(graph, regalloc, Constant('fake gcdata'))
     postprocess_double_check(graph)
 
+def test_bug_2():
+    def f(w_tup):
+        while True:
+            llop.gc_push_roots(lltype.Void, w_tup)
+            llop.gc_pop_roots(lltype.Void, w_tup)
+
+    graph = make_graph(f, [llmemory.GCREF])
+    assert not graph.startblock.operations
+    # this test is about what occurs if the startblock of the graph
+    # is also reached from another block.  None of the 'simplify'
+    # functions actually remove that, but the JIT transformation can...
+    graph.startblock = graph.startblock.exits[0].target
+
+    regalloc = allocate_registers(graph)
+    expand_push_roots(graph, regalloc)
+    move_pushes_earlier(graph, regalloc)
+    expand_pop_roots(graph, regalloc)
+    add_enter_leave_roots_frame(graph, regalloc, Constant('fake gcdata'))
+    postprocess_double_check(graph)
+
 def test_add_enter_roots_frame_remove_empty():
     class W:
         pass


More information about the pypy-commit mailing list