public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/97347] New: [11 Regression] error: statement marked for throw in middle of block in botan
@ 2020-10-09  8:01 marxin at gcc dot gnu.org
  2020-10-09  8:01 ` [Bug tree-optimization/97347] " marxin at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-10-09  8:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97347

            Bug ID: 97347
           Summary: [11 Regression] error: statement marked for throw in
                    middle of block in botan
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
                CC: rguenth at gcc dot gnu.org
  Target Milestone: ---

The following fails:

$ cat botan.ii
inline namespace __cxx11 {}
typedef int size_t;
class MessageAuthenticationCode;
class __uniq_ptr_impl {
  struct _Ptr {
    using type = MessageAuthenticationCode *;
  };
public:
  using pointer = _Ptr::type;
};
class unique_ptr {
public:
  using pointer = __uniq_ptr_impl::pointer;
  unique_ptr(pointer);
};
namespace __cxx11 {
class basic_string {
public:
  basic_string(char *);
  ~basic_string();
};
} // namespace __cxx11
class MessageAuthenticationCode {};
class SCAN_Name {
public:
  SCAN_Name(basic_string);
  size_t arg_as_integer();
};
class SipHash : public MessageAuthenticationCode {
public:
  SipHash(size_t c, size_t d) : m_C(c), m_D(d) {}
  size_t m_C, m_D;
};
void create(basic_string algo_spec) {
  basic_string provider = "";
  SCAN_Name req(algo_spec);
  unique_ptr(new SipHash(req.arg_as_integer(), req.arg_as_integer()));
}

$ g++ -O3 botan.ii -c -fdump-tree-all
botan.ii: In function ‘void create(__cxx11::basic_string)’:
botan.ii:35:27: warning: ISO C++ forbids converting a string constant to
‘char*’ [-Wwrite-strings]
   35 |   basic_string provider = "";
      |                           ^~
botan.ii:34:6: error: statement marked for throw in middle of block
   34 | void create(basic_string algo_spec) {
      |      ^~~~~~
# .MEM_11 = VDEF <.MEM_9>
_12 = operator new (8);
during GIMPLE pass: slp
dump file: botan.ii.175t.slp2
botan.ii:34:6: internal compiler error: verify_gimple failed
0x1057d5a verify_gimple_in_cfg(function*, bool)
        /home/marxin/Programming/gcc/gcc/tree-cfg.c:5482
0xf3d36f execute_function_todo
        /home/marxin/Programming/gcc/gcc/passes.c:1992
0xf3e1bc do_per_function
        /home/marxin/Programming/gcc/gcc/passes.c:1640
0xf3e1bc execute_todo
        /home/marxin/Programming/gcc/gcc/passes.c:2046
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

The insertion code mentions statements that can throw but does not handle it.

Patch candidate:

diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 7e22506b49f..84bc8970f33 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -4148,13 +4148,22 @@ vect_create_constant_vectors (vec_info *vinfo, slp_tree
op_node)
                        gsi = gsi_for_stmt (insert_after->stmt);
                      else
                        {
-                         /* When we want to insert after a def where the
-                            defining stmt throws then insert on the fallthru
-                            edge.  */
                          edge e = find_fallthru_edge
                                     (gimple_bb (insert_after->stmt)->succs);
                          gcc_assert (single_pred_p (e->dest));
                          gsi = gsi_after_labels (e->dest);
+
+                         /* When we want to insert after a def where the
+                            defining stmt throws then insert on the fallthru
+                            edge.  */
+                         while (!gsi_end_p (gsi)
+                                && stmt_can_throw_internal (cfun, gsi_stmt
(gsi)))
+                           {
+                             e = find_fallthru_edge (e->dest->succs);
+                             gcc_assert (single_pred_p (e->dest));
+                             gsi = gsi_after_labels (e->dest);
+                           }
+
                        }
                      gsi_insert_seq_after (&gsi, ctor_seq,
                                            GSI_CONTINUE_LINKING);

What do you think Richi about the patch?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/97347] [11 Regression] error: statement marked for throw in middle of block in botan
  2020-10-09  8:01 [Bug tree-optimization/97347] New: [11 Regression] error: statement marked for throw in middle of block in botan marxin at gcc dot gnu.org
@ 2020-10-09  8:01 ` marxin at gcc dot gnu.org
  2020-10-09  8:08 ` marxin at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-10-09  8:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97347

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Target Milestone|---                         |11.0
             Status|UNCONFIRMED                 |NEW
           Priority|P3                          |P1
   Last reconfirmed|                            |2020-10-09

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/97347] [11 Regression] error: statement marked for throw in middle of block in botan
  2020-10-09  8:01 [Bug tree-optimization/97347] New: [11 Regression] error: statement marked for throw in middle of block in botan marxin at gcc dot gnu.org
  2020-10-09  8:01 ` [Bug tree-optimization/97347] " marxin at gcc dot gnu.org
@ 2020-10-09  8:08 ` marxin at gcc dot gnu.org
  2020-10-09  8:13 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-10-09  8:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97347

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |marxin at gcc dot gnu.org

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/97347] [11 Regression] error: statement marked for throw in middle of block in botan
  2020-10-09  8:01 [Bug tree-optimization/97347] New: [11 Regression] error: statement marked for throw in middle of block in botan marxin at gcc dot gnu.org
  2020-10-09  8:01 ` [Bug tree-optimization/97347] " marxin at gcc dot gnu.org
  2020-10-09  8:08 ` marxin at gcc dot gnu.org
@ 2020-10-09  8:13 ` rguenth at gcc dot gnu.org
  2020-10-09  8:57 ` marxin at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-10-09  8:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97347

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|10.0                        |11.0
           Assignee|marxin at gcc dot gnu.org          |rguenth at gcc dot gnu.org

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Since we're really want to insert on the edge and merely assert that will be
possible we should instead do

                      else
                        {
                          /* When we want to insert after a def where the
                             defining stmt throws then insert on the fallthru
                             edge.  */
                          edge e = find_fallthru_edge
                                     (gimple_bb (insert_after->stmt)->succs);
                          basic_block new_bb
                            = gsi_insert_seq_on_edge_immediate (e, ctor_seq);
                          gcc_assert (!new_bb);
                        }

possibly even allowing a new BB to be created (though our region collection
restrictions should not make this necessary).  Let me take this.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/97347] [11 Regression] error: statement marked for throw in middle of block in botan
  2020-10-09  8:01 [Bug tree-optimization/97347] New: [11 Regression] error: statement marked for throw in middle of block in botan marxin at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-10-09  8:13 ` rguenth at gcc dot gnu.org
@ 2020-10-09  8:57 ` marxin at gcc dot gnu.org
  2020-10-09  9:16 ` dcb314 at hotmail dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-10-09  8:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97347

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |26163

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Just for the record, one can see the same error in 520.omnetpp_r.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26163
[Bug 26163] [meta-bug] missed optimization in SPEC (2k17, 2k and 2k6 and 95)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/97347] [11 Regression] error: statement marked for throw in middle of block in botan
  2020-10-09  8:01 [Bug tree-optimization/97347] New: [11 Regression] error: statement marked for throw in middle of block in botan marxin at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2020-10-09  8:57 ` marxin at gcc dot gnu.org
@ 2020-10-09  9:16 ` dcb314 at hotmail dot com
  2020-10-09  9:28 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dcb314 at hotmail dot com @ 2020-10-09  9:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97347

David Binderman <dcb314 at hotmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dcb314 at hotmail dot com

--- Comment #3 from David Binderman <dcb314 at hotmail dot com> ---
I am seeing the same problem in a large piece of C++ from the tesseract
package.

I will reduce the code and report back.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/97347] [11 Regression] error: statement marked for throw in middle of block in botan
  2020-10-09  8:01 [Bug tree-optimization/97347] New: [11 Regression] error: statement marked for throw in middle of block in botan marxin at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2020-10-09  9:16 ` dcb314 at hotmail dot com
@ 2020-10-09  9:28 ` cvs-commit at gcc dot gnu.org
  2020-10-09  9:28 ` rguenth at gcc dot gnu.org
  2020-10-12 11:13 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-10-09  9:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97347

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:5d708c6315e0fc57992cda7b466a5a9877ced4e3

commit r11-3747-g5d708c6315e0fc57992cda7b466a5a9877ced4e3
Author: Richard Biener <rguenther@suse.de>
Date:   Fri Oct 9 10:19:38 2020 +0200

    tree-optimization/97347 - fix another SLP constant insertion issue

    Just use edge insertion which will appropriately handle the situation
    from botan.

    2020-10-09  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/97347
            * tree-vect-slp.c (vect_create_constant_vectors): Use
            edge insertion when inserting on the fallthru edge,
            appropriately insert at the start of BBs when inserting
            after PHIs.

            * g++.dg/vect/pr97347.cc: New testcase.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/97347] [11 Regression] error: statement marked for throw in middle of block in botan
  2020-10-09  8:01 [Bug tree-optimization/97347] New: [11 Regression] error: statement marked for throw in middle of block in botan marxin at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2020-10-09  9:28 ` cvs-commit at gcc dot gnu.org
@ 2020-10-09  9:28 ` rguenth at gcc dot gnu.org
  2020-10-12 11:13 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-10-09  9:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97347

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/97347] [11 Regression] error: statement marked for throw in middle of block in botan
  2020-10-09  8:01 [Bug tree-optimization/97347] New: [11 Regression] error: statement marked for throw in middle of block in botan marxin at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2020-10-09  9:28 ` rguenth at gcc dot gnu.org
@ 2020-10-12 11:13 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-10-12 11:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97347

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
*** Bug 97354 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-10-12 11:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-09  8:01 [Bug tree-optimization/97347] New: [11 Regression] error: statement marked for throw in middle of block in botan marxin at gcc dot gnu.org
2020-10-09  8:01 ` [Bug tree-optimization/97347] " marxin at gcc dot gnu.org
2020-10-09  8:08 ` marxin at gcc dot gnu.org
2020-10-09  8:13 ` rguenth at gcc dot gnu.org
2020-10-09  8:57 ` marxin at gcc dot gnu.org
2020-10-09  9:16 ` dcb314 at hotmail dot com
2020-10-09  9:28 ` cvs-commit at gcc dot gnu.org
2020-10-09  9:28 ` rguenth at gcc dot gnu.org
2020-10-12 11:13 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).