diff options
| author | Nikita Popov <npopov@redhat.com> | 2021-12-17 20:44:15 +0100 |
|---|---|---|
| committer | Nikita Popov <npopov@redhat.com> | 2021-12-17 20:52:34 +0100 |
| commit | eb2cad8329b0526b6b4e9deaf7187530012a64f1 (patch) | |
| tree | 6135c8c9b76f1d685699cafa0f6518243688c104 | |
| parent | 18ab892ff7e9032914ff7fdb07685d5945c84fef (diff) | |
| download | llvm-eb2cad8329b0526b6b4e9deaf7187530012a64f1.zip llvm-eb2cad8329b0526b6b4e9deaf7187530012a64f1.tar.gz llvm-eb2cad8329b0526b6b4e9deaf7187530012a64f1.tar.bz2 | |
[DSE] Make isRemovable() for calls more robust (NFCI)
We can only drop calls if they have an analyzable write, the return
value is not used, they don't throw and they don't diverge. The last
two conditions were previously not checked, because all the libcalls
with analyzable writes already happened to satisfy those conditions
anyway. This may not be true for generalizations (with D115904 in mind).
No test changes because the necessary attributes are already inferred
for currently supported libcalls.
Differential Revision: https://reviews.llvm.org/D115962
| -rw-r--r-- | llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp index 757461b..ee6c800 100644 --- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -206,9 +206,9 @@ static bool isRemovable(Instruction *I) { } } - // 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<CallBase>(I)) - return CB->use_empty(); + return CB->use_empty() && CB->willReturn() && CB->doesNotThrow(); return false; } |
