r228769 - Emit landing pads for SEH even if nounwind is present

Reid Kleckner reid at kleckner.net
Tue Feb 10 16:00:21 PST 2015


Author: rnk
Date: Tue Feb 10 18:00:21 2015
New Revision: 228769

URL: http://llvm.org/viewvc/llvm-project?rev=228769&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/CodeGen/CGCall.cpp
    cfe/trunk/lib/CodeGen/CGException.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.h
    cfe/trunk/test/CodeGenCXX/exceptions-seh.cpp

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=228769&r1=228768&r2=228769&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Feb 10 18:00:21 2015
@@ -3304,7 +3304,8 @@ RValue CodeGenFunction::EmitCall(const C
 
   llvm::BasicBlock *InvokeDest = nullptr;
   if (!Attrs.hasAttribute(llvm::AttributeSet::FunctionIndex,
-                          llvm::Attribute::NoUnwind))
+                          llvm::Attribute::NoUnwind) ||
+      currentFunctionUsesSEHTry())
     InvokeDest = getInvokeDest();
 
   llvm::CallSite CS;

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=228769&r1=228768&r2=228769&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Tue Feb 10 18:00:21 2015
@@ -743,8 +743,7 @@ llvm::BasicBlock *CodeGenFunction::getIn
   if (!LO.Exceptions) {
     if (!LO.Borland && !LO.MicrosoftExt)
       return nullptr;
-    const auto *FD = dyn_cast_or_null<FunctionDecl>(CurCodeDecl);
-    if (!FD || !FD->usesSEHTry())
+    if (!currentFunctionUsesSEHTry())
       return nullptr;
   }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=228769&r1=228768&r2=228769&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Feb 10 18:00:21 2015
@@ -1122,6 +1122,11 @@ public:
     return getInvokeDestImpl();
   }
 
+  bool currentFunctionUsesSEHTry() const {
+    const auto *FD = dyn_cast_or_null<FunctionDecl>(CurCodeDecl);
+    return FD && FD->usesSEHTry();
+  }
+
   const TargetInfo &getTarget() const { return Target; }
   llvm::LLVMContext &getLLVMContext() { return CGM.getLLVMContext(); }
 

Modified: cfe/trunk/test/CodeGenCXX/exceptions-seh.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/exceptions-seh.cpp?rev=228769&r1=228768&r2=228769&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/exceptions-seh.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/exceptions-seh.cpp Tue Feb 10 18:00:21 2015
@@ -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();





More information about the cfe-commits mailing list