summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGException.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2015-01-22 02:25:56 +0000
committerReid Kleckner <reid@kleckner.net>2015-01-22 02:25:56 +0000
commit2a2e1563182c4ded9bb8baeb377a85bc84849549 (patch)
treefd84b89ee53f12b730cdac52b193f9d955255618 /clang/lib/CodeGen/CGException.cpp
parentf1f4bc217627a6593246f837bb1bcbef3cc92ad6 (diff)
downloadbcm5719-llvm-2a2e1563182c4ded9bb8baeb377a85bc84849549.tar.gz
bcm5719-llvm-2a2e1563182c4ded9bb8baeb377a85bc84849549.zip
SEH: Emit the constant filter 1 as a catch-all
Minor optimization of code like __try { ... } __except(1) { ... }. llvm-svn: 226766
Diffstat (limited to 'clang/lib/CodeGen/CGException.cpp')
-rw-r--r--clang/lib/CodeGen/CGException.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp
index 94cfca962d1..68764e92606 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -1839,6 +1839,18 @@ void CodeGenFunction::EnterSEHTryStmt(const SEHTryStmt &S) {
SEHExceptStmt *Except = S.getExceptHandler();
assert(Except);
EHCatchScope *CatchScope = EHStack.pushCatch(1);
+
+ // If the filter is known to evaluate to 1, then we can use the clause "catch
+ // i8* null".
+ llvm::Constant *C =
+ CGM.EmitConstantExpr(Except->getFilterExpr(), getContext().IntTy, this);
+ if (C && C->isOneValue()) {
+ CatchScope->setCatchAllHandler(0, createBasicBlock("__except"));
+ return;
+ }
+
+ // In general, we have to emit an outlined filter function. Use the function
+ // in place of the RTTI typeinfo global that C++ EH uses.
CodeGenFunction FilterCGF(CGM, /*suppressNewContext=*/true);
llvm::Function *FilterFunc =
FilterCGF.GenerateSEHFilterFunction(*this, *Except);
OpenPOWER on IntegriCloud