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

Commit ea87f9f

Browse files
rnkTimNN
authored andcommitted
[WinEH] Adjust decision to emit SEH moves for leaf functions
Move the check for "MF->hasWinCFI()" up into the calculation of the shouldEmitMoves boolean, rather than putting it in the early returning if. This ensures that endFunction doesn't try to emit .seh_* directives for leaf functions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298276 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 1c788d8 commit ea87f9f

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-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

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)