Skip to content

[X86] Stop emitting CFI instructions on i386-windows #135648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/Target/X86/X86CallFrameOptimization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ void X86CallFrameOptimization::adjustCallSequence(MachineFunction &MF,
// For debugging, when using SP-based CFA, we need to adjust the CFA
// offset after each push.
// TODO: This is needed only if we require precise CFA.
if (!TFL->hasFP(MF))
if (TFL->needsDwarfCFI(MF) && !TFL->hasFP(MF))
TFL->BuildCFI(
MBB, std::next(Push), DL,
MCCFIInstruction::createAdjustCfaOffset(nullptr, SlotSize));
Expand Down
9 changes: 5 additions & 4 deletions llvm/lib/Target/X86/X86FrameLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,9 @@ bool X86FrameLowering::isWin64Prologue(const MachineFunction &MF) const {
}

bool X86FrameLowering::needsDwarfCFI(const MachineFunction &MF) const {
return !isWin64Prologue(MF) && MF.needsFrameMoves();
return MF.getTarget().getMCAsmInfo()->getExceptionHandlingType() !=
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effectively this is switching from MCAsmInfo::usesWindowsCFI to getExceptionHandlingType() != Windows.

I think the CFI check seems more logically correct.

I'm OK with the goal, but this code change doesn't seem self-explanatory.

ExceptionHandling::WinEH &&
MF.needsFrameMoves();
}

/// Return true if an opcode is part of the REP group of instructions
Expand Down Expand Up @@ -3808,8 +3810,7 @@ MachineBasicBlock::iterator X86FrameLowering::eliminateCallFramePseudoInstr(
Amount = alignTo(Amount, getStackAlign());

const Function &F = MF.getFunction();
bool WindowsCFI = MF.getTarget().getMCAsmInfo()->usesWindowsCFI();
bool DwarfCFI = !WindowsCFI && MF.needsFrameMoves();
bool DwarfCFI = needsDwarfCFI(MF);

// If we have any exception handlers in this function, and we adjust
// the SP before calls, we may need to indicate this to the unwinder
Expand All @@ -3818,7 +3819,7 @@ MachineBasicBlock::iterator X86FrameLowering::eliminateCallFramePseudoInstr(
// GNU_ARGS_SIZE.
// TODO: We don't need to reset this between subsequent functions,
// if it didn't change.
bool HasDwarfEHHandlers = !WindowsCFI && !MF.getLandingPads().empty();
bool HasDwarfEHHandlers = DwarfCFI && !MF.getLandingPads().empty();

if (HasDwarfEHHandlers && !isDestroy &&
MF.getInfo<X86MachineFunctionInfo>()->getHasPushSequences())
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/X86/X86FrameLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,14 @@ class X86FrameLowering : public TargetFrameLowering {
/// frame of the top of stack function) as part of it's ABI.
bool has128ByteRedZone(const MachineFunction& MF) const;

bool needsDwarfCFI(const MachineFunction &MF) const;

protected:
bool hasFPImpl(const MachineFunction &MF) const override;

private:
bool isWin64Prologue(const MachineFunction &MF) const;

bool needsDwarfCFI(const MachineFunction &MF) const;

uint64_t calculateMaxStackAlign(const MachineFunction &MF) const;

/// Emit target stack probe as a call to a helper function
Expand Down
2 changes: 0 additions & 2 deletions llvm/test/CodeGen/MIR/X86/diexpr-win32.mir
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ body: |
liveins: $esi

frame-setup PUSH32r killed $esi, implicit-def $esp, implicit $esp
CFI_INSTRUCTION def_cfa_offset 8
CFI_INSTRUCTION offset $esi, -8
$esi = MOV32rm $esp, 1, _, 8, _ :: (load (s32) from %fixed-stack.2)
DBG_VALUE $esp, 0, !26, !10, debug-location !25
DBG_VALUE $esp, 0, !23, !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref), debug-location !25
Expand Down
14 changes: 7 additions & 7 deletions llvm/test/CodeGen/X86/2008-04-16-ReMatBug.ll
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ define i16 @SQLDriversW(ptr %henv, i16 zeroext %fDir, ptr %szDrvDesc, i16 signe
; CHECK-NEXT: ## %bb.4: ## %bb37
; CHECK-NEXT: movw $0, 40(%edi)
; CHECK-NEXT: testb %al, %al
; CHECK-NEXT: leal (,%ecx,4), %ecx
; CHECK-NEXT: leal (,%ebx,4), %edx
; CHECK-NEXT: leal (,%ecx,4), %eax
; CHECK-NEXT: leal (,%ebx,4), %ecx
; CHECK-NEXT: subl $12, %esp
; CHECK-NEXT: movzwl %bp, %eax
; CHECK-NEXT: movzwl %bp, %edx
; CHECK-NEXT: cwtl
; CHECK-NEXT: movswl %cx, %ecx
; CHECK-NEXT: movswl %dx, %edx
; CHECK-NEXT: pushl $87
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
; CHECK-NEXT: pushl %ecx
; CHECK-NEXT: pushl %eax
; CHECK-NEXT: pushl $0
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
; CHECK-NEXT: pushl %edx
; CHECK-NEXT: pushl %ecx
; CHECK-NEXT: pushl $0
; CHECK-NEXT: pushl %eax
; CHECK-NEXT: pushl %edx
; CHECK-NEXT: pushl %edi
; CHECK-NEXT: calll _SQLDrivers_Internal
; CHECK-NEXT: addl $48, %esp
Expand Down
20 changes: 10 additions & 10 deletions llvm/test/CodeGen/X86/andnot-patterns.ll
Original file line number Diff line number Diff line change
Expand Up @@ -198,28 +198,28 @@ define i64 @andnot_rotl_i64_multiuse_rot(i64 %a0, i64 %a1, i64 %a2) nounwind {
; X86-NEXT: pushl %esi
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
; X86-NEXT: notl %edx
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
; X86-NEXT: notl %eax
; X86-NEXT: notl %esi
; X86-NEXT: testb $32, %cl
; X86-NEXT: jne .LBB4_1
; X86-NEXT: # %bb.2:
; X86-NEXT: movl %esi, %eax
; X86-NEXT: movl %esi, %edx
; X86-NEXT: jmp .LBB4_3
; X86-NEXT: .LBB4_1:
; X86-NEXT: movl %edx, %eax
; X86-NEXT: movl %esi, %edx
; X86-NEXT: movl %eax, %edx
; X86-NEXT: movl %esi, %eax
; X86-NEXT: .LBB4_3:
; X86-NEXT: movl %edx, %ebx
; X86-NEXT: shldl %cl, %eax, %ebx
; X86-NEXT: movl %eax, %ebx
; X86-NEXT: shldl %cl, %edx, %ebx
; X86-NEXT: # kill: def $cl killed $cl killed $ecx
; X86-NEXT: shldl %cl, %edx, %eax
; X86-NEXT: shldl %cl, %eax, %edx
; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
; X86-NEXT: andl %eax, %esi
; X86-NEXT: andl %edx, %esi
; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
; X86-NEXT: andl %ebx, %edi
; X86-NEXT: pushl %ebx
; X86-NEXT: pushl %eax
; X86-NEXT: pushl %edx
; X86-NEXT: calll use_i64@PLT
; X86-NEXT: addl $8, %esp
; X86-NEXT: movl %esi, %eax
Expand Down
10 changes: 5 additions & 5 deletions llvm/test/CodeGen/X86/fp128-cast.ll
Original file line number Diff line number Diff line change
Expand Up @@ -1139,19 +1139,19 @@ define dso_local i32 @TestBits128(fp128 %ld) nounwind {
; X86-NEXT: subl $20, %esp
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
; X86-NEXT: subl $12, %esp
; X86-NEXT: leal {{[0-9]+}}(%esp), %edx
; X86-NEXT: pushl %edi
; X86-NEXT: leal {{[0-9]+}}(%esp), %edi
; X86-NEXT: pushl %esi
; X86-NEXT: pushl %edx
; X86-NEXT: pushl %ecx
; X86-NEXT: pushl %eax
; X86-NEXT: pushl %edi
; X86-NEXT: pushl %esi
; X86-NEXT: pushl %edx
; X86-NEXT: pushl %ecx
; X86-NEXT: pushl %eax
; X86-NEXT: pushl %edx
; X86-NEXT: pushl %edi
; X86-NEXT: calll __multf3
; X86-NEXT: addl $44, %esp
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
Expand Down
24 changes: 12 additions & 12 deletions llvm/test/CodeGen/X86/fp128-libcalls-strict.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3418,28 +3418,28 @@ define i64 @cmp_ueq_q(i64 %a, i64 %b, fp128 %x, fp128 %y) #0 {
; X86-NEXT: pushl %edi
; X86-NEXT: pushl %esi
; X86-NEXT: subl $12, %esp
; X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
; X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
; X86-NEXT: pushl %ebp
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %esi
; X86-NEXT: pushl %edi
; X86-NEXT: pushl %ebp
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: calll __eqtf2
; X86-NEXT: addl $32, %esp
; X86-NEXT: testl %eax, %eax
; X86-NEXT: sete %bl
; X86-NEXT: pushl %ebp
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %esi
; X86-NEXT: pushl %edi
; X86-NEXT: pushl %ebp
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: calll __unordtf2
; X86-NEXT: addl $32, %esp
Expand Down Expand Up @@ -3501,28 +3501,28 @@ define i64 @cmp_ueq_q(i64 %a, i64 %b, fp128 %x, fp128 %y) #0 {
; WIN-X86-NEXT: pushl %ebx
; WIN-X86-NEXT: pushl %edi
; WIN-X86-NEXT: pushl %esi
; WIN-X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
; WIN-X86-NEXT: movl {{[0-9]+}}(%esp), %edi
; WIN-X86-NEXT: movl {{[0-9]+}}(%esp), %esi
; WIN-X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
; WIN-X86-NEXT: pushl %ebp
; WIN-X86-NEXT: pushl {{[0-9]+}}(%esp)
; WIN-X86-NEXT: pushl {{[0-9]+}}(%esp)
; WIN-X86-NEXT: pushl {{[0-9]+}}(%esp)
; WIN-X86-NEXT: pushl {{[0-9]+}}(%esp)
; WIN-X86-NEXT: pushl %esi
; WIN-X86-NEXT: pushl %edi
; WIN-X86-NEXT: pushl %ebp
; WIN-X86-NEXT: pushl {{[0-9]+}}(%esp)
; WIN-X86-NEXT: calll ___eqtf2
; WIN-X86-NEXT: addl $32, %esp
; WIN-X86-NEXT: testl %eax, %eax
; WIN-X86-NEXT: sete %bl
; WIN-X86-NEXT: pushl %ebp
; WIN-X86-NEXT: pushl {{[0-9]+}}(%esp)
; WIN-X86-NEXT: pushl {{[0-9]+}}(%esp)
; WIN-X86-NEXT: pushl {{[0-9]+}}(%esp)
; WIN-X86-NEXT: pushl {{[0-9]+}}(%esp)
; WIN-X86-NEXT: pushl %esi
; WIN-X86-NEXT: pushl %edi
; WIN-X86-NEXT: pushl %ebp
; WIN-X86-NEXT: pushl {{[0-9]+}}(%esp)
; WIN-X86-NEXT: calll ___unordtf2
; WIN-X86-NEXT: addl $32, %esp
Expand Down Expand Up @@ -3640,28 +3640,28 @@ define i64 @cmp_one_q(i64 %a, i64 %b, fp128 %x, fp128 %y) #0 {
; X86-NEXT: pushl %edi
; X86-NEXT: pushl %esi
; X86-NEXT: subl $12, %esp
; X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
; X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
; X86-NEXT: pushl %ebp
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %esi
; X86-NEXT: pushl %edi
; X86-NEXT: pushl %ebp
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: calll __eqtf2
; X86-NEXT: addl $32, %esp
; X86-NEXT: testl %eax, %eax
; X86-NEXT: setne %bl
; X86-NEXT: pushl %ebp
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %esi
; X86-NEXT: pushl %edi
; X86-NEXT: pushl %ebp
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: calll __unordtf2
; X86-NEXT: addl $32, %esp
Expand Down Expand Up @@ -3723,28 +3723,28 @@ define i64 @cmp_one_q(i64 %a, i64 %b, fp128 %x, fp128 %y) #0 {
; WIN-X86-NEXT: pushl %ebx
; WIN-X86-NEXT: pushl %edi
; WIN-X86-NEXT: pushl %esi
; WIN-X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
; WIN-X86-NEXT: movl {{[0-9]+}}(%esp), %edi
; WIN-X86-NEXT: movl {{[0-9]+}}(%esp), %esi
; WIN-X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
; WIN-X86-NEXT: pushl %ebp
; WIN-X86-NEXT: pushl {{[0-9]+}}(%esp)
; WIN-X86-NEXT: pushl {{[0-9]+}}(%esp)
; WIN-X86-NEXT: pushl {{[0-9]+}}(%esp)
; WIN-X86-NEXT: pushl {{[0-9]+}}(%esp)
; WIN-X86-NEXT: pushl %esi
; WIN-X86-NEXT: pushl %edi
; WIN-X86-NEXT: pushl %ebp
; WIN-X86-NEXT: pushl {{[0-9]+}}(%esp)
; WIN-X86-NEXT: calll ___eqtf2
; WIN-X86-NEXT: addl $32, %esp
; WIN-X86-NEXT: testl %eax, %eax
; WIN-X86-NEXT: setne %bl
; WIN-X86-NEXT: pushl %ebp
; WIN-X86-NEXT: pushl {{[0-9]+}}(%esp)
; WIN-X86-NEXT: pushl {{[0-9]+}}(%esp)
; WIN-X86-NEXT: pushl {{[0-9]+}}(%esp)
; WIN-X86-NEXT: pushl {{[0-9]+}}(%esp)
; WIN-X86-NEXT: pushl %esi
; WIN-X86-NEXT: pushl %edi
; WIN-X86-NEXT: pushl %ebp
; WIN-X86-NEXT: pushl {{[0-9]+}}(%esp)
; WIN-X86-NEXT: calll ___unordtf2
; WIN-X86-NEXT: addl $32, %esp
Expand Down
Loading
Loading