This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Fix machine verify pass error for PATCHPOINT pseudo instruction that bad machine code
ClosedPublic

Authored by ZhangKang on Dec 29 2018, 6:36 AM.

Details

Summary

This patch to fix below patchpoint error when using verify-machineinstrs option:

*** Bad machine code: Using an undefined physical register ***
- function:    test
- basic block: %bb.0 entry (0x1002e0ed008)
- instruction: PATCHPOINT 0, 40, 0, 2, 13, killed %1:gprc, killed %0:gprc, 2, 3, <regmask $cr0 $cr1 $cr2 $cr3 $cr4 $cr5 $cr6 $cr7 $f0 $f1 $f2 $f3 $f4 $f5 $f6 $f7 $f8 $f9 $f10 $f11 $f12 $f13 $f14 $f15 $f16 $f17 $f18 $f19 $f20 $f21 $f22 $f23 $f24 and 93 more...>, implicit-def dead early-clobber $x12, implicit-def dead early-clobber $lr8, implicit-def dead early-clobber $ctr8, implicit-def $r1, implicit $x2
- operand 14:   implicit $x2

For SDAG, we pretend patchpoints aren't special at all until we emit the code for the pseudo.
Then the verifier runs and it seems like we have a use of an undefined register (the register will
be reserved later, but the verifier doesn't know that).

So this patch call setUsesTOCBasePtr before emit the code for the pseudo, so verifier
can know X2 is a reserved register.

Diff Detail

Event Timeline

ZhangKang created this revision.Dec 29 2018, 6:36 AM
nemanjai added inline comments.Dec 29 2018, 8:30 AM
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
5107

This condition is a never true if the previous one isn't. So this can be changed to just if (!isPatchPoint) and contained within the above if (isSVR4ABI && isPPC64).

So this rell-request

typo in the summary "rell"

ZhangKang edited the summary of this revision. (Show Details)Dec 30 2018, 12:28 AM

So this rell-request

typo in the summary "rell"

I have modified it.

ZhangKang updated this revision to Diff 179721.Dec 30 2018, 1:25 AM

Put if (!isPatchPoint) within if (isSVR4ABI && isPPC64) to follow nemanjai's suggestion.

ZhangKang marked 2 inline comments as done.Dec 30 2018, 1:26 AM
ZhangKang added inline comments.
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
5107

I have updated the patch to follow your suggestion.

ZhangKang marked an inline comment as done.Dec 30 2018, 1:26 AM
nemanjai accepted this revision.Dec 30 2018, 5:02 AM

LGTM.

This revision is now accepted and ready to land.Dec 30 2018, 5:02 AM
This revision was automatically updated to reflect the committed changes.