[all-commits] [llvm/llvm-project] 5b86ea: Reapply [LowerTypeTests] Avoid creation of select ...

Nikita Popov via All-commits all-commits at lists.llvm.org
Tue Mar 14 04:06:40 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5b86eaeb7e4d0b508e8dc9592b63361c5abb1e48
      https://github.com/llvm/llvm-project/commit/5b86eaeb7e4d0b508e8dc9592b63361c5abb1e48
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2023-03-14 (Tue, 14 Mar 2023)

  Changed paths:
    M llvm/lib/IR/ReplaceConstant.cpp
    M llvm/lib/Transforms/IPO/LowerTypeTests.cpp
    M llvm/test/Transforms/LowerTypeTests/cfi-direct-call1.ll
    M llvm/test/Transforms/LowerTypeTests/function-weak.ll

  Log Message:
  -----------
  Reapply [LowerTypeTests] Avoid creation of select constant expression

Reapply with a fix for phi handling: For phis, we need to insert
into the incoming block, not above the phi. This is especially
tricky if there are multiple incoming values from the same
predecessor, because these must all use the same value.

-----

LowerTypeTests replaces weak declarations with an icmp+select
constant expressions. As this is not a relocatable expression,
it additionally promotes initializers using it to global ctors.

As part of https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179,
I would like to remove the select constant expression, of which LTT
is now the last user. This is a bit tricky, because we now need to
replace a constant with an instruction, which might require
converting intermediate constant expression users to instructions as
well.

We do this using the convertUsersOfConstantsToInstructions() helper.
However, it needs to be slightly extended to also support expansion
of ConstantAggregates. These are important in this context, because
the promotion of initializers to global ctors will produce stores
of such aggregates.

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




More information about the All-commits mailing list