aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Value.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2022-04-11 13:35:25 -0700
committerFangrui Song <i@maskray.me>2022-04-11 13:35:25 -0700
commit982247dce5b2d126e66e53d6b6c0fbe592de7ed1 (patch)
tree711fd996e1894803813033fbd0c40a5e0a49f052 /llvm/lib/IR/Value.cpp
parent61d418f97154805100dc19ff2ef1338e9de2f27d (diff)
downloadllvm-982247dce5b2d126e66e53d6b6c0fbe592de7ed1.zip
llvm-982247dce5b2d126e66e53d6b6c0fbe592de7ed1.tar.gz
llvm-982247dce5b2d126e66e53d6b6c0fbe592de7ed1.tar.bz2
Value::isTransitiveUsedByMetadataOnly: Don't repeatedly add an element to the worklist. NFC
Diffstat (limited to 'llvm/lib/IR/Value.cpp')
-rw-r--r--llvm/lib/IR/Value.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp
index 6081388..d4294af 100644
--- a/llvm/lib/IR/Value.cpp
+++ b/llvm/lib/IR/Value.cpp
@@ -1020,20 +1020,16 @@ bool Value::isSwiftError() const {
}
bool Value::isTransitiveUsedByMetadataOnly() const {
- if (use_empty())
- return false;
- llvm::SmallVector<const User *, 32> WorkList;
- llvm::SmallPtrSet<const User *, 32> Visited;
- WorkList.insert(WorkList.begin(), user_begin(), user_end());
+ SmallVector<const User *, 32> WorkList(user_begin(), user_end());
+ SmallPtrSet<const User *, 32> Visited(user_begin(), user_end());
while (!WorkList.empty()) {
const User *U = WorkList.pop_back_val();
- Visited.insert(U);
// If it is transitively used by a global value or a non-constant value,
// it's obviously not only used by metadata.
if (!isa<Constant>(U) || isa<GlobalValue>(U))
return false;
for (const User *UU : U->users())
- if (!Visited.count(UU))
+ if (Visited.insert(UU).second)
WorkList.push_back(UU);
}
return true;