[PATCH] D144477: [GlobalOpt] Handle stored-once in collectSRATypes (WIP).

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 21 05:31:56 PST 2023


fhahn created this revision.
fhahn added reviewers: aeubanks, nikic, kubamracek.
Herald added subscribers: ormris, StephenFan, hiraditya.
Herald added a project: All.
fhahn requested review of this revision.
Herald added a project: LLVM.

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 <https://reviews.llvm.org/D144476>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144477

Files:
  llvm/lib/Transforms/IPO/GlobalOpt.cpp
  llvm/test/Transforms/GlobalOpt/sra-many-stores-once.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144477.499125.patch
Type: text/x-patch
Size: 8579 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230221/58148c00/attachment.bin>


More information about the llvm-commits mailing list