This will allow subsequent passes to perform optimization on aggregates loads/stores.
Details
- Reviewers
- None
Diff Detail
Event Timeline
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. |
Update needed