Skip to content

Commit 53946bf

Browse files
author
Michael Kuperstein
committedDec 15, 2015
[X86] MOVPC32r should only emit CFI adjustments when needed
We only want to emit CFI adjustments when actually using DWARF. This fixes PR25828. Differential Revision: http://reviews.llvm.org/D15522 llvm-svn: 255664
1 parent 0abd281 commit 53946bf

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed
 

‎llvm/lib/Target/X86/X86MCInstLower.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,11 +1145,12 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
11451145
bool hasFP = FrameLowering->hasFP(*MF);
11461146

11471147
// TODO: This is needed only if we require precise CFA.
1148-
bool NeedsDwarfCFI =
1149-
(MMI->hasDebugInfo() || MF->getFunction()->needsUnwindTableEntry());
1148+
bool HasActiveDwarfFrame = OutStreamer->getNumFrameInfos() &&
1149+
!OutStreamer->getDwarfFrameInfos().back().End;
1150+
11501151
int stackGrowth = -RI->getSlotSize();
11511152

1152-
if (NeedsDwarfCFI && !hasFP) {
1153+
if (HasActiveDwarfFrame && !hasFP) {
11531154
OutStreamer->EmitCFIAdjustCfaOffset(-stackGrowth);
11541155
}
11551156

@@ -1160,7 +1161,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
11601161
EmitAndCountInstruction(MCInstBuilder(X86::POP32r)
11611162
.addReg(MI->getOperand(0).getReg()));
11621163

1163-
if (NeedsDwarfCFI && !hasFP) {
1164+
if (HasActiveDwarfFrame && !hasFP) {
11641165
OutStreamer->EmitCFIAdjustCfaOffset(stackGrowth);
11651166
}
11661167
return;

‎llvm/test/CodeGen/X86/pr25828.ll

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
; RUN: llc < %s -mtriple=i686-pc-windows-msvc -relocation-model=pic | FileCheck %s
2+
; MOVPC32r should not generate CFI under windows
3+
4+
; CHECK-LABEL: _foo:
5+
; CHECK-NOT: .cfi_adjust_cfa_offset
6+
define void @foo(i8) {
7+
entry-block:
8+
switch i8 %0, label %bb2 [
9+
i8 1, label %bb1
10+
i8 2, label %bb2
11+
i8 3, label %bb3
12+
i8 4, label %bb4
13+
i8 5, label %bb5
14+
]
15+
16+
bb1:
17+
ret void
18+
19+
bb2:
20+
ret void
21+
22+
bb3:
23+
ret void
24+
25+
bb4:
26+
ret void
27+
28+
bb5:
29+
ret void
30+
}

0 commit comments

Comments
 (0)
Please sign in to comment.