summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2015-10-16 23:43:27 +0000
committerReid Kleckner <rnk@google.com>2015-10-16 23:43:27 +0000
commit28e490342b570ca1f261811e98f31b52e7111cec (patch)
treeeef4a798a32aab53eb3653bf976bd9a170e3a0f6 /llvm/lib/CodeGen/AsmPrinter/WinException.cpp
parent02b74368ce181614741c7f5aa3a39a86df78f9af (diff)
downloadbcm5719-llvm-28e490342b570ca1f261811e98f31b52e7111cec.tar.gz
bcm5719-llvm-28e490342b570ca1f261811e98f31b52e7111cec.zip
[WinEH] Fix stack alignment in funclets and ParentFrameOffset calculation
Our previous value of "16 + 8 + MaxCallFrameSize" for ParentFrameOffset is incorrect when CSRs are involved. We were supposed to have a test case to catch this, but it wasn't very rigorous. The main effect here is that calling _CxxThrowException inside a catchpad doesn't immediately crash on MOVAPS when you have an odd number of CSRs. llvm-svn: 250583
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/WinException.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/WinException.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/WinException.cpp b/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
index 319320a09e0..fab5b3a59eb 100644
--- a/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
@@ -710,6 +710,13 @@ void WinException::emitCXXFrameHandler3Table(const MachineFunction *MF) {
OS.EmitValue(create32bitRef(HandlerMapXData), 4); // HandlerArray
}
+ // All funclets use the same parent frame offset currently.
+ unsigned ParentFrameOffset = 0;
+ if (shouldEmitPersonality) {
+ const TargetFrameLowering *TFI = MF->getSubtarget().getFrameLowering();
+ ParentFrameOffset = TFI->getWinEHParentFrameOffset(*MF);
+ }
+
for (size_t I = 0, E = FuncInfo.TryBlockMap.size(); I != E; ++I) {
WinEHTryBlockMapEntry &TBME = FuncInfo.TryBlockMap[I];
MCSymbol *HandlerMapXData = HandlerMaps[I];
@@ -749,13 +756,8 @@ void WinException::emitCXXFrameHandler3Table(const MachineFunction *MF) {
OS.EmitValue(create32bitRef(HT.TypeDescriptor), 4); // Type
OS.EmitValue(FrameAllocOffsetRef, 4); // CatchObjOffset
OS.EmitValue(create32bitRef(HandlerSym), 4); // Handler
-
- if (shouldEmitPersonality) {
- // Keep this in sync with X86FrameLowering::emitPrologue.
- int ParentFrameOffset =
- 16 + 8 + MF->getFrameInfo()->getMaxCallFrameSize();
+ if (shouldEmitPersonality)
OS.EmitIntValue(ParentFrameOffset, 4); // ParentFrameOffset
- }
}
}
}
OpenPOWER on IntegriCloud