haifa memory abuse
Richard Henderson
rth@redhat.com
Wed Nov 22 11:30:00 GMT 2000
Consider a function such as
void foo()
{
bar(1);
bar(2);
...
bar(6000);
}
At present, such a function will take about 1GB to compile.
This is due to haifa creating _exceedingly_ long dependancy
chains for the call_insns.
The problem was that we never zapped the reg_last_uses and
reg_last_sets lists, which meant that each call_insn depended
on every instruction before it. Yikes.
This patch, bootstrapped on i686 and alphaev6, reduces peak
memory usage for the aforementioned function to 12MB.
r~
* haifa-sched.c (sched_analyze_1): Don't special-case calls
for clobbering registers.
(sched_analyze_2): Likewise.
(sched_analyze): Zap reg_last_uses and reg_last_sets after calls.
Index: haifa-sched.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/haifa-sched.c,v
retrieving revision 1.163
diff -c -p -d -r1.163 haifa-sched.c
*** haifa-sched.c 2000/11/14 09:58:40 1.163
--- haifa-sched.c 2000/11/22 19:18:44
*************** sched_analyze_1 (deps, x, insn)
*** 3384,3394 ****
}
else
SET_REGNO_REG_SET (reg_pending_clobbers, r);
-
- /* Function calls clobber all call_used regs. */
- if (global_regs[r] || (code == SET && call_used_regs[r]))
- for (u = deps->last_function_call; u; u = XEXP (u, 1))
- add_dependence (insn, XEXP (u, 0), REG_DEP_ANTI);
}
}
else
--- 3384,3389 ----
*************** sched_analyze_2 (deps, x, insn)
*** 3540,3550 ****
/* ??? This should never happen. */
for (u = deps->reg_last_clobbers[r]; u; u = XEXP (u, 1))
add_dependence (insn, XEXP (u, 0), 0);
-
- if (call_used_regs[r] || global_regs[r])
- /* Function calls clobber all call_used regs. */
- for (u = deps->last_function_call; u; u = XEXP (u, 1))
- add_dependence (insn, XEXP (u, 0), REG_DEP_ANTI);
}
}
else
--- 3535,3540 ----
*************** sched_analyze (deps, head, tail)
*** 3987,3995 ****
{
for (u = deps->reg_last_uses[i]; u; u = XEXP (u, 1))
add_dependence (insn, XEXP (u, 0), REG_DEP_ANTI);
for (u = deps->reg_last_sets[i]; u; u = XEXP (u, 1))
! add_dependence (insn, XEXP (u, 0), REG_DEP_ANTI);
SET_REGNO_REG_SET (reg_pending_clobbers, i);
}
--- 3977,3987 ----
{
for (u = deps->reg_last_uses[i]; u; u = XEXP (u, 1))
add_dependence (insn, XEXP (u, 0), REG_DEP_ANTI);
+ free_INSN_LIST_list (&deps->reg_last_uses[i]);
for (u = deps->reg_last_sets[i]; u; u = XEXP (u, 1))
! add_dependence (insn, XEXP (u, 0), REG_DEP_OUTPUT);
! free_INSN_LIST_list (&deps->reg_last_sets[i]);
SET_REGNO_REG_SET (reg_pending_clobbers, i);
}
More information about the Gcc-patches
mailing list