summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGCleanup.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-07-31 17:58:45 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-07-31 17:58:45 +0000
commitdbf1045ad75c41e0711e075cf9e0ffd433c55c67 (patch)
treec75cc12748d00898b082c1e1d556af59ec43ab8d /clang/lib/CodeGen/CGCleanup.cpp
parent654e130b6ec76c1a2910b2594cb403ecd2773af8 (diff)
downloadbcm5719-llvm-dbf1045ad75c41e0711e075cf9e0ffd433c55c67.tar.gz
bcm5719-llvm-dbf1045ad75c41e0711e075cf9e0ffd433c55c67.zip
[MS ABI] Hook clang up to the new EH instructions
The new EH instructions make it possible for LLVM to generate .xdata tables that the MSVC personality routines will be happy about. Because this is experimental, hide it behind a -cc1 flag (-fnew-ms-eh). Differential Revision: http://reviews.llvm.org/D11405 llvm-svn: 243767
Diffstat (limited to 'clang/lib/CodeGen/CGCleanup.cpp')
-rw-r--r--clang/lib/CodeGen/CGCleanup.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index 3d4c4850f60..ef5a98ead98 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -247,6 +247,13 @@ void EHScopeStack::pushTerminate() {
InnermostEHScope = stable_begin();
}
+void EHScopeStack::pushCatchEnd(llvm::BasicBlock *CatchEndBlockBB) {
+ char *Buffer = allocate(EHCatchEndScope::getSize());
+ auto *CES = new (Buffer) EHCatchEndScope(InnermostEHScope);
+ CES->setCachedEHDispatchBlock(CatchEndBlockBB);
+ InnermostEHScope = stable_begin();
+}
+
/// Remove any 'null' fixups on the stack. However, we can't pop more
/// fixups than the fixup depth on the innermost normal cleanup, or
/// else fixups that we try to add to that cleanup will end up in the
@@ -896,6 +903,14 @@ void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough) {
CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP();
EmitBlock(EHEntry);
+ llvm::BasicBlock *NextAction = getEHDispatchBlock(EHParent);
+ if (CGM.getCodeGenOpts().NewMSEH &&
+ EHPersonality::get(*this).isMSVCPersonality()) {
+ if (NextAction)
+ Builder.CreateCleanupPad(VoidTy, NextAction);
+ else
+ Builder.CreateCleanupPad(VoidTy, {});
+ }
// We only actually emit the cleanup code if the cleanup is either
// active or was used before it was deactivated.
@@ -905,7 +920,10 @@ void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough) {
EmitCleanup(*this, Fn, cleanupFlags, EHActiveFlag);
}
- Builder.CreateBr(getEHDispatchBlock(EHParent));
+ if (CGM.getCodeGenOpts().NewMSEH && EHPersonality::get(*this).isMSVCPersonality())
+ Builder.CreateCleanupRet(NextAction);
+ else
+ Builder.CreateBr(NextAction);
Builder.restoreIP(SavedIP);
OpenPOWER on IntegriCloud