[PATCH] D116210: [DSE][MemLoc] Handle intrinsics more generically

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 28 09:39:04 PST 2021


fhahn added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:185
 
-  if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
-    switch (II->getIntrinsicID()) {
-    default: llvm_unreachable("Does not have LocForWrite");
-    case Intrinsic::lifetime_end:
-      // Never remove dead lifetime_end's, e.g. because it is followed by a
-      // free.
+  // Note: only get here for calls with analyzable writes.
+  if (auto *CB = dyn_cast<CallBase>(I)) {
----------------
nikic wrote:
> fhahn wrote:
> > nikic wrote:
> > > fhahn wrote:
> > > > might be worth an assert here
> > > In some cases we call isRemovable() before getLocForWriteEx() (but still bail out if either fails). I could add an assert after reordering the calls.
> > That might be a good way to prevent accidental mis-use in future.
> Assert added in https://github.com/llvm/llvm-project/commit/034e66e76c6f0f76aa7c67ba4edf4eba108bcf51, though it took a few more preliminary changes than anticipated.
Great, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116210



More information about the llvm-commits mailing list