diff options
author | Arthur Eubanks <aeubanks@google.com> | 2022-01-13 10:09:52 -0800 |
---|---|---|
committer | Arthur Eubanks <aeubanks@google.com> | 2022-01-13 14:29:45 -0800 |
commit | 757e044dce51d01391e3fa2dbff2cd8e16f964cb (patch) | |
tree | 0c91cc47a1162b195393bfd0f1fecbab6d75aaf5 /llvm/lib/IR/Constants.cpp | |
parent | 00e0de05723a0eee491d4a1ddad69b7fe5265805 (diff) | |
download | llvm-757e044dce51d01391e3fa2dbff2cd8e16f964cb.zip llvm-757e044dce51d01391e3fa2dbff2cd8e16f964cb.tar.gz llvm-757e044dce51d01391e3fa2dbff2cd8e16f964cb.tar.bz2 |
[Inliner] Don't removeDeadConstantUsers() when checking if a function is dead
If a function has many uses, this can take a good chunk of compile times.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D117236
Diffstat (limited to 'llvm/lib/IR/Constants.cpp')
-rw-r--r-- | llvm/lib/IR/Constants.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index e753fc7..8fb17f6 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -779,18 +779,22 @@ void Constant::removeDeadConstantUsers() const { } } -bool Constant::hasOneLiveUse() const { +bool Constant::hasOneLiveUse() const { return hasNLiveUses(1); } + +bool Constant::hasZeroLiveUses() const { return hasNLiveUses(0); } + +bool Constant::hasNLiveUses(unsigned N) const { unsigned NumUses = 0; - for (const Use &use : uses()) { - const Constant *User = dyn_cast<Constant>(use.getUser()); + for (const Use &U : uses()) { + const Constant *User = dyn_cast<Constant>(U.getUser()); if (!User || !constantIsDead(User, /* RemoveDeadUsers= */ false)) { ++NumUses; - if (NumUses > 1) + if (NumUses > N) return false; } } - return NumUses == 1; + return NumUses == N; } Constant *Constant::replaceUndefsWith(Constant *C, Constant *Replacement) { |