diff options
author | Stan Cox <scox@redhat.com> | 2008-05-21 09:22:17 -0400 |
---|---|---|
committer | Stan Cox <scox@redhat.com> | 2008-05-21 09:22:17 -0400 |
commit | fcc7aafa64338bdbac356dd509acd20f35563ef5 (patch) | |
tree | 452151d41b4978bde87eb133018737821e4c9aec | |
parent | aa215f04d4546c5c810d7accde3ad108e855f397 (diff) | |
download | systemtap-steved-fcc7aafa64338bdbac356dd509acd20f35563ef5.tar.gz systemtap-steved-fcc7aafa64338bdbac356dd509acd20f35563ef5.tar.xz systemtap-steved-fcc7aafa64338bdbac356dd509acd20f35563ef5.zip |
Optimize compound and binary expression assignments.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | elaborate.cxx | 13 | ||||
-rw-r--r-- | testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | testsuite/systemtap.base/optim_arridx.exp | 2 | ||||
-rw-r--r-- | testsuite/systemtap.base/optim_arridx.stp | 6 |
5 files changed, 32 insertions, 0 deletions
@@ -1,3 +1,8 @@ +2008-05-21 Stan Cox <scox@redhat.com> + + * elaborate.cxx (dead_assignment_remover::visit_binary_expression): New. + (dead_assignment_remover::visit_assignment): Allow rhs simplification. + 2008-05-20 Tim Moore <timoore@redhat.com> * configure.ac: Check for tr1/unordered_map header. diff --git a/elaborate.cxx b/elaborate.cxx index 4bc43832..87deb9cf 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -1696,6 +1696,7 @@ struct dead_assignment_remover: public traversing_visitor // called with null current_expr. void visit_assignment (assignment* e); + void visit_binary_expression (binary_expression* e); void visit_arrayindex (arrayindex* e); void visit_functioncall (functioncall* e); void visit_if_statement (if_statement* e); @@ -1726,6 +1727,7 @@ dead_assignment_remover::visit_assignment (assignment* e) { expression** last_expr = current_expr; e->left->visit (this); + current_expr = &e->right; e->right->visit (this); current_expr = last_expr; if (vut.read.find(leftvar) == vut.read.end()) // var never read? @@ -1759,6 +1761,17 @@ dead_assignment_remover::visit_assignment (assignment* e) } void +dead_assignment_remover::visit_binary_expression (binary_expression* e) +{ + expression** last_expr = current_expr; + current_expr = &e->left; + e->left->visit (this); + current_expr = &e->right; + e->right->visit (this); + current_expr = last_expr; +} + +void dead_assignment_remover::visit_arrayindex (arrayindex *e) { symbol *array = NULL; diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index 3c74b83d..a576550e 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-05-21 Stan Cox <scox@redhat.com> + + * systemtap.base/optim_arridx.stp: Test compound assignment and + binary expression. + * systemtap.base/optim_arridx.exp: Likewise. + 2008-05-21 Mark Wielaard <mwielaard@redhat.com> * buildok/aux_syscalls-embedded.stp: Don't check _struct_utimbuf_u diff --git a/testsuite/systemtap.base/optim_arridx.exp b/testsuite/systemtap.base/optim_arridx.exp index 447ad1f4..b7c5c360 100644 --- a/testsuite/systemtap.base/optim_arridx.exp +++ b/testsuite/systemtap.base/optim_arridx.exp @@ -45,6 +45,8 @@ for (1; (bb) < (10); (bb)++) (cc) += (bb) for ((dd) = (1); (dd) < (10); 1) (dd) += (1) if (1) (ee) = (1) +(cc) = ((dd) = (5)) +(cc) = ((4) + ((cc) = (1))) printf("%d %d %d %d %d", aa, bb, cc, dd, ee) exit() } diff --git a/testsuite/systemtap.base/optim_arridx.stp b/testsuite/systemtap.base/optim_arridx.stp index 4551bb3e..20710c7f 100644 --- a/testsuite/systemtap.base/optim_arridx.stp +++ b/testsuite/systemtap.base/optim_arridx.stp @@ -34,6 +34,12 @@ probe begin { if (elide_global_b = 1) ee = 1 + // compound assignment + cc = elide_gg=dd=5 + + // binary expression + cc = ((elide_hh = 4) + (cc = 1)) + printf("%d %d %d %d %d", aa, bb, cc, dd, ee) exit () } |