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

Backport two Win64 fixes #77

Merged
merged 2 commits into from
May 4, 2017
Merged
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
4 changes: 2 additions & 2 deletions lib/CodeGen/AsmPrinter/WinException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void WinException::beginFunction(const MachineFunction *MF) {

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

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

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

// If we're not using CFI, we don't want the CFI or the personality, but we
// might want EH tables if we had EH pads.
if (!Asm->MAI->usesWindowsCFI() || (!MF->hasWinCFI() && !PerFn)) {
if (!Asm->MAI->usesWindowsCFI()) {
if (Per == EHPersonality::MSVC_X86SEH && !hasEHFunclets) {
// If this is 32-bit SEH and we don't have any funclets (really invokes),
// make sure we emit the parent offset label. Some unreferenced filter
Expand Down
4 changes: 4 additions & 0 deletions lib/Target/X86/X86FrameLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2952,6 +2952,10 @@ unsigned X86FrameLowering::getWinEHParentFrameOffset(const MachineFunction &MF)

void X86FrameLowering::processFunctionBeforeFrameFinalized(
MachineFunction &MF, RegScavenger *RS) const {
// Mark the function as not having WinCFI. We will set it back to true in
// emitPrologue if it gets called and emits CFI.
MF.setHasWinCFI(false);

// If this function isn't doing Win64-style C++ EH, we don't need to do
// anything.
const Function *Fn = MF.getFunction();
Expand Down
9 changes: 9 additions & 0 deletions test/CodeGen/X86/win64_eh_leaf.ll
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,12 @@ entry:
; and no unwind info in the object file.
; READOBJ-NOT: leaf_func
}

define void @naked_func() naked {
call void asm sideeffect "ret", ""()
unreachable
}
; ASM-LABEL: naked_func:
; ASM-NOT: .seh_
; ASM: ret
; ASM-NOT: .seh_
22 changes: 22 additions & 0 deletions test/CodeGen/X86/win64_eh_leaf2.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
; RUN: llc < %s -O1 -mtriple=x86_64-pc-win32 | FileCheck %s

; Neither of these functions need .seh_ directives. We used to crash.

target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"

declare i32 @__CxxFrameHandler3(...)

define void @f1() uwtable nounwind personality i32 (...)* @__CxxFrameHandler3 {
ret void
}

; CHECK-LABEL: f1:
; CHECK-NOT: .seh_

define void @f2() uwtable {
ret void
}

; CHECK-LABEL: f2:
; CHECK-NOT: .seh_