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

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 19 12:24:44 PST 2017


efriedma added inline comments.


================
Comment at: lib/Transforms/Scalar/MemCpyOptimizer.cpp:836
+  // The store to dest may never happen if the call can throw.
+  if (C->mayThrow() && !isa<AllocaInst>(cpyDest))
+    return false;
----------------
You probably want to clarify why an alloca is special here.

Does it matter if cpyDest could be accessed from another thread?

Do you need to check whether any calls between "C" and "cpy" could throw?


================
Comment at: lib/Transforms/Scalar/MemCpyOptimizer.cpp:848
+    APInt APOffset(DL.getPointerSizeInBits(GEP->getPointerAddressSpace()), 0);
+    if (GEP->accumulateConstantOffset(DL, APOffset) && !Offset.isNegative()) {
+      auto Offset = APOffset.getSExtValue();
----------------
Maybe this code belongs in getPointerDereferenceableBytes, rather than here?


================
Comment at: lib/Transforms/Scalar/MemCpyOptimizer.cpp:915
+      if (auto G = dyn_cast<GetElementPtrInst>(cpyDest)) {
+        auto P = G->getPointerOperand();
+        auto PI = dyn_cast<Instruction>(P);
----------------
This check is kind of fragile, in that it assumes the other operands to the GEP are all ConstantInts.


https://reviews.llvm.org/D41400





More information about the llvm-commits mailing list