[PATCH] D60619: New pass to produce more easily-read IR.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 13 05:34:50 PDT 2019


MaskRay added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/ImproveReadingOrder.cpp:52
+  BasicBlock * lastSoFar = nullptr;
+  std::set<BasicBlock *> processed;
+  std::vector<BasicBlock *> toBeDone;
----------------
For a not-necessarily-sorted set, you may use `SmallPtrSet` or `DenseSet`.


================
Comment at: llvm/lib/Transforms/Utils/ImproveReadingOrder.cpp:56
+
+  std::set<BasicBlock *> blocksWithUnreachables;
+  for(auto & b : F.getBasicBlockList())
----------------
This can be a `SetVector` (since we want determinism but `set::set` is slow)


================
Comment at: llvm/lib/Transforms/Utils/ImproveReadingOrder.cpp:134
+
+    while(current && processed.count(current)) {
+      if(!toBeDone.empty())
----------------
In some pessimistic cases, `preferredNextBlock` is of `O(|input|^2)` and this while loop is cubic..

Do you want to rewrite the loop to use a worklist?

```
if (condition) {
  complex   /////// I believe the current algorithm only reorders the 'then' part
} else {
  complex    /////// this is not touched
}
```



Repository:
  rL LLVM

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

https://reviews.llvm.org/D60619





More information about the llvm-commits mailing list