[PATCH] D85379: Improve dropTriviallyDeadConstantArrays time cost ratio from 17% to 4%

Mehdi AMINI via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 5 20:18:22 PDT 2020


mehdi_amini added inline comments.


================
Comment at: llvm/lib/IR/LLVMContextImpl.cpp:159
+        WorkList.insert(COp);
+    // This does not invalidate ArrayConstants's iterator.
+    C->destroyConstant();
----------------
So can you use a for-range loop?



================
Comment at: llvm/lib/IR/LLVMContextImpl.cpp:161
+    C->destroyConstant();
+    Deleted.insert(C);
+  }
----------------
It actually isn't clear to why you need the `Deleted` set at all.

Can't we just use this loop to prime the worklist with the entries that aren't used and then process the worklist below?

```
for (ConstantArray *Constant : ArrayConstants) {
  if (C->use_empty())
    WorkList.insert.COp);
}

while (!WorkList.empty()) {
  // unchanged...
```



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85379/new/

https://reviews.llvm.org/D85379



More information about the llvm-commits mailing list