This is an archive of the discontinued LLVM Phabricator instance.

[MemCpyOpt] Fix a variety of scalable-type crashes
ClosedPublic

Authored by frasercrmck on Sep 6 2021, 9:22 AM.

Details

Summary

This patch fixes a variety of crashes resulting from the MemCpyOptPass
casting TypeSize to a constant integer, whether implicitly or
explicitly.

Since the MemsetRanges requires a constant size to work, all but one
of the fixes in this patch simply involve skipping the various
optimizations for scalable types as cleanly as possible.

The optimization of byval parameters, however, has been updated to
work on scalable types in theory. In practice, this optimization is only
valid when the length of the memcpy is known to be larger than the
scalable type size, which is currently never the case. This could
perhaps be done in the future using the vscale_range attribute.

Some implicit casts have been left as they were, under the knowledge
they are only called on aggregate types. These should never be
scalably-sized.

Diff Detail

Event Timeline

frasercrmck created this revision.Sep 6 2021, 9:22 AM
frasercrmck requested review of this revision.Sep 6 2021, 9:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 6 2021, 9:22 AM
tra accepted this revision.Sep 7 2021, 10:07 AM

LGTM in general.

Caveat -- I'm not the most familiar with the pass. Please give other reviewers a chance to chime in before landing the patch.

This revision is now accepted and ready to land.Sep 7 2021, 10:07 AM
This revision was landed with ongoing or failed builds.Sep 8 2021, 3:31 AM
This revision was automatically updated to reflect the committed changes.