This is an archive of the discontinued LLVM Phabricator instance.

some StmtExprs do not have side-effects
ClosedPublic

Authored by scott-0 on Jun 3 2015, 3:44 AM.

Details

Summary

Refine Expr::HasSideEffects to correct identify StmtExprs that do not have side-effects.

[Depends on http://reviews.llvm.org/D10210.]

Diff Detail

Repository
rL LLVM

Event Timeline

scott-0 updated this revision to Diff 27032.Jun 3 2015, 3:44 AM
scott-0 retitled this revision from to some StmtExprs do not have side-effects.
scott-0 updated this object.
scott-0 edited the test plan for this revision. (Show Details)
scott-0 added a subscriber: Unknown Object (MLST).

I see two typos in comments already "side-efect" and "warnig" -- I'll be sure to fix those.

rs added a subscriber: rs.Jun 3 2015, 4:19 AM

Just one small comment.

lib/AST/Expr.cpp
2904 ↗(On Diff #27032)

Remove newline

rs added a comment.Jun 3 2015, 5:32 AM

LGTM, but someone else should approve as well

rsmith added a subscriber: rsmith.Jun 4 2015, 2:26 PM
rsmith added inline comments.
lib/AST/Expr.cpp
2886–2887 ↗(On Diff #27032)

{ goes on previous line.

2901 ↗(On Diff #27032)

Remove this call: you've already completely checked E and all of its subexpressions for side-effects. Calling into the base class here will result in a (worst-case) exponential-time search as both VisitStmt and HasSideEffects will recurse into subexpressions at every level.

scott-0 updated this revision to Diff 27202.Jun 5 2015, 8:53 AM

Thanks for the reviews! I have addressed the review comments. (But I still need a review on the prereq differential http://reviews.llvm.org/D10210)

rsmith accepted this revision.Jun 5 2015, 12:19 PM
rsmith added a reviewer: rsmith.

LGTM

lib/AST/Expr.cpp
2899–2900 ↗(On Diff #27202)

Maybe only call E->HasSideEffect(...) if HasSideEffect is false. There's no point doing more checking once we've already found a side-effect.

This revision is now accepted and ready to land.Jun 5 2015, 12:19 PM
This revision was automatically updated to reflect the committed changes.