[PATCH] D109329: [MemCpyOpt] Fix a variety of scalable-type crashes

Fraser Cormack via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 6 09:22:27 PDT 2021


frasercrmck created this revision.
frasercrmck added reviewers: nikic, tra, hliao, efriedma, asbirlea.
Herald added a subscriber: hiraditya.
frasercrmck requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109329

Files:
  llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h
  llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
  llvm/test/Transforms/MemCpyOpt/vscale-crashes.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109329.370937.patch
Type: text/x-patch
Size: 12084 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210906/3b8e9b12/attachment.bin>


More information about the llvm-commits mailing list