https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126147
Bug ID: 126147
Summary: IPA PTA and modref miscompile
gcc.c-torture/execute/pr111613.c with -fipa-pta
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: ipa
Assignee: unassigned at gcc dot gnu.org
Reporter: rguenth at gcc dot gnu.org
Target Milestone: ---
pr111613.c.130t.dse2 has
;; Function new_bitfield (new_bitfield, funcdef_no=23, decl_uid=4089,
cgraph_uid=24, symbol_order=23) (executed once)
ipa-modref: call stmt set_field1_and_field2 (b_3);
ipa-modref: call to set_field1_and_field2/23 kills *b_3
Deleted dead store: # .MEM_4 = VDEF <.MEM_2>
b_3->field3 = 1;
__attribute__((returns_nonnull, noinline))
struct bitfield * new_bitfield ()
{
struct bitfield * b;
<bb 2> [local count: 1073741824]:
# .MEM_2 = VDEF <.MEM_1(D)>
# PT = null { D.4110 } (nonlocal, escaped heap)
# ALIGN = 8, MISALIGN = 0
# USE = nonlocal unit-escaped
# CLB = nonlocal unit-escaped
b_3 = malloc (4);
# .MEM_5 = VDEF <.MEM_2>
# CLB = { D.4110 } (nonlocal, escaped heap)
set_field1_and_field2 (b_3);
# VUSE <.MEM_5>
return b_3;
this looks like because modref tracks the kill as
(gdb) p kill
$6 = {offset = {coeffs = {0}}, size = {coeffs = {8}}, max_size = {coeffs = {
8}}, parm_offset = {coeffs = {0}}, parm_index = 0,
parm_offset_known = true, adjustments = 0 '\000'}
not honoring the bitfield access.