A store to an object whose lifetime is about to end can be removed.
See PR40550 for motivation.
Differential D57541
[DAGCombiner] Eliminate dead stores to stack. courbet on Jan 31 2019, 1:32 PM. Authored by
Details A store to an object whose lifetime is about to end can be removed. See PR40550 for motivation.
Diff Detail
Event Timeline
Comment Actions I just realized that there is nothing that guarantees that an alloca's lifetime is ended in one go, so I'll also have to check that the store is within the lifetime.end base and size. Comment Actions Yes. You should use the BaseIndexOffset alias framework here. Also, you'll need to deal with the additional output from indexed stores. We should probably also add this some LIFETIME nodes casing to FindBetterChains and improve LIFETIME_END's chain so we can deal with overlapping lifetimes. Comment Actions Only remove stores to dead stack space when they are fully contained inside the Comment Actions
I think I'm fine because of the hasOneUse() check. I'm not sure how I should test this though, do you have a suggestion for some test IR for an indexed store ? Comment Actions I believe the CombineTo will fail from too few values on indexed stores, even if the value isn't used. Better to check isIndexed() or do the unfolding back to an ADD/SUB. I suspect the only way this would trigger currently is if an intrinsic lowers into an indexed store in ARM or AArch64.
Comment Actions
Comment Actions
Comment Actions LGTM, modulo potentially excising the hasOneUse as I've suggested provided you agree with my line of reasoning there.
Comment Actions
Comment Actions I finally had time to track this down. The issue was that we were missing a hasOneUse() check on the chain (we were only checking it on the store itself), so there could be other nodes dependind on the store (typically through tokenfactors), e.g. store ----> TF ---> LIFETIME_END \-----> some_user We were deleting the store...
|