From 42f47d38f00b4f557288d41319bcec00ed419d36 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Fri, 11 Jan 2019 02:07:54 +0100 Subject: [PATCH] Fix swaps and other misoptimizations This undoes 454d44e85fb7e70d4f330da9054850f85a9482ff --- lslopt/lsldeadcode.py | 19 ++++++++++++------- unit_tests/coverage.suite/inline-4.out | 3 ++- .../declaration-chain-dcr.out | 5 ++++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lslopt/lsldeadcode.py b/lslopt/lsldeadcode.py index 728c17a..59cf2fa 100644 --- a/lslopt/lsldeadcode.py +++ b/lslopt/lsldeadcode.py @@ -322,13 +322,18 @@ class deadcode(object): node = sym['W'] nt = node.nt - while nt == 'IDENT': - # Follow the chain of identifiers all the way to the original - if self.symtab[node.scope][node.name].get('W', False) is False: - return sym - sym = self.symtab[node.scope][node.name] - node = sym['W'] - nt = node.nt + # This screws up swaps. See + # unit_tests/regression.suite/aggressive-local-removal.lsl + # It can't be done without a reliable CFG-based method (SSA or + # the like). + +# while nt == 'IDENT': +# # Follow the chain of identifiers all the way to the original +# if self.symtab[node.scope][node.name].get('W', False) is False: +# return sym +# sym = self.symtab[node.scope][node.name] +# node = sym['W'] +# nt = node.nt if nt == 'CONST': tcurnode = curnode.t diff --git a/unit_tests/coverage.suite/inline-4.out b/unit_tests/coverage.suite/inline-4.out index 52d485c..6e9a45b 100644 --- a/unit_tests/coverage.suite/inline-4.out +++ b/unit_tests/coverage.suite/inline-4.out @@ -17,8 +17,9 @@ default { { { + integer f2param = 4; { - llOwnerSay("f2:" + "4"); + llOwnerSay("f2:" + (string)f2param); } } { diff --git a/unit_tests/regression.suite/declaration-chain-dcr.out b/unit_tests/regression.suite/declaration-chain-dcr.out index 0cadfac..2a7af0c 100644 --- a/unit_tests/regression.suite/declaration-chain-dcr.out +++ b/unit_tests/regression.suite/declaration-chain-dcr.out @@ -2,6 +2,9 @@ default { state_entry() { - llOwnerSay("x" + "3"); + integer b = 3; + integer c = b; + integer d = c; + llOwnerSay("x" + (string)d); } }