[Bug rtl-optimization/38245] [4.4 Regression] stack corruption when a call is removed but not the outgoing argument pushes

steven at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Thu Dec 18 21:20:00 GMT 2008



------- Comment #13 from steven at gcc dot gnu dot org  2008-12-18 21:19 -------
Jakub's idea of comment #10 is nice conceptually, but it's a bit complicated in
practice for most cases where a libcall is emitted.  Before subreg lowering we
have this:

(insn 8 7 9 2 t.c:19 (set (mem:DI (plus:SI (reg/f:SI 7 sp)
                (const_int 8 [0x8])) [0 S8 A32])
        (const_int 2123 [0x84b])) 63 {*movdi_2} (nil))

(insn 9 8 10 2 t.c:19 (set (mem:DI (reg/f:SI 7 sp) [0 S8 A32])
        (reg:DI 60)) 63 {*movdi_2} (nil))

(call_insn/u 10 9 11 2 t.c:19 (set (reg:DI 0 ax)
        (call (mem:QI (symbol_ref:SI ("__umoddi3") [flags 0x43]) [0 S1 A8])
            (const_int 16 [0x10]))) 676 {*call_value_0}
(expr_list:REG_EH_REGION (const_int -1 [0xffffffff])
        (nil))
    (expr_list:REG_DEP_TRUE (use (mem:DI (reg/f:SI 7 sp) [0 S8 A8]))
        (expr_list:REG_DEP_TRUE (use (mem:DI (plus:SI (reg/f:SI 7 sp)
                        (const_int 8 [0x8])) [0 S8 A8]))
            (nil))))


But after subreg lowering (and some more, fwprop dump shown) we have split the
DImode store of g into two separate stores, without updating the REG_DEP notes
in the CALL_INSN:

(insn 8 33 34 2 t.c:19 (set (mem:DI (plus:SI (reg/f:SI 7 sp)
                (const_int 8 [0x8])) [0 S8 A32])
        (const_int 2123 [0x84b])) 63 {*movdi_2} (nil))

(insn 34 8 35 2 t.c:19 (set (mem:SI (reg/f:SI 7 sp) [0 S4 A32])
        (reg:SI 61 [ g ])) 41 {*movsi_1} (nil))

(insn 35 34 10 2 t.c:19 (set (mem:SI (plus:SI (reg/f:SI 7 sp)
                (const_int 4 [0x4])) [0 S4 A32])
        (const_int 0 [0x0])) 41 {*movsi_1} (nil))

(call_insn/u 10 35 36 2 t.c:19 (set (reg:DI 0 ax)
        (call (mem:QI (symbol_ref:SI ("__umoddi3") [flags 0x43]) [0 S1 A8])
            (const_int 16 [0x10]))) 676 {*call_value_0}
(expr_list:REG_EH_REGION (const_int -1 [0xffffffff])
        (nil))
    (expr_list:REG_DEP_TRUE (use (mem:DI (reg/f:SI 7 sp) [0 S8 A8]))
        (expr_list:REG_DEP_TRUE (use (mem:DI (plus:SI (reg/f:SI 7 sp)
                        (const_int 8 [0x8])) [0 S8 A8]))
            (nil))))

Most "interesting" libcalls for x86 -m32 probably are the DImode ones, and if
subreg lowering does this for all arguments, we would have to update the
REG_REP notes in the CALL_INSN, or do a lot of DSE-like work...


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38245



More information about the Gcc-bugs mailing list