Skip to content

Commit

Permalink
[DSE] Make isRemovable() for calls more robust (NFCI)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nikic committed Dec 17, 2021
1 parent 18ab892 commit eb2cad8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
Expand Up @@ -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;
}
Expand Down

0 comments on commit eb2cad8

Please sign in to comment.