[PATCH] D103582: [AArch64][GlobalISel] Handle multiple phis in fixupPHIOpBanks

Jessica Paquette via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 2 17:53:01 PDT 2021


paquette created this revision.
paquette added reviewers: aemerson, jroelofs.
Herald added subscribers: danielkiss, hiraditya, kristof.beyls, rovka.
paquette requested review of this revision.
Herald added a project: LLVM.

If we ended up with two phi instructions in a block, and we needed to fix up the banks for the first one, we'd end up inserting our COPY before the second phi.

E.g.

  %x = G_PHI ...
  %fixup = COPY ...
  %y = G_PHI ...

This is invalid MIR, and breaks assumptions made by the register allocator later down the line. With the verifier enabled, it also emits a verification error.

This teaches `fixupPHIOpBanks` to walk past any phi instructions in the block when emitting the fixup copies.

Here's an example of the crashing code (same as added testcase):
https://godbolt.org/z/h5j1x3o6e


https://reviews.llvm.org/D103582

Files:
  llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
  llvm/test/CodeGen/AArch64/GlobalISel/preselect-process-phis.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103582.349436.patch
Type: text/x-patch
Size: 4755 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210603/6e025350/attachment.bin>


More information about the llvm-commits mailing list