diff options
Diffstat (limited to 'lib/Target/Mips/MipsEmitGPRestore.cpp')
-rw-r--r-- | lib/Target/Mips/MipsEmitGPRestore.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Target/Mips/MipsEmitGPRestore.cpp b/lib/Target/Mips/MipsEmitGPRestore.cpp index 5b84ad8ffe..f49d490565 100644 --- a/lib/Target/Mips/MipsEmitGPRestore.cpp +++ b/lib/Target/Mips/MipsEmitGPRestore.cpp @@ -55,6 +55,20 @@ bool Inserter::runOnMachineFunction(MachineFunction &F) { MachineBasicBlock& MBB = *MFI; MachineBasicBlock::iterator I = MFI->begin(); + // If MBB is a landing pad, insert instruction that restores $gp after + // EH_LABEL. + if (MBB.isLandingPad()) { + // Find EH_LABEL first. + for (; I->getOpcode() != TargetOpcode::EH_LABEL; ++I) ; + + // Insert lw. + ++I; + DebugLoc dl = I != MBB.end() ? I->getDebugLoc() : DebugLoc(); + BuildMI(MBB, I, dl, TII->get(Mips::LW), Mips::GP).addImm(0) + .addFrameIndex(FI); + Changed = true; + } + while (I != MFI->end()) { if (I->getOpcode() != Mips::JALR) { ++I; |