[PATCH] D112717: [IR] Replace *all* uses of a constant expression by corresponding instruction

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 29 12:10:35 PDT 2021


rampitec added inline comments.


================
Comment at: llvm/lib/IR/ReplaceConstant.cpp:93
+  for (auto Item : Visited)
+    Item.first->removeDeadConstantUsers();
 }
----------------
hsmhsm wrote:
> rampitec wrote:
> > Why not to remove it immediately?
> Consider below example, where C2 uses lds.  In this case, we have two paths, but both the paths have same sequence, that is (C1, C2).  So,  it again causes the same bug which https://reviews.llvm.org/D104425 has fixed. That is, we land up replacing already dead constant expression. 
> 
> 
> ```
>                                    I
>                                  /  \
>                                C1   C1
>                               /        \
>                              C2        C2
> ```
> 
I mean, dead users are already dead users. In this case you would just call `removeDeadConstantUsers` twice, which shall not be a problem as far as I understand. Just why a separate loop is needed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112717



More information about the llvm-commits mailing list