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

--- Comment #8 from rguenther at suse dot de <rguenther at suse dot de> ---
On Mon, 17 Feb 2020, marxin at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93583
> 
> --- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
> (In reply to Segher Boessenkool from comment #4)
> > The line where things crash is
> >           rtx temp = gen_reg_rtx (GET_MODE (valreg));
> > but presumably valreg is just 0 here?
> 
> Yes:
> 
> (gdb) p valreg
> $1 = (rtx_def *) 0x0
> 
> (gdb) p debug_gimple_stmt(stmt)
> # .MEM_49 = VDEF <_45>
> describe_cache.constprop.isra (l1_sizekb_36, l1_line_37);

So from the context of the crash kind-of an obvious fix would be

diff --git a/gcc/calls.c b/gcc/calls.c
index d1c53171176..b5ccfaced37 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -4667,7 +4667,7 @@ expand_call (tree exp, rtx target, int ignore)
          valreg = gen_rtx_REG (TYPE_MODE (rettype), REGNO (valreg));
        }

-      if (pass && (flags & ECF_MALLOC))
+      if (pass && (flags & ECF_MALLOC) && valreg)
        {
          rtx temp = gen_reg_rtx (GET_MODE (valreg));
          rtx_insn *last, *insns;

since there is no use of the return value so any fumbling with
it for ECF_MALLOC is pointless.  Correspoinding code
handling ERF_RETURNS_ARG checks for a NULL valreg already.

> One can debug that on gcc112 compile farm machine:
> 
> $ /home/marxin/Programming/gcc/objdir/./prev-gcc/lto1 /tmp/ice.ltrans1.o
> -fltrans -quiet
> during RTL pass: expand
> ../../gcc/config/rs6000/driver-rs6000.c: In function ‘host_detect_local_cpu’:
> ../../gcc/config/rs6000/driver-rs6000.c:338:25: internal compiler error:
> Segmentation fault
>   338 |   return describe_cache (l1_sizekb, l1_line, l1_assoc, l2_sizekb);
>       |                         ^
> 0x109138f3 crash_signal
>         ../../gcc/toplev.c:328
> 0x102468b0 expand_call(tree_node*, rtx_def*, int)
>         ../../gcc/calls.c:4672
> 0x1040d527 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
> expand_modifier, rtx_def**, bool)
>         ../../gcc/expr.c:11130
> 0x10260097 expand_expr
>         ../../gcc/expr.h:282
> 0x10260097 expand_call_stmt
>         ../../gcc/cfgexpand.c:2703
> 0x10260097 expand_gimple_stmt_1
>         ../../gcc/cfgexpand.c:3682
> 0x10260097 expand_gimple_stmt
>         ../../gcc/cfgexpand.c:3847
> 0x102673d3 expand_gimple_basic_block
>         ../../gcc/cfgexpand.c:5887
> 0x10269f07 execute
>         ../../gcc/cfgexpand.c:6542
> 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.
> 
>

Reply via email to