[PATCH] D18725: Assure calling cld instruction in prologue of interrupt handler function
Amjad Aboud via llvm-commits
llvm-commits at lists.llvm.org
Fri May 13 05:53:07 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269413: Assure calling "cld" instruction in prologue of X86 interrupt handler function. (authored by aaboud).
Changed prior to commit:
http://reviews.llvm.org/D18725?vs=52466&id=57166#toc
Repository:
rL LLVM
http://reviews.llvm.org/D18725
Files:
llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
llvm/trunk/test/CodeGen/X86/x86-interrupt_cld.ll
Index: llvm/trunk/test/CodeGen/X86/x86-interrupt_cld.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/x86-interrupt_cld.ll
+++ llvm/trunk/test/CodeGen/X86/x86-interrupt_cld.ll
@@ -0,0 +1,17 @@
+; RUN: llc -mtriple=x86_64-unknown-unknown < %s | FileCheck %s
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Checks that interrupt handler code calls cld before calling an external
+;; function.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+; CHECK: cld
+; CHECK: call
+
+define x86_intrcc void @foo(i8* %frame) {
+ call void @bar()
+ ret void
+}
+
+declare void @bar()
+
Index: llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
===================================================================
--- llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
+++ llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
@@ -1381,6 +1381,18 @@
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(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18725.57166.patch
Type: text/x-patch
Size: 1656 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160513/71e4ec90/attachment.bin>
More information about the llvm-commits
mailing list