Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit cf85b5a

Browse files
authored
Merge pull request #77 from TimNN/win64-backports
Backport two Win64 fixes
2 parents 917dcde + 508425c commit cf85b5a

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

lib/CodeGen/AsmPrinter/WinException.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void WinException::beginFunction(const MachineFunction *MF) {
6868

6969
const Function *F = MF->getFunction();
7070

71-
shouldEmitMoves = Asm->needsSEHMoves();
71+
shouldEmitMoves = Asm->needsSEHMoves() && MF->hasWinCFI();
7272

7373
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
7474
unsigned PerEncoding = TLOF.getPersonalityEncoding();
@@ -94,7 +94,7 @@ void WinException::beginFunction(const MachineFunction *MF) {
9494

9595
// If we're not using CFI, we don't want the CFI or the personality, but we
9696
// might want EH tables if we had EH pads.
97-
if (!Asm->MAI->usesWindowsCFI() || (!MF->hasWinCFI() && !PerFn)) {
97+
if (!Asm->MAI->usesWindowsCFI()) {
9898
if (Per == EHPersonality::MSVC_X86SEH && !hasEHFunclets) {
9999
// If this is 32-bit SEH and we don't have any funclets (really invokes),
100100
// make sure we emit the parent offset label. Some unreferenced filter

lib/Target/X86/X86FrameLowering.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2952,6 +2952,10 @@ unsigned X86FrameLowering::getWinEHParentFrameOffset(const MachineFunction &MF)
29522952

29532953
void X86FrameLowering::processFunctionBeforeFrameFinalized(
29542954
MachineFunction &MF, RegScavenger *RS) const {
2955+
// Mark the function as not having WinCFI. We will set it back to true in
2956+
// emitPrologue if it gets called and emits CFI.
2957+
MF.setHasWinCFI(false);
2958+
29552959
// If this function isn't doing Win64-style C++ EH, we don't need to do
29562960
// anything.
29572961
const Function *Fn = MF.getFunction();

test/CodeGen/X86/win64_eh_leaf.ll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,12 @@ entry:
2929
; and no unwind info in the object file.
3030
; READOBJ-NOT: leaf_func
3131
}
32+
33+
define void @naked_func() naked {
34+
call void asm sideeffect "ret", ""()
35+
unreachable
36+
}
37+
; ASM-LABEL: naked_func:
38+
; ASM-NOT: .seh_
39+
; ASM: ret
40+
; ASM-NOT: .seh_

test/CodeGen/X86/win64_eh_leaf2.ll

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; RUN: llc < %s -O1 -mtriple=x86_64-pc-win32 | FileCheck %s
2+
3+
; Neither of these functions need .seh_ directives. We used to crash.
4+
5+
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
6+
target triple = "x86_64-pc-windows-msvc"
7+
8+
declare i32 @__CxxFrameHandler3(...)
9+
10+
define void @f1() uwtable nounwind personality i32 (...)* @__CxxFrameHandler3 {
11+
ret void
12+
}
13+
14+
; CHECK-LABEL: f1:
15+
; CHECK-NOT: .seh_
16+
17+
define void @f2() uwtable {
18+
ret void
19+
}
20+
21+
; CHECK-LABEL: f2:
22+
; CHECK-NOT: .seh_

0 commit comments

Comments
 (0)