The following deals with (note/s 5 0 0 ("lab") NOTE_INSN_DELETED_LABEL 2) appearing in DECL_RTL of LABEL_DECLs which expand_debug_expr doesn't expect. copy_rtx cannot deal with any notes so the following simply treats NOTE_P DECL_RTL as if it was optimized away.
Bootstrap / regtest running on x86_64-unknown-linux-gnu. Richard. 2019-06-18 Richard Biener <rguent...@suse.de> PR debug/90900 * cfgexpand.c (expand_debug_expr): Treat NOTE_P DECL_RTL as if optimized away. * gcc.dg/gomp/pr90900.c: New testcase. Index: gcc/cfgexpand.c =================================================================== --- gcc/cfgexpand.c (revision 272405) +++ gcc/cfgexpand.c (working copy) @@ -4387,7 +4387,11 @@ expand_debug_expr (tree exp) op0 = DECL_RTL_IF_SET (exp); /* This decl was probably optimized away. */ - if (!op0) + if (!op0 + /* At least label RTXen are sometimes replaced by + NOTE_INSN_DELETED_LABEL. Any notes here are not + handled by copy_rtx. */ + || NOTE_P (op0)) { if (!VAR_P (exp) || DECL_EXTERNAL (exp) Index: gcc/testsuite/gcc.dg/gomp/pr90900.c =================================================================== --- gcc/testsuite/gcc.dg/gomp/pr90900.c (nonexistent) +++ gcc/testsuite/gcc.dg/gomp/pr90900.c (working copy) @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fopenmp -g" } */ + +void f (int a) +{ + void *x = &&lab; +#pragma omp parallel + if (a) + { lab: __builtin_unreachable(); } + x; +}