[PATCH] D47237: [DSE] Calloc-strlen optimizations

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 23 07:02:44 PDT 2018


xbolva00 added inline comments.


================
Comment at: lib/Analysis/MemoryLocation.cpp:22
+MemoryLocation MemoryLocation::get(const CallInst *CI, const Value *Op) {
+  AAMDNodes AATags;
+  CI->getAAMetadata(AATags);
----------------
Self note: add assert for nonnull Op.


================
Comment at: lib/Transforms/Scalar/DeadStoreElimination.cpp:1125
+
+static bool eliminateLibCalls(Instruction *Inst, BasicBlock::iterator &BBI,
+                              AliasAnalysis *AA, MemoryDependenceResults *MD,
----------------
I would like to also reduce number of args here, since we don't need some of them.

new name: optimizeLibCalls?


================
Comment at: lib/Transforms/Scalar/DeadStoreElimination.cpp:1133
+  if (!CI)
+    return false;
+
----------------
I should check if CI->isNoBuiltin, I will fix it later


================
Comment at: lib/Transforms/Scalar/DeadStoreElimination.cpp:1136
+  bool Changed = false;
+  Changed |= eliminateStrlen(CI, BBI, AA, MD, DL, TLI, IOL, InstrOrdering);
+  // more to be added later
----------------
I would like to do here a similar switch like the one in SimplifyLibCalls

Value *NewInst = nullptr;
switch (...) {
      case LibFunc_strlen:
           NewInst = optimizeStrlen(CI, BBI, AA, MD, DL, TLI, IOL, InstrOrdering);
           break;
       ....
}

if (NewInst) {
    CI->replaceAllUsesWith(NewInst);
    CI->eraseFromParent();
    return true;
}


Suggestions?


https://reviews.llvm.org/D47237





More information about the llvm-commits mailing list