[PATCH] D145247: [LowerTypeTests] Avoid creation of select constant expression

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 3 07:59:14 PST 2023


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

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.


https://reviews.llvm.org/D145247

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145247.502129.patch
Type: text/x-patch
Size: 9155 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230303/988bdf10/attachment.bin>


More information about the llvm-commits mailing list