This is an archive of the discontinued LLVM Phabricator instance.

[SROA] Switch replacement of dead/UB/unreachable ops from undef to poison
ClosedPublic

Authored by nlopes on Jan 9 2022, 5:02 AM.

Details

Summary

SROA has 3 data-structures where it stores sets of instructions that should be deleted:

  • DeadUsers -> instructions that are UB or have no users
  • DeadOperands -> instructions that are UB or operands of useless phis
  • DeadInsts -> "dead" instructions, including loads of uninitialized memory with users

The first 2 sets can be RAUW with poison instead of undef. No brainer as UB can be replaced with poison, and for instructions with no users RAUW is a NOP.

The 3rd case cannot be currently replaced with poison because the set mixes the loads of uninit memory. I leave that alone for now.

Another case where we can use poison is in the construction of vectors from multiple loads. The base vector for the first insertelement is now poison as it doesn't matter as it is fully overwritten by inserts.

Diff Detail

Event Timeline

nlopes created this revision.Jan 9 2022, 5:02 AM
nlopes requested review of this revision.Jan 9 2022, 5:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 9 2022, 5:02 AM
nikic accepted this revision.Jan 10 2022, 1:30 AM

LGTM

This revision is now accepted and ready to land.Jan 10 2022, 1:30 AM
nikic added a comment.Jan 10 2022, 1:31 AM

Watch out for the failing clang test though, aarch64-bf16-ldst-intrinsics.c needs to be updated.

This revision was landed with ongoing or failed builds.Jan 10 2022, 6:06 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJan 10 2022, 6:06 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript