[WinEH] Only generate UnwindHelp slot for MSVCXX
authorJoseph Tremoulet <jotrem@microsoft.com>
Wed, 11 Nov 2015 19:21:09 +0000 (19:21 +0000)
committerJoseph Tremoulet <jotrem@microsoft.com>
Wed, 11 Nov 2015 19:21:09 +0000 (19:21 +0000)
Summary: Other personalities don't use this special frame slot.

Reviewers: majnemer, andrew.w.kaylor, rnk

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D14580

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252778 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/seh-catchpad.ll

index 9513176..a0ffa12 100644 (file)
@@ -2878,18 +2878,18 @@ SDValue X86TargetLowering::LowerFormalArguments(
 
   FuncInfo->setArgumentStackSize(StackSize);
 
-  if (MMI.hasWinEHFuncInfo(Fn)) {
-    if (Is64Bit) {
-      int UnwindHelpFI = MFI->CreateStackObject(8, 8, /*isSS=*/false);
-      SDValue StackSlot = DAG.getFrameIndex(UnwindHelpFI, MVT::i64);
-      MMI.getWinEHFuncInfo(MF.getFunction()).UnwindHelpFrameIdx = UnwindHelpFI;
-      SDValue Neg2 = DAG.getConstant(-2, dl, MVT::i64);
-      Chain = DAG.getStore(Chain, dl, Neg2, StackSlot,
-                           MachinePointerInfo::getFixedStack(
-                               DAG.getMachineFunction(), UnwindHelpFI),
-                           /*isVolatile=*/true,
-                           /*isNonTemporal=*/false, /*Alignment=*/0);
-    }
+  if (MMI.hasWinEHFuncInfo(Fn) && Is64Bit &&
+      classifyEHPersonality(Fn->getPersonalityFn()) ==
+          EHPersonality::MSVC_CXX) {
+    int UnwindHelpFI = MFI->CreateStackObject(8, 8, /*isSS=*/false);
+    SDValue StackSlot = DAG.getFrameIndex(UnwindHelpFI, MVT::i64);
+    MMI.getWinEHFuncInfo(MF.getFunction()).UnwindHelpFrameIdx = UnwindHelpFI;
+    SDValue Neg2 = DAG.getConstant(-2, dl, MVT::i64);
+    Chain = DAG.getStore(Chain, dl, Neg2, StackSlot,
+                         MachinePointerInfo::getFixedStack(
+                             DAG.getMachineFunction(), UnwindHelpFI),
+                         /*isVolatile=*/true,
+                         /*isNonTemporal=*/false, /*Alignment=*/0);
   }
 
   return Chain;
index 93775b6..895dba8 100644 (file)
@@ -97,10 +97,10 @@ ehcleanup.end:                                    ; preds = %ehcleanup
 ; CHECK:         .seh_handler __C_specific_handler, @unwind, @except
 ; CHECK:         pushq   %rbp
 ; CHECK:         .seh_pushreg 5
-; CHECK:         subq    $48, %rsp
-; CHECK:         .seh_stackalloc 48
-; CHECK:         leaq    48(%rsp), %rbp
-; CHECK:         .seh_setframe 5, 48
+; CHECK:         subq    $32, %rsp
+; CHECK:         .seh_stackalloc 32
+; CHECK:         leaq    32(%rsp), %rbp
+; CHECK:         .seh_setframe 5, 32
 ; CHECK:         .seh_endprologue
 ; CHECK: .Ltmp0:
 ; CHECK:         movl    $1, %ecx
@@ -109,7 +109,7 @@ ehcleanup.end:                                    ; preds = %ehcleanup
 ; CHECK: .Ltmp1:
 ; CHECK: .LBB1_[[epilogue:[0-9]+]]:                                # %__try.cont.12
 ; CHECK:         xorl    %eax, %eax
-; CHECK:         addq    $48, %rsp
+; CHECK:         addq    $32, %rsp
 ; CHECK:         popq    %rbp
 ; CHECK:         retq
 ; CHECK: .LBB1_[[except1bb:[0-9]+]]:                                # %catch.dispatch
@@ -162,7 +162,7 @@ ehcleanup.end:                                    ; preds = %ehcleanup
 ; CHECK:         .seh_pushreg 5
 ; CHECK:         subq    $32, %rsp
 ; CHECK:         .seh_stackalloc 32
-; CHECK:         leaq    48(%rdx), %rbp
+; CHECK:         leaq    32(%rdx), %rbp
 ; CHECK:         .seh_endprologue
 ; CHECK:         callq   "?fin$0@0@main@@"
 ; CHECK:         nop