[Bug ipa/110282] [12/13/14/15 regression] Segmentation fault with specific optimizations since r10-3311-gff6686d2e5f797

2025-05-20 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110282

--- Comment #23 from Sam James  ---
Thanks Martin.

[Bug ipa/110282] [12/13/14/15 regression] Segmentation fault with specific optimizations since r10-3311-gff6686d2e5f797

2025-05-20 Thread jamborm at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110282

Martin Jambor  changed:

   What|Removed |Added

 Resolution|--- |DUPLICATE
 Status|NEW |RESOLVED

--- Comment #22 from Martin Jambor  ---
(In reply to mcccs from comment #21)
> Okay I'm so sorry for the misinterpretation. I thought DCE should never turn
> an invalid program to a valid one because DCE is always an optimization and
> optimizations should never modify the behavior of the programs. But since
> you're the code owner and someone familiar with GCC internals your word is
> worth 100 times my word so this can be closed.

Your thinking about DCE, meaning the DCE pass, is actually the one
that prevailed. But that is in fact why I was made to write the patch
committed as r12-1848.  It also adds a special DCE-like feature to
IPA-SRA pass but it is there specifically for the pass to clean up
after itself, not as a standalone optimization.

Before that the pass did rely on the fact that when a parameter is
used as a divisor or when it is dereferenced, but then the result is
never used, DCE would take care of that operation and remove it.  And
so IPA-SRA was happy to keep such operations around even if they used
uninitialized values from what remained of removed formal parameters
of a function.  Since it was decided that DCE can be switched off
safely, IPA-SRA had to find all such operations it "created" and
remove it - or rather not copy it the new clone - itself.  The line
you removed by sed is an initial part of that process.

*** This bug has been marked as a duplicate of bug 99912 ***

[Bug ipa/110282] [12/13/14/15 regression] Segmentation fault with specific optimizations since r10-3311-gff6686d2e5f797

2025-05-20 Thread mcccs at gmx dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110282

--- Comment #21 from mcccs at gmx dot com ---
Okay I'm so sorry for the misinterpretation. I thought DCE should never turn an
invalid program to a valid one because DCE is always an optimization and
optimizations should never modify the behavior of the programs. But since
you're the code owner and someone familiar with GCC internals your word is
worth 100 times my word so this can be closed.

[Bug ipa/110282] [12/13/14/15 regression] Segmentation fault with specific optimizations since r10-3311-gff6686d2e5f797

2025-05-19 Thread jamborm at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110282

--- Comment #20 from Martin Jambor  ---
(In reply to mcccs from comment #17)
>
[...]
> 
> The problem is that the parameter pointer is not set to the argument so
> dereferencing it causes a segfault. Dumping all the passes, this problem is
> first present in the output of the pass "x.c.100t.fixup_cfg3.c" as compiled
> with the modified GCC with -O3 -fno-dce -fno-ipa-cp -fno-tree-dce -fno-dse
> -fno-tree-dse
> 

This looks pretty much like a bug that...

(In reply to mcccs from comment #15)
> There's indeed a miscompilation and I've confirmed it's still present in the
> current trunk. With -fno-dce -fno-ipa-cp -fno-tree-dce the issue was visible
> until r12-248 which made the issue latent. So I added -fno-tree-dse and then
> it was made latent by r12-1848. So I added:

...the commit r12-1848 aimed to fix.  What makes you think it is
"latent?"

>
[...]
> 
> Download the minimized testcase from
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110282#c14
> 
> -O3 -fno-dce -fno-ipa-cp -fno-tree-dce -fno-dse -fno-tree-dse
> 
> sed -i -e 's/mark_dead_statements (m_oparms\[i\]/(void)3;\/\//g'
> ./gcc/gcc/ipa-param-manipulation.cc
> 

This looks like undoing a fix for the problem you described in
comment#17, I'm afraid.

[Bug ipa/110282] [12/13/14/15 regression] Segmentation fault with specific optimizations since r10-3311-gff6686d2e5f797

2025-05-19 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110282

Sam James  changed:

   What|Removed |Added

 Ever confirmed|0   |1
   Last reconfirmed||2025-05-19
 Status|UNCONFIRMED |NEW

--- Comment #19 from Sam James  ---
Tentatively confirmed then.

[Bug ipa/110282] [12/13/14/15 regression] Segmentation fault with specific optimizations since r10-3311-gff6686d2e5f797

2025-05-11 Thread mcccs at gmx dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110282

--- Comment #18 from mcccs at gmx dot com ---
> this problem is first present in the output of the pass 
> "x.c.100t.fixup_cfg3.c" 

Sorry, there are non-tree dumps as well. the first wrong dump is (of course)
the "inline" ipa dump

[Bug ipa/110282] [12/13/14/15 regression] Segmentation fault with specific optimizations since r10-3311-gff6686d2e5f797

2025-05-11 Thread mcccs at gmx dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110282

--- Comment #17 from mcccs at gmx dot com ---
Actually my test file in comment 16 is invalid. This means the failure happens
before the optimized pass and it needs the DCE-disabled GCC I described in
comment 15 to reproduce the faulty optimized dump (which is then propagated in
later passes in any GCC).

The problem is that the parameter pointer is not set to the argument so
dereferencing it causes a segfault. Dumping all the passes, this problem is
first present in the output of the pass "x.c.100t.fixup_cfg3.c" as compiled
with the modified GCC with -O3 -fno-dce -fno-ipa-cp -fno-tree-dce -fno-dse
-fno-tree-dse

The previous dump, "x.058t.local-fnsummary2", is sane and looks like this:

int * __GIMPLE (ssa,guessed_local(1073741824))
n (int * o)
{
...
  _3 = __MEM  (o_17(D));

...

main ()
{
  __BB(2):
  n (&a);

whereas x.c.100t.fixup_cfg3.c looks like this:

int __GIMPLE (ssa)
main ()
{
  int * o;
...(no assignment to o)...
  _6 = __MEM  (o_5(D));


__attribute__((noclone)) to the function fixes the segmentation fault,
__attribute__((noinline)) doesn't.

[Bug ipa/110282] [12/13/14/15 regression] Segmentation fault with specific optimizations since r10-3311-gff6686d2e5f797

2025-05-11 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110282

Sam James  changed:

   What|Removed |Added

   Target Milestone|--- |12.5
Summary|Segmentation fault with |[12/13/14/15 regression]
   |specific optimizations  |Segmentation fault with
   ||specific optimizations
   ||since
   ||r10-3311-gff6686d2e5f797
   Keywords|needs-bisection,|
   |needs-reduction |
  Component|middle-end  |ipa
 CC||jamborm at gcc dot gnu.org