summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/X86/X86FrameLowering.cpp
diff options
context:
space:
mode:
authorAmjad Aboud <amjad.aboud@intel.com>2016-05-13 12:46:57 +0000
committerAmjad Aboud <amjad.aboud@intel.com>2016-05-13 12:46:57 +0000
commit78b1fb01466818fd1296cd32805d4ecf1655fef8 (patch)
treefaa8fa17c68e1e3a7e64ad3eb4ec897753386497 /llvm/lib/Target/X86/X86FrameLowering.cpp
parentfc1186510b79c0dbc4ff521fcb37f6c83e564c71 (diff)
downloadbcm5719-llvm-78b1fb01466818fd1296cd32805d4ecf1655fef8.tar.gz
bcm5719-llvm-78b1fb01466818fd1296cd32805d4ecf1655fef8.zip
Assure calling "cld" instruction in prologue of X86 interrupt handler function.
Differential Revision: http://reviews.llvm.org/D18725 llvm-svn: 269413
Diffstat (limited to 'llvm/lib/Target/X86/X86FrameLowering.cpp')
-rw-r--r--llvm/lib/Target/X86/X86FrameLowering.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86FrameLowering.cpp b/llvm/lib/Target/X86/X86FrameLowering.cpp
index 8a283775138..700ebf9e91c 100644
--- a/llvm/lib/Target/X86/X86FrameLowering.cpp
+++ b/llvm/lib/Target/X86/X86FrameLowering.cpp
@@ -1381,6 +1381,18 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF,
if (PushedRegs)
emitCalleeSavedFrameMoves(MBB, MBBI, DL);
}
+
+ // X86 Interrupt handling function cannot assume anything about the direction
+ // flag (DF in EFLAGS register). Clear this flag by creating "cld" instruction
+ // in each prologue of interrupt handler function.
+ //
+ // FIXME: Create "cld" instruction only in these cases:
+ // 1. The interrupt handling function uses any of the "rep" instructions.
+ // 2. Interrupt handling function calls another function.
+ //
+ if (Fn->getCallingConv() == CallingConv::X86_INTR)
+ BuildMI(MBB, MBBI, DL, TII.get(X86::CLD))
+ .setMIFlag(MachineInstr::FrameSetup);
}
bool X86FrameLowering::canUseLEAForSPInEpilogue(
OpenPOWER on IntegriCloud