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

            Bug ID: 67850
           Summary: Wrong call_used_regs used in aggregate_value_p
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
                CC: julia.koval at intel dot com
  Target Milestone: ---

aggregate_value_p may be called:

#0  aggregate_value_p (exp=0x7ffff7ff9258, fntype=0x7ffff150b0a8)
    at /export/gnu/import/git/sources/gcc/gcc/function.c:2096
#1  0x0000000000e2d3ae in (anonymous namespace)::pass_nrv::execute (
    this=0x2313730, fun=0x7ffff16091f8)
    at /export/gnu/import/git/sources/gcc/gcc/tree-nrv.c:153
#2  0x0000000000c6c6ce in execute_one_pass (pass=0x2313730)
    at /export/gnu/import/git/sources/gcc/gcc/passes.c:2342
#3  0x0000000000c6c918 in execute_pass_list_1 (pass=0x2313730)
    at /export/gnu/import/git/sources/gcc/gcc/passes.c:2395
#4  0x0000000000c6c989 in execute_pass_list (fn=0x7ffff16091f8, pass=0x2310730)
    at /export/gnu/import/git/sources/gcc/gcc/passes.c:2406
#5  0x00000000008f436c in cgraph_node::expand (this=0x7ffff160c170)
    at /export/gnu/import/git/sources/gcc/gcc/cgraphunit.c:1983
#6  0x00000000008f49a6 in expand_all_functions ()
    at /export/gnu/import/git/sources/gcc/gcc/cgraphunit.c:2119
#7  0x00000000008f54bf in symbol_table::compile (this=0x7ffff14e90a8)
    at /export/gnu/import/git/sources/gcc/gcc/cgraphunit.c:2472
#8  0x00000000008f56e0 in symbol_table::finalize_compilation_unit (
    this=0x7ffff14e90a8)
    at /export/gnu/import/git/sources/gcc/gcc/cgraphunit.c:2562
#9  0x0000000000d6a287 in compile_file ()
(gdb) f 1
#1  0x0000000000e2d3ae in (anonymous namespace)::pass_nrv::execute (
    this=0x2313730, fun=0x7ffff16091f8)
    at /export/gnu/import/git/sources/gcc/gcc/tree-nrv.c:153
153       if (!aggregate_value_p (result, current_function_decl))
(gdb) 

But the wrong call_used_regs may be used here:

  regno = REGNO (reg);
  nregs = hard_regno_nregs[regno][TYPE_MODE (type)];
  for (i = 0; i < nregs; i++) 
    if (! call_used_regs[regno + i])
      return 1;

since targetm.expand_to_rtl_hook may be called to switch ABI:

(gdb) bt
#0  ix86_maybe_switch_abi ()
    at /export/gnu/import/git/sources/gcc/gcc/config/i386/i386.c:7445
#1  0x00000000008b0e6f in (anonymous namespace)::pass_expand::execute (
    this=0x2313850, fun=0x7ffff16090a8)
    at /export/gnu/import/git/sources/gcc/gcc/cfgexpand.c:6153
#2  0x0000000000c6c6ce in execute_one_pass (pass=0x2313850)
    at /export/gnu/import/git/sources/gcc/gcc/passes.c:2342
#3  0x0000000000c6c918 in execute_pass_list_1 (pass=0x2313850)
    at /export/gnu/import/git/sources/gcc/gcc/passes.c:2395
#4  0x0000000000c6c989 in execute_pass_list (fn=0x7ffff16090a8, pass=0x2310730)
    at /export/gnu/import/git/sources/gcc/gcc/passes.c:2406
#5  0x00000000008f436c in cgraph_node::expand (this=0x7ffff160c000)
    at /export/gnu/import/git/sources/gcc/gcc/cgraphunit.c:1983
#6  0x00000000008f49a6 in expand_all_functions ()
    at /export/gnu/import/git/sources/gcc/gcc/cgraphunit.c:2119
#7  0x00000000008f54bf in symbol_table::compile (this=0x7ffff14e90a8)
    at /export/gnu/import/git/sources/gcc/gcc/cgraphunit.c:2472
#8  0x00000000008f56e0 in symbol_table::finalize_compilation_unit (
    this=0x7ffff14e90a8)
    at /export/gnu/import/git/sources/gcc/gcc/cgraphunit.c:2562
#9  0x0000000000d6a287 in compile_file ()

to change call_used_regs.

Reply via email to