[PATCH] D29781: Add alias canonicalization pass when preparing for ThinLTO

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 15 13:48:15 PST 2017


tejohnson added a comment.

I should also add that I have been investigating how hard it would be to do this during GlobalAlias::create. It turns out to be much more complicated, unfortunately (a few notes below). It seems like it would be more straightforward to add a pass as done here and then a bitcode upgrade path for now, and eventually teach producers such as clang to do the right thing.

BTW I will be on vacation for a week+ so might not have time to do follow-up work here until I am back Feb 27.

Complications with canonicalization during GlobalAlias::create:

- When we canonicalize an alias being created, where the aliasee is another alias that has already been canonicalized (since we are converting each alias as we read it in from the LLVM assembly) - means having to repeatedly look through uses of the already-canonicalized alias to find the one in the alias being canonicalized in this call, so that we can rename it to the anonymous private.
- To do the above, need to inspect the aliasee's GV for each alias being created - but there isn't already a way to find the aliasee's GV while stripping both pointer casts and inbound indices, but not follow aliases (i.e. normally getBaseObject() will look through aliases).

I have a fix for the first one, but it seems inefficient to have to re-scan uses of the aliasee that was a converted alias (not sure how common that is though). The second one I don't have a complete fix for. It probably needs an additional facility on stripPointerCastsAndOffsets.


https://reviews.llvm.org/D29781





More information about the llvm-commits mailing list