[PATCH] D105370: [GlobalISel] Mark memcpy/memmove/memset as thisreturn

Jon Roelofs via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 2 14:19:46 PDT 2021


jroelofs added a comment.

In D105370#2856111 <https://reviews.llvm.org/D105370#2856111>, @paquette wrote:

> SDAG doesn't seem to mark the call as returned with the same example.

It doesn't, but it must know something about this property since it doesn't restore `$x0` afterward.

> Is this a new optimization?

rdar://77466123

> https://clang.godbolt.org/z/K49z51zoo
>
> IIRC `thisreturn` comes up as a result of the `returned` attribute in IR, right? Should the frontend be marking memory functions as `returned` instead? (I guess that we'd need a patch like this either way...?)

Exactly. The thing that's special here is that these three functions have their own `GISel` Opcodes, which don't have that `returned` behavior that the call had, so it wasn't being transferred automatically like it would for other calls with the attribute.



================
Comment at: llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp:597
   default:
-    return LegalizerHelper::UnableToLegalize;
+    llvm_unreachable("unsupported opcode");
   }
----------------
arsenm wrote:
> Why change to unreachable? This is an unrelated change.
The one call site only passes these four opcodes, so I figured this was a useful drive-by improvement. Happy to take it out if you think it should stay generic.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105370/new/

https://reviews.llvm.org/D105370



More information about the llvm-commits mailing list