[PATCH] D64884: [PHINode] Preserve use-list order when removing incoming values.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 6 16:45:35 PDT 2019


efriedma added a comment.

> My motivation for this change is to fix a case where we end up with a non-deterministic use-list order after simplifycfg, which I think is caused by this trashing of the use-lists.

I don't see how this could be a problem. Sure, mixing up the order is sort of confusing, but it should get mixed up in a deterministic way.



================
Comment at: llvm/include/llvm/IR/Value.h:739
+      RHS.Next->setPrev(&Next);
+    if (Val->UseList == &RHS)
+      Val->UseList = this;
----------------
Is this "if" actually necessary?  Use::removeFromList just unconditionally dereferences Prev.


================
Comment at: llvm/lib/IR/Instructions.cpp:129
-  // clients might not expect this to happen.  The code as it is thrashes the
-  // use/def lists, which is kinda lame.
-  std::copy(op_begin() + Idx + 1, op_end(), op_begin() + Idx);
----------------
Even if this patch fixes the use/def list thrashing, swap would still be faster.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64884





More information about the llvm-commits mailing list