This is an archive of the discontinued LLVM Phabricator instance.

[GlobalOpt] Handle stored-once in collectSRATypes (WIP).
Needs ReviewPublic

Authored by fhahn on Feb 21 2023, 5:31 AM.

Details

Summary

Teach SRA heuristic about GlobalOpts stored-once pattern:

If

  1. a global location is initialized with 0
  2. all uses other than stores are accesses that would be UB if the zero value is used and
  3. And there's exactly one store to the location

the store can be removed and all uses can be updated to use the stored
value.

This patch is not complete: it misses precise tracking of accessed
locations for a global; given this is just a heuristic, that may be
fine to start with.

Depends on D144476.

Diff Detail