[PATCH] D105019: [RegisterCoalescer] Avoid coalescing erased Copy

Quentin Colombet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 7 11:50:32 PDT 2021


qcolombet requested changes to this revision.
qcolombet added inline comments.
This revision now requires changes to proceed.


================
Comment at: llvm/lib/CodeGen/RegisterCoalescer.cpp:3869
   for (unsigned i = 0, e = CurrList.size(); i != e; ++i) {
-    if (!CurrList[i])
+    if (!CurrList[i] || !CurrList[i]->getParent())
       continue;
----------------
> Sometimes the CurrList may have two identical instructions that will be coalesced later. Once the first one coalesced, it will be removed from its parent, this will make the second identical instruction become illegal at the same time which getParent will be a nullptr.

When that happens the instruction should be part of `ErasedInst` and we would skip it in the next conditional block.

Why is it not happening?

BTW
> Once the first one coalesced, it will be removed from its parent,

It is removed or erased? If the latter, accessing the pointer is UB, so testing getParent is invalid.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105019



More information about the llvm-commits mailing list