[PATCH] D41400: [MemCpyOpt] Perform call slot optimizations through GEPs

Björn Steinbrink via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 19 08:57:36 PST 2017

dotdash created this revision.
dotdash added reviewers: rnk, hfinkel, sanjoy, majnemer.

Call slot optimization needs to know that writing to the destination of the
memcpy won't trap, so it has to know the number of dereferenceable bytes of the
destination. Currently it can only handle this for allocas and function
arguments that are directly written to. We can improve upon this by handling
simple GEPs with constant offsets.

This allows call slot optimizations to happen in code like this:

  struct Foo {
    int o[200];
  struct Bar {
    char p;
    Foo f;
  Foo moo()
    return {0};
  Bar goo()
    Bar f;
    f.f = moo();
    return f;

Which is a slightly modified version of the code in PR35134 that works around
the missing alias information in the original C++ code.

It also makes the optimization happen in the Rust code that originally lead to
the above PR.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41400.127543.patch
Type: text/x-patch
Size: 4709 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171219/04ff0d96/attachment.bin>

More information about the llvm-commits mailing list