diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp --- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -206,9 +206,9 @@ } } - // note: only get here for calls with analyzable writes - i.e. libcalls + // note: only get here for calls with analyzable writes. if (auto *CB = dyn_cast(I)) - return CB->use_empty(); + return CB->use_empty() && CB->willReturn() && CB->doesNotThrow(); return false; }