]> granicus.if.org Git - clang/commitdiff
Emit landing pads for SEH even if nounwind is present
authorReid Kleckner <reid@kleckner.net>
Wed, 11 Feb 2015 00:00:21 +0000 (00:00 +0000)
committerReid Kleckner <reid@kleckner.net>
Wed, 11 Feb 2015 00:00:21 +0000 (00:00 +0000)
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

lib/CodeGen/CGCall.cpp
lib/CodeGen/CGException.cpp
lib/CodeGen/CodeGenFunction.h
test/CodeGenCXX/exceptions-seh.cpp

index 95fad1a11430b668dd83d286bffd33e876a468a4..0574a1a34dcac6ebdfc85425eae694fbb61fe245 100644 (file)
@@ -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;
index 5ddd3bbb82b84bf2324731c8c37c2aca2d934f3b..a632a40e14ad1933236b68333ab948f7d80ce561 100644 (file)
@@ -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<FunctionDecl>(CurCodeDecl);
-    if (!FD || !FD->usesSEHTry())
+    if (!currentFunctionUsesSEHTry())
       return nullptr;
   }
 
index f6e2bae3195ae0ced345eb292e800b54835a0948..998e0676cd27154f4446e3fb42a1ef5e21896645 100644 (file)
@@ -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(); }
 
index e76f0ea5c07537af55c218931c0d7081f3b9ad3e..38d176b829ff8b0f84c72f48a489d22f9c954d05 100644 (file)
@@ -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();