diff options
author | Matthias Braun <matze@braunis.de> | 2017-09-28 23:12:06 +0000 |
---|---|---|
committer | Matthias Braun <matze@braunis.de> | 2017-09-28 23:12:06 +0000 |
commit | 51687912a4da910426c8daf40994fde3a9ac3520 (patch) | |
tree | 6fc94a09eb23f18e965e47e6b164f0f6606cb4fe /llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp | |
parent | 195b25cf3cbde92e8613465571b5f3511c5cc69d (diff) | |
download | llvm-51687912a4da910426c8daf40994fde3a9ac3520.zip llvm-51687912a4da910426c8daf40994fde3a9ac3520.tar.gz llvm-51687912a4da910426c8daf40994fde3a9ac3520.tar.bz2 |
ARM: Fix cases where CSI Restored bit is not cleared
LR is an untypical callee saved register in that it is restored into a
different register (PC) and thus does not live-out of the return block.
This case requires the `Restored` flag in CalleeSavedInfo to be cleared.
This fixes a number of cases where this wasn't handled correctly yet.
llvm-svn: 314471
Diffstat (limited to 'llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp')
-rw-r--r-- | llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp b/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp index 47e4956..4aa7e15 100644 --- a/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp +++ b/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp @@ -1909,6 +1909,17 @@ bool ARMLoadStoreOpt::MergeReturnIntoLDM(MachineBasicBlock &MBB) { MO.setReg(ARM::PC); PrevMI.copyImplicitOps(*MBB.getParent(), *MBBI); MBB.erase(MBBI); + // We now restore LR into PC so it is not live-out of the return block + // anymore: Clear the CSI Restored bit. + MachineFrameInfo &MFI = MBB.getParent()->getFrameInfo(); + // CSI should be fixed after PrologEpilog Insertion + assert(MFI.isCalleeSavedInfoValid() && "CSI should be valid"); + for (CalleeSavedInfo &Info : MFI.getCalleeSavedInfo()) { + if (Info.getReg() == ARM::LR) { + Info.setRestored(false); + break; + } + } return true; } } |