diff --git a/lib/Target/PowerPC/PPCFrameLowering.cpp b/lib/Target/PowerPC/PPCFrameLowering.cpp index 40a2e8bbe23..3954ee72c11 100644 --- a/lib/Target/PowerPC/PPCFrameLowering.cpp +++ b/lib/Target/PowerPC/PPCFrameLowering.cpp @@ -843,12 +843,15 @@ void PPCFrameLowering::emitPrologue(MachineFunction &MF, // mfocrf to selectively save just those fields, because mfocrf has short // latency compares to mfcr. unsigned MfcrOpcode = PPC::MFCR8; - if (isELFv2ABI && MustSaveCRs.size() == 1) + unsigned CrState = RegState::ImplicitKill; + if (isELFv2ABI && MustSaveCRs.size() == 1) { MfcrOpcode = PPC::MFOCRF8; + CrState = RegState::Kill; + } MachineInstrBuilder MIB = BuildMI(MBB, MBBI, dl, TII.get(MfcrOpcode), TempReg); for (unsigned i = 0, e = MustSaveCRs.size(); i != e; ++i) - MIB.addReg(MustSaveCRs[i], RegState::ImplicitKill); + MIB.addReg(MustSaveCRs[i], CrState); BuildMI(MBB, MBBI, dl, TII.get(PPC::STW8)) .addReg(TempReg, getKillRegState(true)) .addImm(8) @@ -865,12 +868,15 @@ void PPCFrameLowering::emitPrologue(MachineFunction &MF, // mfocrf to selectively save just those fields, because mfocrf has short // latency compares to mfcr. unsigned MfcrOpcode = PPC::MFCR8; - if (isELFv2ABI && MustSaveCRs.size() == 1) + unsigned CrState = RegState::ImplicitKill; + if (isELFv2ABI && MustSaveCRs.size() == 1) { MfcrOpcode = PPC::MFOCRF8; + CrState = RegState::Kill; + } MachineInstrBuilder MIB = BuildMI(MBB, MBBI, dl, TII.get(MfcrOpcode), TempReg); for (unsigned i = 0, e = MustSaveCRs.size(); i != e; ++i) - MIB.addReg(MustSaveCRs[i], RegState::ImplicitKill); + MIB.addReg(MustSaveCRs[i], CrState); } if (HasFP) diff --git a/test/CodeGen/PowerPC/crsave.ll b/test/CodeGen/PowerPC/crsave.ll index 4975afcce75..a079e7f1585 100644 --- a/test/CodeGen/PowerPC/crsave.ll +++ b/test/CodeGen/PowerPC/crsave.ll @@ -1,6 +1,6 @@ ; RUN: llc -O0 -disable-fp-elim -mtriple=powerpc-unknown-linux-gnu -mcpu=g5 < %s | FileCheck %s -check-prefix=PPC32 ; RUN: llc -O0 -mtriple=powerpc64-unknown-linux-gnu -mcpu=g5 < %s | FileCheck %s -check-prefix=PPC64 -; RUN: llc -O0 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s -check-prefix=PPC64-ELFv2 +; RUN: llc -O0 -mtriple=powerpc64le-unknown-linux-gnu -verify-machineinstrs < %s | FileCheck %s -check-prefix=PPC64-ELFv2 declare void @foo()