mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-25 15:41:05 +00:00
Assure calling "cld" instruction in prologue of X86 interrupt handler function.
Differential Revision: http://reviews.llvm.org/D18725 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269413 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ce7190c29e
commit
c0cc51c8de
@ -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(
|
||||
|
17
test/CodeGen/X86/x86-interrupt_cld.ll
Normal file
17
test/CodeGen/X86/x86-interrupt_cld.ll
Normal file
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user