[PATCH] D114889: [GlobalOpt] Simplify CleanupConstantGlobalUsers()

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 1 09:59:08 PST 2021


nikic created this revision.
nikic added a reviewer: aeubanks.
Herald added subscribers: ormris, hiraditya.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This bases the CleanupConstantGlobalUsers() implementation around the ConstantFoldLoadFromConst() API. The general approach is that we discover all users while looking through casts, and then constant fold loads and drop stores and memintrinsics.

This avoids special cases and limitations in the previous implementation, which is also incompatible with opaque pointers. The result is a bit more powerful than before, because we now use more general load folding logic which can for example look through pointer bitcasts between different sizes. This is where the test changes come from, as we now fold more loads and can thus remove more globals.


https://reviews.llvm.org/D114889

Files:
  llvm/lib/Transforms/IPO/GlobalOpt.cpp
  llvm/test/Transforms/GlobalOpt/address_space_initializer.ll
  llvm/test/Transforms/GlobalOpt/atomic.ll
  llvm/test/Transforms/GlobalOpt/const-return-status-atomic.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114889.391066.patch
Type: text/x-patch
Size: 9761 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211201/bfd7734e/attachment.bin>


More information about the llvm-commits mailing list