[PATCH] D136822: [InstCombine] Allow memcpys from constant memory to readonly noalias parameters to be elided.

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 29 02:26:23 PDT 2022


nikic added inline comments.


================
Comment at: compiler-rt/test/asan/TestCases/printf-5.c:22
+  for (unsigned i = 0; i < sizeof(fmt); i++)
+    fmt[i] = "%c %d %f %s\n"[i];
   printf((char *)fmt, c, x, f, s);
----------------
I'm really confused by what this test is trying to do with the memcpy here. Would the test pass with just `volatile char fmt[2] = "%c"`? That'll produce a volatile memcpy, and that shouldn't get optimized away.


================
Comment at: llvm/test/Transforms/InstCombine/memcpy-from-global.ll:350
+  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %A, ptr align 4 @H, i64 20, i1 false)
+  call void @readonly_nocapture(ptr nocapture readonly %A)
+  ret void
----------------
This can be `call void @bar(ptr nocapture readonly %A)`. We don't need separate functions and can vary the attributes at the call-site only. Same below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136822



More information about the llvm-commits mailing list