summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2015-04-07 19:46:38 +0000
committerReid Kleckner <reid@kleckner.net>2015-04-07 19:46:38 +0000
commitf1853c65d99e72c212a8ca048e609876168cb0ff (patch)
treedeb587b0e4064e320e57a3c30a1f093d24d422fa /llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp
parent39e20aa9c20766cbce0b74d6f12f4d4f5b2d937d (diff)
downloadbcm5719-llvm-f1853c65d99e72c212a8ca048e609876168cb0ff.tar.gz
bcm5719-llvm-f1853c65d99e72c212a8ca048e609876168cb0ff.zip
[WinEH] Fix xdata generation when no catch object is present
The lack of a catch object is indicated by a frame escape index of -1. Fixes PR23137. llvm-svn: 234346
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp b/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp
index 3bfcaa96593..a685d2e23d5 100644
--- a/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp
@@ -455,12 +455,20 @@ void Win64Exception::emitCXXFrameHandler3Table(const MachineFunction *MF) {
const MCSymbolRefExpr *ParentFrameOffsetRef = MCSymbolRefExpr::Create(
ParentFrameOffset, MCSymbolRefExpr::VK_None, Asm->OutContext);
- MCSymbol *FrameAllocOffset =
- Asm->OutContext.getOrCreateFrameAllocSymbol(
- GlobalValue::getRealLinkageName(F->getName()),
- HT.CatchObjRecoverIdx);
- const MCSymbolRefExpr *FrameAllocOffsetRef = MCSymbolRefExpr::Create(
- FrameAllocOffset, MCSymbolRefExpr::VK_None, Asm->OutContext);
+ // Get the frame escape label with the offset of the catch object. If
+ // the index is -1, then there is no catch object, and we should emit an
+ // offset of zero, indicating that no copy will occur.
+ const MCExpr *FrameAllocOffsetRef = nullptr;
+ if (HT.CatchObjRecoverIdx >= 0) {
+ MCSymbol *FrameAllocOffset =
+ Asm->OutContext.getOrCreateFrameAllocSymbol(
+ GlobalValue::getRealLinkageName(F->getName()),
+ HT.CatchObjRecoverIdx);
+ FrameAllocOffsetRef = MCSymbolRefExpr::Create(
+ FrameAllocOffset, MCSymbolRefExpr::VK_None, Asm->OutContext);
+ } else {
+ FrameAllocOffsetRef = MCConstantExpr::Create(0, Asm->OutContext);
+ }
OS.EmitIntValue(HT.Adjectives, 4); // Adjectives
OS.EmitValue(createImageRel32(HT.TypeDescriptor), 4); // Type
OpenPOWER on IntegriCloud