diff options
| author | Jessica Paquette <jpaquette@apple.com> | 2018-03-19 22:48:40 +0000 |
|---|---|---|
| committer | Jessica Paquette <jpaquette@apple.com> | 2018-03-19 22:48:40 +0000 |
| commit | 563548d8f342ea11160b55cd2868f427108614a7 (patch) | |
| tree | 73c0fff050219f1ddd555e5ca65ea9b832f60f75 /llvm/lib | |
| parent | 956fec2a4aa7780cbe475be1db6e945a5f38c805 (diff) | |
| download | bcm5719-llvm-563548d8f342ea11160b55cd2868f427108614a7.tar.gz bcm5719-llvm-563548d8f342ea11160b55cd2868f427108614a7.zip | |
[MachineOutliner] AArch64: Emit CFI instructions when outlining calls
When outlining calls, the outliner needs to update CFI to ensure that, say,
exception handling works. This commit adds that functionality and adds a test
just for call outlining.
Call outlining stuff in machine-outliner.mir should be moved into
machine-outliner-calls.mir in a later commit.
llvm-svn: 327917
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp index 0164905a3e0..585524ebbf2 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp @@ -5282,6 +5282,25 @@ void AArch64InstrInfo::insertOutlinerEpilogue( .addImm(-16); It = MBB.insert(It, STRXpre); + const TargetSubtargetInfo &STI = MF.getSubtarget(); + const MCRegisterInfo *MRI = STI.getRegisterInfo(); + unsigned DwarfReg = MRI->getDwarfRegNum(AArch64::LR, true); + + // Add a CFI saying the stack was moved 16 B down. + int64_t StackPosEntry = + MF.addFrameInst(MCCFIInstruction::createDefCfaOffset(nullptr, 16)); + BuildMI(MBB, It, DebugLoc(), get(AArch64::CFI_INSTRUCTION)) + .addCFIIndex(StackPosEntry) + .setMIFlags(MachineInstr::FrameSetup); + + // Add a CFI saying that the LR that we want to find is now 16 B higher than + // before. + int64_t LRPosEntry = + MF.addFrameInst(MCCFIInstruction::createOffset(nullptr, DwarfReg, 16)); + BuildMI(MBB, It, DebugLoc(), get(AArch64::CFI_INSTRUCTION)) + .addCFIIndex(LRPosEntry) + .setMIFlags(MachineInstr::FrameSetup); + // Insert a restore before the terminator for the function. MachineInstr *LDRXpost = BuildMI(MF, DebugLoc(), get(AArch64::LDRXpost)) .addReg(AArch64::SP, RegState::Define) |

