summaryrefslogtreecommitdiffstats
path: root/elaborate.cxx
diff options
context:
space:
mode:
authorfche <fche>2007-09-21 18:03:28 +0000
committerfche <fche>2007-09-21 18:03:28 +0000
commit739a3e814f64578666c4d2e25a2bab2b771a8559 (patch)
tree2e9c5913775866a3dbddd4cb954c06f5a678a256 /elaborate.cxx
parent5d1374bb3ac11d922f22d4904b43242a1a6eb94f (diff)
downloadsystemtap-steved-739a3e814f64578666c4d2e25a2bab2b771a8559.tar.gz
systemtap-steved-739a3e814f64578666c4d2e25a2bab2b771a8559.tar.xz
systemtap-steved-739a3e814f64578666c4d2e25a2bab2b771a8559.zip
rhbz 300121: optimization bug
Diffstat (limited to 'elaborate.cxx')
-rw-r--r--elaborate.cxx39
1 files changed, 38 insertions, 1 deletions
diff --git a/elaborate.cxx b/elaborate.cxx
index 094fbbac..621e1a72 100644
--- a/elaborate.cxx
+++ b/elaborate.cxx
@@ -1577,6 +1577,9 @@ struct dead_stmtexpr_remover: public traversing_visitor
session(s), relaxed_p(r), current_stmt(0) {}
void visit_block (block *s);
+ void visit_if_statement (if_statement* s);
+ void visit_foreach_loop (foreach_loop *s);
+ void visit_for_loop (for_loop *s);
// XXX: and other places where stmt_expr's might be nested
void visit_expr_statement (expr_statement *s);
@@ -1595,6 +1598,39 @@ dead_stmtexpr_remover::visit_block (block *s)
}
}
+void
+dead_stmtexpr_remover::visit_if_statement (if_statement *s)
+{
+ statement** last_stmt = current_stmt;
+ current_stmt = & s->thenblock;
+ s->thenblock->visit (this);
+ if (s->elseblock)
+ {
+ current_stmt = & s->elseblock;
+ s->elseblock->visit (this);
+ }
+ current_stmt = last_stmt;
+}
+
+void
+dead_stmtexpr_remover::visit_foreach_loop (foreach_loop *s)
+{
+ statement** last_stmt = current_stmt;
+ current_stmt = & s->block;
+ s->block->visit (this);
+ current_stmt = last_stmt;
+}
+
+void
+dead_stmtexpr_remover::visit_for_loop (for_loop *s)
+{
+ statement** last_stmt = current_stmt;
+ current_stmt = & s->block;
+ s->block->visit (this);
+ current_stmt = last_stmt;
+}
+
+
void
dead_stmtexpr_remover::visit_expr_statement (expr_statement *s)
@@ -1614,7 +1650,8 @@ dead_stmtexpr_remover::visit_expr_statement (expr_statement *s)
varuse_collecting_visitor vut;
s->value->visit (& vut);
- if (vut.side_effect_free_wrt (focal_vars))
+ if (vut.side_effect_free_wrt (focal_vars) &&
+ *current_stmt == s) // we're not nested any deeper than expected
{
if (session.verbose>2)
clog << "Eliding side-effect-free expression "