This is an archive of the discontinued LLVM Phabricator instance.

Add a pass to transform aggregate loads and stores into scalar loads and stores.
AbandonedPublic

Authored by deadalnix on Feb 13 2015, 12:32 AM.

Details

Reviewers
None
Summary

This will allow subsequent passes to perform optimization on aggregates loads/stores.

Diff Detail

Event Timeline

deadalnix updated this revision to Diff 19875.Feb 13 2015, 12:32 AM
deadalnix retitled this revision from to Add a pass to transform aggregate loads and stores into scalar loads and stores..
deadalnix updated this object.
deadalnix edited the test plan for this revision. (Show Details)
deadalnix set the repository for this revision to rL LLVM.
reames added a subscriber: reames.Feb 18 2015, 4:17 PM

This is definitely moving in the direction previously discussed.

I would *strongly* suggest narrowing down the initial patch to the easiest possible case (i.e. a struct with a single element of the same size). Then post a patch for the iteration case (i.e. a struct of a struct of a struct). Then a patch which handles arrays. Then a patch which handles multi-element structs. Reviewing this in the current form will be slow and painful.

lib/Transforms/Scalar/AggregateMemAccessRemoval.cpp
1

Update needed

67

I don't see any particular reason to cache this. Why not just get it from the Function when needed?

81

When you have a struct that contains a struct that contains a struct, you may need to iterate here. It would be much clearer to create a worklist of instructions to split and then visit each in turn until the worklist is empty.

109

I'd probably pull this check into the caller for readability.

136

const please.

148

I'm confused about the complexity buried inside getFromLoad and addToStore. I think part of this is the iteration thing I mentioned previously, but there's also something else going on?

Ok I can make a simple version of this and get more complex cases in another, but one these diff wil have a good chunk of complexity. As you need to handle cases like array of struct or struct that contains array, you ends up having to pull it all together.

Still can do load then store I guess.

lib/Transforms/Scalar/AggregateMemAccessRemoval.cpp
81

Why would you iterate ? You only replace this load by another integral load, and then iterate to recompose the expected value from the integral using bit manipulation wizzardry.

The iteration is in getFromLoad .

148

The complexity come from the fact you can have struct containing arrays of struct and you need to turle down to the point you get to some primitive type.

deadalnix updated this revision to Diff 20373.Feb 19 2015, 9:01 PM

Rebase on top of D7780

deadalnix abandoned this revision.Aug 25 2015, 11:36 PM