[PATCH] D85379: Improve dropTriviallyDeadConstantArrays time cost ratio from 17% to 4%
Stephan Z via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 6 00:29:37 PDT 2020
stephan.yichao.zhao updated this revision to Diff 283512.
stephan.yichao.zhao marked 4 inline comments as done.
stephan.yichao.zhao added a comment.
reverted unrelated change
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85379/new/
https://reviews.llvm.org/D85379
Files:
llvm/lib/IR/LLVMContextImpl.cpp
Index: llvm/lib/IR/LLVMContextImpl.cpp
===================================================================
--- llvm/lib/IR/LLVMContextImpl.cpp
+++ llvm/lib/IR/LLVMContextImpl.cpp
@@ -129,8 +129,15 @@
}
void LLVMContextImpl::dropTriviallyDeadConstantArrays() {
- SmallSetVector<ConstantArray *, 4> WorkList(ArrayConstants.begin(),
- ArrayConstants.end());
+ SmallSetVector<ConstantArray *, 4> WorkList;
+
+ // When ArrayConstants are of substantial size and only a few in them are
+ // dead, starting WorkList with all elements of ArrayConstants can be
+ // wasteful. Instead, starting WorkList with only elements that have empty
+ // uses.
+ for (ConstantArray *C : ArrayConstants)
+ if (C->use_empty())
+ WorkList.insert(C);
while (!WorkList.empty()) {
ConstantArray *C = WorkList.pop_back_val();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85379.283512.patch
Type: text/x-patch
Size: 872 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200806/7336d7a4/attachment.bin>
More information about the llvm-commits
mailing list