[PATCH] D24918: [ADCE] Add code to remove dead branches

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 2 10:52:48 PDT 2016


mehdi_amini added a comment.

I had started reviewing after you previous ping last week but couldn't finish because of the conference preparation, so just some piece of wip feedback inline.



================
Comment at: lib/Transforms/Scalar/ADCE.cpp:232
+        return Iter != end() && Iter->second;
+      }
+    } State;
----------------
OK, I was wondering how the "completed" stuff worked when you introduced it, I see now :)


================
Comment at: lib/Transforms/Scalar/ADCE.cpp:243
+    for (; Iter != End; ++Iter) {
+      auto *BB = *Iter;
+      TerminatorInst *Term = BB->getTerminator();
----------------
I think the boilerplate can be reduced: 

```
for (auto *BB : make_range(Iterator::begin(&F.getEntryBlock(), State),
                                               Iterator::end(&F.getEntryBlock(), State)) {
   ....
```

The repetition of `&F.getEntryBlock(), State` isn't great, upgrading `iterator_range<df_iterator<T>> depth_first(const T& G)` and `df_begin` and `df_end` to accept the extra `State` parameter should allow to write:

```
for (auto *BB : depth_first(&F.getEntryBlock(), State)) {
   ....
```



https://reviews.llvm.org/D24918





More information about the llvm-commits mailing list