[PATCH] D88335: [BuildLibCalls] Add noalias for strcat and stpcpy

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 14:07:53 PDT 2020


fhahn added a comment.

In D88335#2295872 <https://reviews.llvm.org/D88335#2295872>, @efriedma wrote:

> It's conceivable that we might not want to mark strcpy/stpcpy etc. noalias for the same reason llvm.memcpy isn't noalias: standard implementation tolerate exact overlap, and the benefit from forbidding that is small.  (Actually, I'm not sure any optimizations benefit at the moment.)  Maybe that's being overconservative, though.

Hmm, it appears we already use noalias for `strcpy/strncpy` and this patch only additionally adds it to `strcat/stpcpy`.

`noalias` on its own is probably not too useful in this context, but I think without `noalias`, we cannot mark either argument as `readonly`/`writeonly`, which prevents some DSE opportunities (https://bugs.llvm.org/show_bug.cgi?id=47644). IIRC the main reason to allow exact overlap for `llvm.memcpy` was because clang generated code that violated the assumption. I think for the `memcpy` libfunc we still add `noalias` for both arguments.


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

https://reviews.llvm.org/D88335



More information about the llvm-commits mailing list