gimple-fold: Fix ICE in maybe_canonicalize_mem_ref_addr on debug stmt [PR96354]
authorJakub Jelinek <jakub@redhat.com>
Tue, 4 Aug 2020 09:31:44 +0000 (11:31 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 4 Aug 2020 09:31:44 +0000 (11:31 +0200)
commitfabe0ede9db9fa95832b2329d3d6156711905e20
treeb59578cbcce2710686dd48ab104a570cd247d2f8
parentd79d9445d69a20a0e0361fb47584bbb8f5c6e84b
gimple-fold: Fix ICE in maybe_canonicalize_mem_ref_addr on debug stmt [PR96354]

In debug stmts, we are less strict about what is and what is not accepted
there, so this patch just punts on optimization of a debug stmt rather than
ICEing.

2020-08-04  Jakub Jelinek  <jakub@redhat.com>

PR debug/96354
* gimple-fold.c (maybe_canonicalize_mem_ref_addr): Add IS_DEBUG
argument.  Return false instead of gcc_unreachable if it is true and
get_addr_base_and_unit_offset returns NULL.
(fold_stmt_1) <case GIMPLE_DEBUG>: Adjust caller.

* g++.dg/opt/pr96354.C: New test.
gcc/gimple-fold.c
gcc/testsuite/g++.dg/opt/pr96354.C [new file with mode: 0644]