summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2015-10-07 21:13:15 +0000
committerReid Kleckner <rnk@google.com>2015-10-07 21:13:15 +0000
commit70bf6bb5e6b8e3ddde3245d36cf7f84d05297fd5 (patch)
tree8d698df9d497267a261ff9996f33ce3259a202f2 /llvm/lib/CodeGen/AsmPrinter/WinException.cpp
parentc289c9ff553424791d9b72b6eb5529f9f14e58d9 (diff)
downloadbcm5719-llvm-70bf6bb5e6b8e3ddde3245d36cf7f84d05297fd5.tar.gz
bcm5719-llvm-70bf6bb5e6b8e3ddde3245d36cf7f84d05297fd5.zip
[WinEH] Undo the effect of r249578 for 32-bit
The __CxxFrameHandler3 tables for 32-bit are supposed to hold stack offsets relative to EBP, not ESP. I blindly updated the win-catchpad.ll test case, and immediately noticed that 32-bit catching stopped working. While I'm at it, move the frame index to frame offset WinEH table logic out of PEI. PEI shouldn't have to know about WinEHFuncInfo. I realized we can calculate frame index offsets just fine from the table printer. llvm-svn: 249618
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/WinException.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/WinException.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/WinException.cpp b/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
index bc2c9ee635c..f672f93a3ee 100644
--- a/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
@@ -38,6 +38,7 @@
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Target/TargetRegisterInfo.h"
+#include "llvm/Target/TargetSubtargetInfo.h"
using namespace llvm;
WinException::WinException(AsmPrinter *A) : EHStreamer(A) {
@@ -292,6 +293,14 @@ const MCExpr *WinException::getLabelPlusOne(MCSymbol *Label) {
Asm->OutContext);
}
+int WinException::getFrameIndexOffset(int FrameIndex) {
+ const TargetFrameLowering &TFI = *Asm->MF->getSubtarget().getFrameLowering();
+ unsigned UnusedReg;
+ if (Asm->MAI->usesWindowsCFI())
+ return TFI.getFrameIndexReferenceFromSP(*Asm->MF, FrameIndex, UnusedReg);
+ return TFI.getFrameIndexReference(*Asm->MF, FrameIndex, UnusedReg);
+}
+
namespace {
/// Information describing an invoke range.
struct InvokeRange {
@@ -599,6 +608,10 @@ void WinException::emitCXXFrameHandler3Table(const MachineFunction *MF) {
emitEHRegistrationOffsetLabel(FuncInfo, FuncLinkageName);
}
+ int UnwindHelpOffset = 0;
+ if (Asm->MAI->usesWindowsCFI())
+ UnwindHelpOffset = getFrameIndexOffset(FuncInfo.UnwindHelpFrameIdx);
+
MCSymbol *UnwindMapXData = nullptr;
MCSymbol *TryBlockMapXData = nullptr;
MCSymbol *IPToStateXData = nullptr;
@@ -637,7 +650,7 @@ void WinException::emitCXXFrameHandler3Table(const MachineFunction *MF) {
OS.EmitIntValue(IPToStateTable.size(), 4); // IPMapEntries
OS.EmitValue(create32bitRef(IPToStateXData), 4); // IPToStateMap
if (Asm->MAI->usesWindowsCFI())
- OS.EmitIntValue(FuncInfo.UnwindHelpFrameOffset, 4); // UnwindHelp
+ OS.EmitIntValue(UnwindHelpOffset, 4); // UnwindHelp
OS.EmitIntValue(0, 4); // ESTypeList
OS.EmitIntValue(1, 4); // EHFlags
@@ -714,8 +727,8 @@ void WinException::emitCXXFrameHandler3Table(const MachineFunction *MF) {
FuncLinkageName, HT.CatchObjRecoverIdx);
FrameAllocOffsetRef = MCSymbolRefExpr::create(
FrameAllocOffset, MCSymbolRefExpr::VK_None, Asm->OutContext);
- } else if (HT.CatchObj.FrameOffset != INT_MAX) {
- int Offset = HT.CatchObj.FrameOffset;
+ } else if (HT.CatchObj.FrameIndex != INT_MAX) {
+ int Offset = getFrameIndexOffset(HT.CatchObj.FrameIndex);
// For 32-bit, the catch object offset is relative to the end of the
// EH registration node. For 64-bit, it's relative to SP at the end of
// the prologue.
OpenPOWER on IntegriCloud