diff options
author | Kang Zhang <shkzhang@cn.ibm.com> | 2018-12-30 15:13:51 +0000 |
---|---|---|
committer | Kang Zhang <shkzhang@cn.ibm.com> | 2018-12-30 15:13:51 +0000 |
commit | 9d78c60bf425b077d7f694a7508989ab889c7f53 (patch) | |
tree | 7599a0502eed1a92798f8dd0543624b0cf0a304c /llvm/lib/Target/PowerPC/PPCISelLowering.cpp | |
parent | e4c91204990668299c4883d2221397fd7c345c89 (diff) | |
download | bcm5719-llvm-9d78c60bf425b077d7f694a7508989ab889c7f53.tar.gz bcm5719-llvm-9d78c60bf425b077d7f694a7508989ab889c7f53.zip |
[PowerPC] Fix machine verify pass error for PATCHPOINT pseudo instruction that bad machine code
Summary:
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.
Reviewed By: nemanjai
Differential Revision: https://reviews.llvm.org/D56148
llvm-svn: 350165
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCISelLowering.cpp')
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp index 4442746031d..39608cb74be 100644 --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -5097,9 +5097,15 @@ PrepareCall(SelectionDAG &DAG, SDValue &Callee, SDValue &InFlag, SDValue &Chain, // All calls, in both the ELF V1 and V2 ABIs, need the TOC register live // into the call. - if (isSVR4ABI && isPPC64 && !isPatchPoint) { + // We do need to reserve X2 to appease the verifier for the PATCHPOINT. + if (isSVR4ABI && isPPC64) { setUsesTOCBasePtr(DAG); - Ops.push_back(DAG.getRegister(PPC::X2, PtrVT)); + + // We cannot add X2 as an operand here for PATCHPOINT, because there is no + // way to mark dependencies as implicit here. We will add the X2 dependency + // in EmitInstrWithCustomInserter. + if (!isPatchPoint) + Ops.push_back(DAG.getRegister(PPC::X2, PtrVT)); } return CallOpc; @@ -10346,7 +10352,6 @@ PPCTargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI, // way to mark the dependence as implicit there, and so the stackmap code // will confuse it with a regular operand. Instead, add the dependence // here. - setUsesTOCBasePtr(*BB->getParent()); MI.addOperand(MachineOperand::CreateReg(PPC::X2, false, true)); } |