[PATCH] Fix ICE with __RTL and -g (PR debug/82933)
Jakub Jelinek
jakub@redhat.com
Mon Nov 20 21:14:00 GMT 2017
Hi!
The dwarf2out.c code relies on the assembly_start debug hook being
invoked before any RTL is processed from final.c (and needs it to be
done just once). Normally it is called from cgraphunit.c, but when
__RTL is seen with a starting pass, run_rtl_passes is called already
from the FE. While it would be better to defer the rtl finalization
until cgraph says so, it might be quite hard, so instead this patch
hacks dwarf2out_assembly_start so that it can be invoked multiple times
(and does nothing on the 2nd+ call) and invokes it from the run_rtl_passes
function too.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2017-11-20 Jakub Jelinek <jakub@redhat.com>
PR debug/82933
* run-rtl-passes.c: Include debug.h.
(run_rtl_passes): Call debug_hooks->assembly_start.
* dwarf2out.c (dwarf2out_assembly_start): Return early if invoked
multiple times.
* gcc.dg/rtl/x86_64/pr82933.c: New test.
--- gcc/run-rtl-passes.c.jj 2017-01-24 23:29:09.000000000 +0100
+++ gcc/run-rtl-passes.c 2017-11-20 17:36:31.320854900 +0100
@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3.
#include "bitmap.h"
#include "df.h"
#include "regs.h"
+#include "debug.h" /* for debug_hooks. */
#include "insn-attr-common.h" /* for INSN_SCHEDULING. */
#include "insn-attr.h" /* for init_sched_attrs. */
#include "run-rtl-passes.h"
@@ -43,6 +44,9 @@ run_rtl_passes (char *initial_pass_name)
cfun->pass_startwith = initial_pass_name;
max_regno = max_reg_num ();
+ /* cgraphunit.c normally handles this. */
+ (*debug_hooks->assembly_start) ();
+
/* Pass "expand" normally sets this up. */
#ifdef INSN_SCHEDULING
init_sched_attrs ();
--- gcc/dwarf2out.c.jj 2017-11-15 09:38:26.000000000 +0100
+++ gcc/dwarf2out.c 2017-11-20 17:31:48.222394813 +0100
@@ -27507,6 +27507,9 @@ dwarf2out_init (const char *filename ATT
static void
dwarf2out_assembly_start (void)
{
+ if (text_section_line_info)
+ return;
+
#ifndef DWARF2_LINENO_DEBUGGING_INFO
ASM_GENERATE_INTERNAL_LABEL (text_section_label, TEXT_SECTION_LABEL, 0);
ASM_GENERATE_INTERNAL_LABEL (text_end_label, TEXT_END_LABEL, 0);
--- gcc/testsuite/gcc.dg/rtl/x86_64/pr82933.c.jj 2017-11-20 17:34:54.680063313 +0100
+++ gcc/testsuite/gcc.dg/rtl/x86_64/pr82933.c 2017-11-20 17:35:26.361667161 +0100
@@ -0,0 +1,4 @@
+/* { dg-do run { target { { i?86-*-* x86_64-*-* } && lp64 } } } */
+/* { dg-options "-g" } */
+
+#include "into-cfglayout.c"
Jakub
More information about the Gcc-patches
mailing list