Author: Armin Rigo <ar...@tunes.org> Branch: shadowstack-perf-2 Changeset: r84379:e0900fa2a687 Date: 2016-05-11 17:04 +0200 http://bitbucket.org/pypy/pypy/changeset/e0900fa2a687/
Log: Test that is_trivial_rewrite() is correctly used 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 @@ -65,6 +65,19 @@ pred = find_predecessors(graph, [(graph.returnblock, graph.getreturnvar())]) assert summary(pred) == {'a': 4, 'c': 1, 'v': 1} +def test_find_predecessors_trivial_rewrite(): + def f(a, b): # 'b' in empty startblock + while a > 100: # 'b' + a -= 2 # 'b' + c = llop.same_as(lltype.Signed, b) # 'c', 'b' + while b > 10: # 'c' + b -= 2 # 'c' + d = llop.same_as(lltype.Signed, c) # 'd', 'c' + return d # 'v' is the return var + graph = make_graph(f, [int, int]) + pred = find_predecessors(graph, [(graph.returnblock, graph.getreturnvar())]) + assert summary(pred) == {'b': 4, 'c': 4, 'd': 1, 'v': 1} + def test_find_successors_1(): def f(a, b): return a + b @@ -95,6 +108,19 @@ succ = find_successors(graph, [(graph.startblock, graph.getargs()[0])]) assert summary(succ) == {'a': 5} +def test_find_successors_trivial_rewrite(): + def f(a, b): # 'b' in empty startblock + while a > 100: # 'b' + a -= 2 # 'b' + c = llop.same_as(lltype.Signed, b) # 'c', 'b' + while b > 10: # 'c', 'b' + b -= 2 # 'c', 'b' + d = llop.same_as(lltype.Signed, c) # 'd', 'c' + return d # 'v' is the return var + graph = make_graph(f, [int, int]) + pred = find_successors(graph, [(graph.startblock, graph.getargs()[1])]) + assert summary(pred) == {'b': 6, 'c': 4, 'd': 1, 'v': 1} + def test_interesting_vars_0(): def f(a, b): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit