From 6ea7b5b53b7bd4e72b540992b8fa5bd183e70250 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Tue, 5 Jan 2016 17:46:36 +0000 Subject: [PATCH] [X86] Determine if we have an OpaqueSPAdjustment earlier We queried hasFP before we hit ExpandISelPseudos. ExpandISelPseudos manipulated state that hasFP relied on, potentially changing the result after it has been queried elsewhere. While I am not aware of any particular bug due to this state of affairs, it seems best to avoid it entirely by changing the state during DAG construction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256849 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86ISelLowering.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 6d748ca5164..b9863d1dea2 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -17374,6 +17374,18 @@ static SDValue LowerINTRINSIC_W_CHAIN(SDValue Op, const X86Subtarget *Subtarget, if (!IntrData) { if (IntNo == llvm::Intrinsic::x86_seh_ehregnode) return MarkEHRegistrationNode(Op, DAG); + if (IntNo == llvm::Intrinsic::x86_flags_read_u32 || + IntNo == llvm::Intrinsic::x86_flags_read_u64 || + IntNo == llvm::Intrinsic::x86_flags_write_u32 || + IntNo == llvm::Intrinsic::x86_flags_write_u64) { + // We need a frame pointer because this will get lowered to a PUSH/POP + // sequence. + MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); + MFI->setHasOpaqueSPAdjustment(true); + // Don't do anything here, we will expand these intrinsics out later + // during ExpandISelPseudos in EmitInstrWithCustomInserter. + return SDValue(); + } return SDValue(); } @@ -22541,8 +22553,6 @@ X86TargetLowering::EmitInstrWithCustomInserter(MachineInstr *MI, case X86::RDFLAGS32: case X86::RDFLAGS64: { DebugLoc DL = MI->getDebugLoc(); - MachineFunction *MF = BB->getParent(); - MF->getFrameInfo()->setHasOpaqueSPAdjustment(true); const TargetInstrInfo *TII = Subtarget->getInstrInfo(); unsigned PushF = MI->getOpcode() == X86::RDFLAGS32 ? X86::PUSHF32 : X86::PUSHF64; @@ -22558,8 +22568,6 @@ X86TargetLowering::EmitInstrWithCustomInserter(MachineInstr *MI, case X86::WRFLAGS32: case X86::WRFLAGS64: { DebugLoc DL = MI->getDebugLoc(); - MachineFunction *MF = BB->getParent(); - MF->getFrameInfo()->setHasOpaqueSPAdjustment(true); const TargetInstrInfo *TII = Subtarget->getInstrInfo(); unsigned Push = MI->getOpcode() == X86::WRFLAGS32 ? X86::PUSH32r : X86::PUSH64r; -- 2.34.1