This is an archive of the discontinued LLVM Phabricator instance.

[LowerTypeTests] Avoid creation of select constant expression
ClosedPublic

Authored by nikic on Mar 3 2023, 7:59 AM.

Details

Summary

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.

Diff Detail

Event Timeline

nikic created this revision.Mar 3 2023, 7:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2023, 7:59 AM
nikic requested review of this revision.Mar 3 2023, 7:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2023, 7:59 AM
aeubanks accepted this revision.Mar 3 2023, 12:23 PM
This revision is now accepted and ready to land.Mar 3 2023, 12:23 PM
This revision was landed with ongoing or failed builds.Mar 6 2023, 12:49 AM
This revision was automatically updated to reflect the committed changes.

Hi, it causes broken module error when building media_unittests in chromium project (https://bugs.chromium.org/p/chromium/issues/detail?id=1423915 for detail). I'll work on a reduced repo later.

hans added a subscriber: hans.Mar 13 2023, 10:05 AM

From just a quick look, I guess what might be happening is this transformation replacing a select constant expression in a PHI node, and inserting the replacement instruction(s) above the PHI node, which the verifier doesn't like.

nikic added a comment.Mar 14 2023, 4:07 AM

I've reapplied this change in rG5b86eaeb7e4d0b508e8dc9592b63361c5abb1e48 with fixed handling for uses in phis. Let me know if you still see issues.