Don't merge block suffixes if catch handlers are different.
PeepholeOptimizer::shareIdenticalBlockSuffix() should only merge
identical basic block suffixes if the blocks have same catch handlers.
BUG=
Change-Id: I8be4c521ce57dc26dceae56ab1f0db4dc0998148
diff --git a/src/test/examples/nestedtrycatches/NestedTryCatches.java b/src/test/examples/nestedtrycatches/NestedTryCatches.java
new file mode 100644
index 0000000..00bec2a
--- /dev/null
+++ b/src/test/examples/nestedtrycatches/NestedTryCatches.java
@@ -0,0 +1,38 @@
+// Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+package nestedtrycatches;
+
+public class NestedTryCatches {
+ private static void throwException() {
+ throw new RuntimeException("IGNORED");
+ }
+
+ private static void test() throws Throwable {
+ RuntimeException _primaryExc = null;
+ try {
+ throw new RuntimeException("PRIMARY");
+ } catch (RuntimeException _t) {
+ _primaryExc = _t;
+ throw _t;
+ } finally {
+ // Keep the two calls to throwException() the same line
+ if(_primaryExc!=null) {
+ try {
+ throwException();
+ } catch(Throwable _suppressed) {
+ }
+ } else {
+ throwException();
+ }
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ try {
+ test();
+ } catch (Throwable e) {
+ System.out.println("EXCEPTION: " + e.getMessage());
+ }
+ }
+}