[all-commits] [llvm/llvm-project] 8d1759: [GlobalOpt] Simplify CleanupConstantGlobalUsers()

Nikita Popov via All-commits all-commits at lists.llvm.org
Wed Dec 1 12:06:45 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8d1759c404c7899c62d6ed89791e49b2742c1a20
      https://github.com/llvm/llvm-project/commit/8d1759c404c7899c62d6ed89791e49b2742c1a20
  Author: Nikita Popov <nikita.ppv at gmail.com>
  Date:   2021-12-01 (Wed, 01 Dec 2021)

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

  Log Message:
  -----------
  [GlobalOpt] Simplify CleanupConstantGlobalUsers()

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.

Differential Revision: https://reviews.llvm.org/D114889




More information about the All-commits mailing list