This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Fix the undef virtual register reading failure for PPC backend trap optimization
AbandonedPublic

Authored by NeHuang on Jan 14 2022, 1:01 PM.

Details

Reviewers
nemanjai
stefanp
amyk
Group Reviewers
Restricted Project
Summary

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

Diff Detail

Event Timeline

NeHuang created this revision.Jan 14 2022, 1:01 PM
NeHuang requested review of this revision.Jan 14 2022, 1:01 PM
amyk added inline comments.Jan 25 2022, 7:00 AM
llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
432

Might be good to pull out MI.getOperand(0).isReg() into a separate variable since you're using it three times here.

llvm/test/CodeGen/PowerPC/mi-peephole-trap-opt-dominated-block.mir
2

Question: are AIX run lines necessary, too?

amyk added inline comments.Feb 10 2022, 9:18 AM
llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
432

I think you can disregard my comment. I realized later that there are both isReg() and getReg(), and the latter should be called only when isReg() is true. Sorry about that.

NeHuang updated this revision to Diff 407877.Feb 11 2022, 12:56 PM
NeHuang marked an inline comment as done.

Address review comments.

NeHuang marked 2 inline comments as done.Feb 11 2022, 12:57 PM
NeHuang abandoned this revision.Feb 25 2022, 2:35 PM