This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch, installed] do not crash with -fdump-tree-all-all if cfun->cfg is null
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: 19 Apr 2005 01:33:28 -0300
- Subject: Re: [patch, installed] do not crash with -fdump-tree-all-all if cfun->cfg is null
- Organization: Red Hat Global Engineering Services Compiler Team
- References: <or8y3gt3za.fsf@livre.redhat.lsd.ic.unicamp.br>
On Apr 18, 2005, Alexandre Oliva <aoliva@redhat.com> wrote:
> basic_block_info is now a macro that dereferences cfun->cfg, so make
> sure we don't evaluate basic_block_info if cfun->cfg is NULL.
After checking the patch in, it occurred to me that we're probably not
entitled to assume that cfun refers to the fn passed as argument,
although AFAICT this is the case for all calls to
dump_function_to_file from within GCC. Calls from the debugger
needn't be so though...
Fixed with the patch below. Tested on amd64-linux-gnu, checking in as
obvious.
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* tree-cfg.c (dump_function_to_file): Use cfun info only if it
refers to the function being dumped.
Index: gcc/tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.174
diff -u -p -r2.174 tree-cfg.c
--- gcc/tree-cfg.c 18 Apr 2005 17:04:06 -0000 2.174
+++ gcc/tree-cfg.c 19 Apr 2005 04:31:05 -0000
@@ -5167,7 +5167,7 @@ dump_function_to_file (tree fn, FILE *fi
/* When GIMPLE is lowered, the variables are no longer available in
BIND_EXPRs, so display them separately. */
- if (cfun && cfun->unexpanded_var_list)
+ if (cfun && cfun->decl == fn && cfun->unexpanded_var_list)
{
ignore_topmost_bind = true;
@@ -5183,7 +5183,7 @@ dump_function_to_file (tree fn, FILE *fi
}
}
- if (cfun && cfun->cfg && basic_block_info)
+ if (cfun && cfun->decl == fn && cfun->cfg && basic_block_info)
{
/* Make a CFG based dump. */
check_bb_profile (ENTRY_BLOCK_PTR, file);
--
Alexandre Oliva http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}