[PATCH] D14669: [EH] Keep filter types even if the type has been caught.

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 17 12:15:48 PST 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL253370: [EH] Keep filter clauses for types that have been caught. (authored by akaylor).

Changed prior to commit:
  http://reviews.llvm.org/D14669?vs=40330&id=40422#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14669

Files:
  llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/trunk/test/Transforms/InstCombine/LandingPadClauses.ll

Index: llvm/trunk/test/Transforms/InstCombine/LandingPadClauses.ll
===================================================================
--- llvm/trunk/test/Transforms/InstCombine/LandingPadClauses.ll
+++ llvm/trunk/test/Transforms/InstCombine/LandingPadClauses.ll
@@ -69,9 +69,11 @@
           filter [1 x i32*] [i32* @T1]
           catch i32* @T2
   unreachable
+; Caught types should not be removed from filters
 ; CHECK: %c = landingpad
-; CHECK-NEXT: @T1
-; CHECK-NEXT: filter [0 x i32*]
+; CHECK-NEXT: catch i32* @T1
+; CHECK-NEXT: filter [1 x i32*] [i32* @T1]
+; CHECK-NEXT: catch i32* @T2 
 ; CHECK-NEXT: unreachable
 
 lpad.d:
@@ -87,9 +89,10 @@
           catch i32* @T1
           filter [3 x i32*] [i32* @T1, i32* @T2, i32* @T2]
   unreachable
+; Caught types should not be removed from filters
 ; CHECK: %e = landingpad
-; CHECK-NEXT: @T1
-; CHECK-NEXT: filter [1 x i32*] [i32* @T2]
+; CHECK-NEXT: catch i32* @T1
+; CHECK-NEXT: filter [2 x i32*] [i32* @T1, i32* @T2]
 ; CHECK-NEXT: unreachable
 
 lpad.f:
Index: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
===================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -2486,10 +2486,24 @@
             SawCatchAll = true;
             break;
           }
-          if (AlreadyCaught.count(TypeInfo))
-            // Already caught by an earlier clause, so having it in the filter
-            // is pointless.
-            continue;
+
+          // Even if we've seen a type in a catch clause, we don't want to
+          // remove it from the filter.  An unexpected type handler may be
+          // set up for a call site which throws an exception of the same
+          // type caught.  In order for the exception thrown by the unexpected
+          // handler to propogate correctly, the filter must be correctly
+          // described for the call site.
+          //
+          // Example:
+          //
+          // void unexpected() { throw 1;}
+          // void foo() throw (int) {
+          //   std::set_unexpected(unexpected);
+          //   try {
+          //     throw 2.0;
+          //   } catch (int i) {}
+          // }
+
           // There is no point in having multiple copies of the same typeinfo in
           // a filter, so only add it if we didn't already.
           if (SeenInFilter.insert(TypeInfo).second)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14669.40422.patch
Type: text/x-patch
Size: 2468 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151117/02a03c84/attachment.bin>


More information about the llvm-commits mailing list