[PATCH] D117355: [PowerPC] Fix the undef virtual register reading failure for PPC backend trap optimization

Victor Huang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 14 13:01:35 PST 2022


NeHuang created this revision.
NeHuang added reviewers: nemanjai, stefanp, amyk, PowerPC.
NeHuang added a project: LLVM.
Herald added subscribers: shchenz, kbarton, hiraditya.
NeHuang requested review of this revision.

This patch adds the fix for undef virtual register reading failure when trap optimization is enabled.

Failure scenario as below:

1. In a machine basic block A, the definition of a virtual register MI was eliminated due to trap optimization (TRAP inserted before the MI)
2. The same virtual register is still used in another machine basic block B (dominated by A) will trigger undef vr reading failure

Idea of the fix

1. Detect and set all virtual register definition after the conditional trap to `IMPLICIT_DEF`
2. Remove all the other machine instructions after the conditional trap and change the terminator machine instruction to an unconditional trap


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117355

Files:
  llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
  llvm/test/CodeGen/PowerPC/mi-peephole-trap-opt-dominated-block.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117355.400090.patch
Type: text/x-patch
Size: 8054 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220114/b3efa0c7/attachment-0001.bin>


More information about the cfe-commits mailing list