Index: lib/Target/Mips/MipsSEInstrInfo.cpp =================================================================== --- lib/Target/Mips/MipsSEInstrInfo.cpp +++ lib/Target/Mips/MipsSEInstrInfo.cpp @@ -540,11 +540,20 @@ void MipsSEInstrInfo::expandRetRA(MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const { + + MachineInstrBuilder MIB; if (Subtarget.isGP64bit()) - BuildMI(MBB, I, I->getDebugLoc(), get(Mips::PseudoReturn64)) - .addReg(Mips::RA_64); + MIB = BuildMI(MBB, I, I->getDebugLoc(), get(Mips::PseudoReturn64)) + .addReg(Mips::RA_64, RegState::Undef); else - BuildMI(MBB, I, I->getDebugLoc(), get(Mips::PseudoReturn)).addReg(Mips::RA); + MIB = BuildMI(MBB, I, I->getDebugLoc(), get(Mips::PseudoReturn)) + .addReg(Mips::RA, RegState::Undef); + + // Retain any imp-use flags. + for (auto & MO : I->operands()) { + if (MO.isImplicit()) + MIB.add(MO); + } } void MipsSEInstrInfo::expandERet(MachineBasicBlock &MBB, Index: test/CodeGen/Mips/return_address.ll =================================================================== --- test/CodeGen/Mips/return_address.ll +++ test/CodeGen/Mips/return_address.ll @@ -1,4 +1,4 @@ -; RUN: llc -march=mipsel < %s | FileCheck %s +; RUN: llc -march=mipsel -verify-machineinstrs < %s | FileCheck %s define i8* @f1() nounwind { entry: Index: test/CodeGen/Mips/tnaked.ll =================================================================== --- test/CodeGen/Mips/tnaked.ll +++ test/CodeGen/Mips/tnaked.ll @@ -1,4 +1,4 @@ -; RUN: llc -march=mipsel < %s | FileCheck %s +; RUN: llc -march=mipsel < %s -verify-machineinstrs | FileCheck %s define void @tnaked() #0 {