summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorAndrew Kaylor <andrew.kaylor@intel.com>2015-11-17 20:13:04 +0000
committerAndrew Kaylor <andrew.kaylor@intel.com>2015-11-17 20:13:04 +0000
commitde642cef2c9e18a7943613809b085789e16fa562 (patch)
tree4a9dafab84cb14ede139ee836d454f03cd13cce8 /llvm/lib
parent36b8626b0067a0ee2893377a0caccd50fc6dd741 (diff)
downloadbcm5719-llvm-de642cef2c9e18a7943613809b085789e16fa562.tar.gz
bcm5719-llvm-de642cef2c9e18a7943613809b085789e16fa562.zip
[EH] Keep filter clauses for types that have been caught.
The instruction combiner previously removed types from filter clauses in Landing Pad instructions if the type had previously been seen in a catch clause. This is incorrect and prevents unexpected exception handlers from rethrowing the caught type. Differential Revision: http://reviews.llvm.org/D14669 llvm-svn: 253370
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstructionCombining.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 3ae7f08238b..dbc963a2b35 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -2486,10 +2486,24 @@ Instruction *InstCombiner::visitLandingPadInst(LandingPadInst &LI) {
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)
OpenPOWER on IntegriCloud