r233787 - [MS ABI] Disregard restrictive exception specifications

David Majnemer david.majnemer at gmail.com
Tue Mar 31 21:45:52 PDT 2015


Author: majnemer
Date: Tue Mar 31 23:45:52 2015
New Revision: 233787

URL: http://llvm.org/viewvc/llvm-project?rev=233787&view=rev
Log:
[MS ABI] Disregard restrictive exception specifications

MSVC treats all non-empty exception specifications the same way: all
exceptions are permitted.  The .xdata tables provide a way to
efficiently lower exception specifications *but* this probably has to be
implemented as a catch-all/rethrow mechanism instead of the Itanium way.

This fixes PR23092.

Modified:
    cfe/trunk/lib/CodeGen/CGException.cpp
    cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-catch.cpp

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=233787&r1=233786&r2=233787&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Tue Mar 31 23:45:52 2015
@@ -458,6 +458,10 @@ void CodeGenFunction::EmitStartEHSpec(co
       EHStack.pushTerminate();
     }
   } else if (EST == EST_Dynamic || EST == EST_DynamicNone) {
+    // TODO: Revisit exception specifications for the MS ABI.  There is a way to
+    // encode these in an object file but MSVC doesn't do anything with it.
+    if (getTarget().getCXXABI().isMicrosoft())
+      return;
     unsigned NumExceptions = Proto->getNumExceptions();
     EHFilterScope *Filter = EHStack.pushFilter(NumExceptions);
 
@@ -532,6 +536,10 @@ void CodeGenFunction::EmitEndEHSpec(cons
       EHStack.popTerminate();
     }
   } else if (EST == EST_Dynamic || EST == EST_DynamicNone) {
+    // TODO: Revisit exception specifications for the MS ABI.  There is a way to
+    // encode these in an object file but MSVC doesn't do anything with it.
+    if (getTarget().getCXXABI().isMicrosoft())
+      return;
     EHFilterScope &filterScope = cast<EHFilterScope>(*EHStack.begin());
     emitFilterDispatchBlock(*this, filterScope);
     EHStack.popFilter();

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-catch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-catch.cpp?rev=233787&r1=233786&r2=233787&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-catch.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-catch.cpp Tue Mar 31 23:45:52 2015
@@ -96,3 +96,11 @@ extern "C" void catch_a_ref() {
 // WIN64: %[[eptr_i8:[^ ]*]] = bitcast %struct.A* %[[eptr]] to i8*
 // WIN64: call void @handle_exception(i8* %[[eptr_i8]])
 // WIN64: call void @llvm.eh.endcatch()
+
+extern "C" void fn_with_exc_spec() throw(int) {
+  might_throw();
+}
+
+// WIN64-LABEL: define void @fn_with_exc_spec()
+// WIN64: call void @might_throw()
+// WIN64-NEXT: ret void





More information about the cfe-commits mailing list