This is an archive of the discontinued LLVM Phabricator instance.

InferAddressSpaces: Search constant expressions for addrspacecasts
ClosedPublic

Authored by arsenm on Apr 26 2017, 4:33 PM.

Details

Reviewers
jlebar
arsenm
Summary

These are pretty common when using local memory, and the 64-bit generic
addressing is much more expensive to compute.

Diff Detail

Event Timeline

arsenm created this revision.Apr 26 2017, 4:33 PM
jlebar edited reviewers, added: chandlerc; removed: jlebar.Apr 26 2017, 5:27 PM
jlebar added a subscriber: jlebar.Apr 28 2017, 12:31 PM
jlebar added inline comments.
lib/Transforms/Scalar/InferAddressSpaces.cpp
843

If we expect that the Value*s won't be deleted while in this vector, why are we using WeakVH at all? Are we trying to catch use-after-frees?

At least the choice to use WeakVH could use a comment somewhere, but if it's just fear of use-after-free's, is there some reason that this code is particularly dangerous as compared to other parts of LLVM, where we rely on asan/msan to catch this issue?

jlebar edited reviewers, added: jlebar; removed: chandlerc.Apr 28 2017, 12:33 PM
arsenm added inline comments.Apr 28 2017, 12:59 PM
lib/Transforms/Scalar/InferAddressSpaces.cpp
843

It's possible to make it work without WeakVH, but it fails to handle more cases. The RAUW used for the handling of constants needs to be tracked

arsenm added inline comments.Apr 28 2017, 1:02 PM
lib/Transforms/Scalar/InferAddressSpaces.cpp
843

Earlier versions of the patch were more complicated and attempted to recursively handle all of the constants up front, but it ended up much more complicated than to just add WeakVH here.

arsenm accepted this revision.Apr 28 2017, 4:05 PM

r301711

This revision is now accepted and ready to land.Apr 28 2017, 4:05 PM
arsenm closed this revision.Apr 28 2017, 4:05 PM