From: Reid Kleckner Date: Wed, 11 Feb 2015 00:00:21 +0000 (+0000) Subject: Emit landing pads for SEH even if nounwind is present X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4e8f3d056fc68714029c61df05645fbb88f5a391;p=clang Emit landing pads for SEH even if nounwind is present Disabling exceptions applies nounwind to lots of functions. SEH catches asynch exceptions, so emit the landing pad anyway. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@228769 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index 95fad1a114..0574a1a34d 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -3304,7 +3304,8 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, llvm::BasicBlock *InvokeDest = nullptr; if (!Attrs.hasAttribute(llvm::AttributeSet::FunctionIndex, - llvm::Attribute::NoUnwind)) + llvm::Attribute::NoUnwind) || + currentFunctionUsesSEHTry()) InvokeDest = getInvokeDest(); llvm::CallSite CS; diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp index 5ddd3bbb82..a632a40e14 100644 --- a/lib/CodeGen/CGException.cpp +++ b/lib/CodeGen/CGException.cpp @@ -743,8 +743,7 @@ llvm::BasicBlock *CodeGenFunction::getInvokeDestImpl() { if (!LO.Exceptions) { if (!LO.Borland && !LO.MicrosoftExt) return nullptr; - const auto *FD = dyn_cast_or_null(CurCodeDecl); - if (!FD || !FD->usesSEHTry()) + if (!currentFunctionUsesSEHTry()) return nullptr; } diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index f6e2bae319..998e0676cd 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -1122,6 +1122,11 @@ public: return getInvokeDestImpl(); } + bool currentFunctionUsesSEHTry() const { + const auto *FD = dyn_cast_or_null(CurCodeDecl); + return FD && FD->usesSEHTry(); + } + const TargetInfo &getTarget() const { return Target; } llvm::LLVMContext &getLLVMContext() { return CGM.getLLVMContext(); } diff --git a/test/CodeGenCXX/exceptions-seh.cpp b/test/CodeGenCXX/exceptions-seh.cpp index e76f0ea5c0..38d176b829 100644 --- a/test/CodeGenCXX/exceptions-seh.cpp +++ b/test/CodeGenCXX/exceptions-seh.cpp @@ -2,7 +2,7 @@ // RUN: -o - -mconstructor-aliases -fcxx-exceptions -fexceptions | \ // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CXXEH // RUN: %clang_cc1 -std=c++11 -fblocks -fms-extensions %s -triple=x86_64-windows-msvc -emit-llvm \ -// RUN: -o - -mconstructor-aliases | \ +// RUN: -o - -mconstructor-aliases -O1 -disable-llvm-optzns | \ // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=NOCXX extern "C" void might_throw();