This is an archive of the discontinued LLVM Phabricator instance.

Use value semantics for list of ScopStmt(s) instead of std::owningptr
ClosedPublic

Authored by grosser on May 26 2015, 2:52 PM.

Details

Summary

David Blaike suggested this as an alternative to the use of owningptr(s) for our
memory management, as value semantics allow to avoid the additional interface
complexity caused by owningptr while still providing similar memory consistency
guarantees. We could also have used a std::vector, but the use of std::vector
would yield possibly changing pointers which currently causes problems as for
example the memory accesses carry pointers to their parent statements. Such
pointers should not change.

Diff Detail

Repository
rL LLVM

Event Timeline

grosser updated this revision to Diff 26541.May 26 2015, 2:52 PM
grosser retitled this revision from to Use value semantics for list of ScopStmt(s) instead of std::owningptr.
grosser updated this object.
grosser edited the test plan for this revision. (Show Details)
grosser added reviewers: jdoerfert, dblaikie.
grosser added subscribers: pollydev, Unknown Object (MLST).
dblaikie edited edge metadata.May 26 2015, 3:00 PM

Looks great - deque's a great option (imho - opinions vary, of course) when you're never removing things but are adding new things that all need consistent pointer identity.

dblaikie accepted this revision.May 26 2015, 3:19 PM
dblaikie edited edge metadata.
This revision is now accepted and ready to land.May 26 2015, 3:19 PM
jdoerfert accepted this revision.May 26 2015, 4:14 PM
jdoerfert edited edge metadata.

I think this is much more intuitive than the smart pointer version.

If you do only worry about the order but you would like to use a list, define the begin()/end() function of a Scop as rbegin()/rend() of the underlying list of scopstmts, that should give us the same order but avoid the deque (which isn't that bad I guess).

lib/Analysis/ScopInfo.cpp
2024 ↗(On Diff #26541)

Why no const &?

This revision was automatically updated to reflect the committed changes.

If you do only worry about the order but you would like to use a list, define the begin()/end() function of a Scop as rbegin()/rend() of the underlying list of scopstmts, that should give us the same order but avoid the deque (which isn't that bad I guess).

I decided to stay with the deque as the use of rbegin()/rend() is possible, but would (only slightly) increase complexity. As I doubt this has any performance effect, I decided to minimize complexity.

lib/Analysis/ScopInfo.cpp
2024 ↗(On Diff #26541)

Changed.