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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2023-06-20

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  The issue is that we create a constant pool entry at RTL expansion
time and when the last use vanishes during RTL optimization the unused constant
pool entries are not pruned.

In this case we initially emit

;; _5 = __builtin_memcmp_eq (p_8(D), "ifndef", 6);

(insn 34 33 35 (set (reg/f:DI 94)
        (symbol_ref/f:DI ("*.LC0") [flags 0x2]  <var_decl 0x7fdd8d0643f0
*.LC0>)) "t.c":13:24 -1 
     (nil))       

(insn 35 34 36 (set (reg:CCZ 17 flags)
        (compare:CCZ (mem:SI (reg/v/f:DI 91 [ p ]) [0 MEM <char[1:6]> [(void
*)p_8(D)]+0 S4 A8])
            (const_int 1684956777 [0x646e6669]))) "t.c":13:24 -1
     (nil))

(jump_insn 36 35 37 (set (pc)
        (if_then_else (ne (reg:CCZ 17 flags)
                (const_int 0 [0]))
            (label_ref 43)
            (pc))) "t.c":13:24 -1
     (nil))

(insn 37 36 38 (set (reg:CCZ 17 flags)
        (compare:CCZ (mem:HI (plus:DI (reg/v/f:DI 91 [ p ])
                    (const_int 4 [0x4])) [0 MEM <char[1:6]> [(void *)p_8(D)]+4
S2 A8])
            (const_int 26213 [0x6665]))) "t.c":13:24 -1
     (nil))

(jump_insn 38 37 39 (set (pc)
        (if_then_else (ne (reg:CCZ 17 flags)
                (const_int 0 [0]))
            (label_ref 43)
            (pc))) "t.c":13:24 -1
     (nil))

(insn 39 38 40 (set (reg:SI 85 [ _5 ])
        (const_int 0 [0])) "t.c":13:24 -1
     (nil))

... so even RTL expansion doesn't end up using the string literal so
maybe this particular case can be catched early.  Pruning the constant
pool would be nice of course but we emit that quite early.

I'm quite sure there's duplicate bugreports about this.

Reply via email to