[llvm] r368631 - [WinEH] Fix catch block parent frame pointer offset

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 12 16:02:00 PDT 2019


Author: rnk
Date: Mon Aug 12 16:02:00 2019
New Revision: 368631

URL: http://llvm.org/viewvc/llvm-project?rev=368631&view=rev
Log:
[WinEH] Fix catch block parent frame pointer offset

r367088 made it so that funclets store XMM registers into their local
frame instead of storing them to the parent frame. However, that change
forgot to update the parent frame pointer offset for catch blocks. This
change does that.

Fixes crashes when an exception is rethrown in a catch block that saves
XMMs, as described in https://crbug.com/992860.

Modified:
    llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
    llvm/trunk/test/CodeGen/X86/win64-funclet-savexmm.ll

Modified: llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FrameLowering.cpp?rev=368631&r1=368630&r2=368631&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FrameLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FrameLowering.cpp Mon Aug 12 16:02:00 2019
@@ -3191,14 +3191,19 @@ void X86FrameLowering::orderFrameObjects
     std::reverse(ObjectsToAllocate.begin(), ObjectsToAllocate.end());
 }
 
-
-unsigned X86FrameLowering::getWinEHParentFrameOffset(const MachineFunction &MF) const {
+unsigned
+X86FrameLowering::getWinEHParentFrameOffset(const MachineFunction &MF) const {
+  const X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
   // RDX, the parent frame pointer, is homed into 16(%rsp) in the prologue.
   unsigned Offset = 16;
   // RBP is immediately pushed.
   Offset += SlotSize;
   // All callee-saved registers are then pushed.
-  Offset += MF.getInfo<X86MachineFunctionInfo>()->getCalleeSavedFrameSize();
+  Offset += X86FI->getCalleeSavedFrameSize();
+  // Funclets allocate space for however XMM registers are required.
+  int Ignore;
+  if (MF.getTarget().getMCAsmInfo()->usesWindowsCFI())
+    Offset += X86FI->getCalleeSavedXMMFrameInfo(Ignore);
   // Every funclet allocates enough stack space for the largest outgoing call.
   Offset += getWinEHFuncletFrameSize(MF);
   return Offset;

Modified: llvm/trunk/test/CodeGen/X86/win64-funclet-savexmm.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/win64-funclet-savexmm.ll?rev=368631&r1=368630&r2=368631&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/win64-funclet-savexmm.ll (original)
+++ llvm/trunk/test/CodeGen/X86/win64-funclet-savexmm.ll Mon Aug 12 16:02:00 2019
@@ -66,3 +66,14 @@ unreachable:
 ; CHECK: popq    %rbx
 ; CHECK: popq    %rbp
 ; CHECK: retq # CATCHRET
+
+; CHECK-LABEL: "$handlerMap$0$?foo@@YAXXZ":
+; CHECK-NEXT: .long   0                       # Adjectives
+; CHECK-NEXT: .long   "??_R0H at 8"@IMGREL       # Type
+; CHECK-NEXT: .long   44                      # CatchObjOffset
+; CHECK-NEXT: .long   "?catch${{.*}}??foo@@YAXXZ at 4HA"@IMGREL # Handler
+; Sum of:
+;   16 RDX store offset
+;   16 two pushes
+;   72 stack alloc
+; CHECK-NEXT: .long   104                     # ParentFrameOffset




More information about the llvm-commits mailing list