Re: [PATCH] Do not merge BBs with a different EH landing pads (PR, tree-optimization/77943)

2016-10-14 Thread Richard Biener
On Fri, Oct 14, 2016 at 1:12 PM, Martin Liška  wrote:
> On 10/13/2016 11:39 AM, Richard Biener wrote:
>> Yes, as said, the patch is ok as-is.
>>
>> Richard.
>
> Installed, I've just tested the patch on 5 and 6 branch.
> May I install it as well?

Yes please.

Ricahrd.

> M.


Re: [PATCH] Do not merge BBs with a different EH landing pads (PR, tree-optimization/77943)

2016-10-14 Thread Martin Liška
On 10/13/2016 11:39 AM, Richard Biener wrote:
> Yes, as said, the patch is ok as-is.
> 
> Richard.

Installed, I've just tested the patch on 5 and 6 branch.
May I install it as well?

M.


Re: [PATCH] Do not merge BBs with a different EH landing pads (PR, tree-optimization/77943)

2016-10-13 Thread Richard Biener
On Thu, Oct 13, 2016 at 11:15 AM, Martin Liška  wrote:
> On 10/13/2016 10:46 AM, Richard Biener wrote:
>> On Thu, Oct 13, 2016 at 9:40 AM, Martin Liška  wrote:
>>> Hi.
>>>
>>> Following patch adds code that is already present in IPA ICF.
>>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>>>
>>> Ready to be installed?
>>
>> Ok, though technically this is conservative and we could still merge if
>> the blocks associated with the landing pads are merged as well?
>
> Agree with you, however as find_duplicates operates BB by BB, it would require
> introduction of some kind of dependencies (e.g. you can merge BB1 with BB2, if
> BBx would be merged with BBy). I can write it on my TODO list after we'll
> transform tail-merge to IPA ICF infrastructure.
>
> Does it work for you?

Yes, as said, the patch is ok as-is.

Richard.

> Martin
>
>>
>> Thanks,
>> Richard.
>>
>>> Martin
>


Re: [PATCH] Do not merge BBs with a different EH landing pads (PR, tree-optimization/77943)

2016-10-13 Thread Martin Liška
On 10/13/2016 10:46 AM, Richard Biener wrote:
> On Thu, Oct 13, 2016 at 9:40 AM, Martin Liška  wrote:
>> Hi.
>>
>> Following patch adds code that is already present in IPA ICF.
>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>>
>> Ready to be installed?
> 
> Ok, though technically this is conservative and we could still merge if
> the blocks associated with the landing pads are merged as well?

Agree with you, however as find_duplicates operates BB by BB, it would require
introduction of some kind of dependencies (e.g. you can merge BB1 with BB2, if
BBx would be merged with BBy). I can write it on my TODO list after we'll
transform tail-merge to IPA ICF infrastructure.

Does it work for you?
Martin

> 
> Thanks,
> Richard.
> 
>> Martin



Re: [PATCH] Do not merge BBs with a different EH landing pads (PR, tree-optimization/77943)

2016-10-13 Thread Richard Biener
On Thu, Oct 13, 2016 at 9:40 AM, Martin Liška  wrote:
> Hi.
>
> Following patch adds code that is already present in IPA ICF.
> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>
> Ready to be installed?

Ok, though technically this is conservative and we could still merge if
the blocks associated with the landing pads are merged as well?

Thanks,
Richard.

> Martin


[PATCH] Do not merge BBs with a different EH landing pads (PR, tree-optimization/77943)

2016-10-13 Thread Martin Liška
Hi.

Following patch adds code that is already present in IPA ICF.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

Ready to be installed?
Martin
>From 542c318af84ca561661b42baca3da7c340971dd8 Mon Sep 17 00:00:00 2001
From: marxin <mli...@suse.cz>
Date: Wed, 12 Oct 2016 16:38:31 +0200
Subject: [PATCH] Do not merge BBs with a different EH landing pads (PR
 tree-optimization/77943)

gcc/testsuite/ChangeLog:

2016-10-12  Martin Liska  <mli...@suse.cz>

	PR tree-optimization/77943
	* g++.dg/tree-ssa/pr77943.C: New test.

gcc/ChangeLog:

2016-10-12  Martin Liska  <mli...@suse.cz>

	PR tree-optimization/77943
	* tree-ssa-tail-merge.c (merge_stmts_p): Do not merge BBs with
	a different EH landing pads.
---
 gcc/testsuite/g++.dg/tree-ssa/pr77943.C | 25 +
 gcc/tree-ssa-tail-merge.c   |  5 +
 2 files changed, 30 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr77943.C

diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr77943.C b/gcc/testsuite/g++.dg/tree-ssa/pr77943.C
new file mode 100644
index 000..ef7954a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr77943.C
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -std=c++11" } */
+
+void thrower[[gnu::noinline]]() {
+throw 1;
+}
+
+inline void fatal() noexcept {thrower();}
+inline void notFatal() {thrower();}
+
+void func(bool callFatal) {
+if (callFatal) {
+fatal();
+} else { 
+notFatal();
+}
+}
+
+int main(int argc, const char* argv[]) {
+try {
+bool callFatal = argc > 1;
+func(callFatal);
+} catch (...) {
+}
+}
diff --git a/gcc/tree-ssa-tail-merge.c b/gcc/tree-ssa-tail-merge.c
index 5e815ec..c292ee7 100644
--- a/gcc/tree-ssa-tail-merge.c
+++ b/gcc/tree-ssa-tail-merge.c
@@ -204,6 +204,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "params.h"
 #include "tree-ssa-sccvn.h"
 #include "cfgloop.h"
+#include "tree-eh.h"
 
 /* Describes a group of bbs with the same successors.  The successor bbs are
cached in succs, and the successor edge flags are cached in succ_flags.
@@ -1222,6 +1223,10 @@ merge_stmts_p (gimple *stmt1, gimple *stmt2)
   if (is_tm_ending (stmt1))
 return false;
 
+  /* Verify EH landing pads.  */
+  if (lookup_stmt_eh_lp_fn (cfun, stmt1) != lookup_stmt_eh_lp_fn (cfun, stmt2))
+return false;
+
   if (is_gimple_call (stmt1)
   && gimple_call_internal_p (stmt1))
 switch (gimple_call_internal_fn (stmt1))
-- 
2.9.2