[Bug rtl-optimization/38245] [4.4 Regression] apparent improper segfault in compiler output

steven at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Nov 28 11:25:00 GMT 2008

------- Comment #2 from steven at gcc dot gnu dot org  2008-11-28 11:23 -------
There really is obvious way to remove the argument pushes without libcall
notes.  There is nothing in the RTL to make clear that the pushes are dead when
the call is removed, so they pushes stay.

There are several ways to "fix" this.

1. Make the call not pure (even if the function is technically pure).
IIRC the call pops the incoming arguments on return, which is clearly a
non-pure side-effect. I am assuming it is acceptable that the call is not a
candidate for DCE.  I think this is acceptable -- it's the consequence of
removing libcall notes -- but OTOH I would like to understand *why* we end up
with a DCE-able pure call in the first place, why it's not optimized away in
the tree optimizations.
Of course, a call would only have to be non-pure if it takes arguments via the
stack.  For targets with "proper" argument passing via registers ;) the call
should still be pure.

2. Make it explicit in the IL that the pushes are inputs for the call.
For example, add EXPR_LISTs from the CALL_INSNs to the pushes of the outgoing
args, and teach DCE to remove the insn in the EXPR_LIST when a CALL_INSN is
removed.  Or resurrect REG_LIBCALL_ID (renamed REG_PURECALL_ID), teach DCE to
keep a list of the REG_PURECALL_IDs for removed pure calls, and do a second
pass to remove all (non-CALL_INSN) insns that have the REG_PURECALL_ID of a
removed libcall.
This assumes that we can always remove the outgoing argument pushes if a pure
call is removed.  I'm not sure if this is true (is it conceivable that we CSE
things in such a way that other insns would depend on the argument pushes?).

Personally, I'm strongly in favor of option 1.



More information about the Gcc-bugs mailing list