This is a redacted version of my original pass, modeled after Daniel Berlin's comments.
Please take a closer look.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
include/llvm/Transforms/Scalar/MergedLoadStoreMotion.h | ||
---|---|---|
95 ↗ | (On Diff #61052) | Any reason we need to make it a member field, instead of just being created as a local instance at the time it is run? With that there is no need to hoist the class into the header. |
A couple comments.
include/llvm/Transforms/Scalar/MergedLoadStoreMotion.h | ||
---|---|---|
95 ↗ | (On Diff #61052) | In this case it does not matter. In other cases, it is preferable to .clear() maps/vectors between calls to run instead of reallocating from scratch (to save malloc traffic). E.g. SLPVectorizer in r272766. I have not done measurement to see if this optimization helps, but it is the existing state of things. |
lib/Transforms/Scalar/MergedLoadStoreMotion.cpp | ||
530 ↗ | (On Diff #61052) | Use the new-PM class as the Impl (or just make the Impl local to runOnFunction). See e.g. r272757 |
Make Impl local to runOnFunction()/run() as suggested by David/Sean.
I was worried about an increased malloc() activity so I measured but I wasn't able to discover any substantial difference.
We can re-evaluate in the future, if needed.
Also, Daniel needs to sign-off this patch before it can go in.
LGTM.
I really appreciate you taking the time to sit down and do this, i know it's quite annoying when folks ask you to take a different approach after you already got it done once.