[Bug tree-optimization/105739] [10 Regression] Miscompilation of Linux kernel update.c

2022-06-20 Thread hubicka at kam dot mff.cuni.cz via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105739

--- Comment #17 from hubicka at kam dot mff.cuni.cz ---
> Fixed (Honza, hope you don't mind the backports I've done, did that so that it
> is on time for 10.4).
Thanks. I don't mind: I was planning to do them this week anyway and
also extra VOLATILE check shoud not be very risky.

[Bug tree-optimization/105739] [10 Regression] Miscompilation of Linux kernel update.c

2022-06-20 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105739

Jakub Jelinek  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #16 from Jakub Jelinek  ---
Fixed (Honza, hope you don't mind the backports I've done, did that so that it
is on time for 10.4).

[Bug tree-optimization/105739] [10 Regression] Miscompilation of Linux kernel update.c

2022-06-20 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105739

--- Comment #15 from CVS Commits  ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
:

https://gcc.gnu.org/g:62148f13c6427edd256072b3196a01b3d5ed2805

commit r10-10856-g62148f13c6427edd256072b3196a01b3d5ed2805
Author: Jan Hubicka 
Date:   Tue Jun 14 14:05:53 2022 +0200

Fix ipa-cp wrt volatile loads

Check for volatile flag to ipa_load_from_parm_agg.

gcc/ChangeLog:

2022-06-10  Jan Hubicka  

PR ipa/105739
* ipa-prop.c (ipa_load_from_parm_agg): Punt on volatile loads.

gcc/testsuite/ChangeLog:

2022-06-10  Jan Hubicka  

* gcc.dg/ipa/pr105739.c: New test.

(cherry picked from commit 8f6c317b3a16350698f3c9e0accb43a9b4acb4ae)

[Bug tree-optimization/105739] [10 Regression] Miscompilation of Linux kernel update.c

2022-06-20 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105739

--- Comment #14 from CVS Commits  ---
The releases/gcc-11 branch has been updated by Jakub Jelinek
:

https://gcc.gnu.org/g:49aa637488053223bc04e59aac411d4a92ebcf7b

commit r11-10080-g49aa637488053223bc04e59aac411d4a92ebcf7b
Author: Jan Hubicka 
Date:   Tue Jun 14 14:05:53 2022 +0200

Fix ipa-cp wrt volatile loads

Check for volatile flag to ipa_load_from_parm_agg.

gcc/ChangeLog:

2022-06-10  Jan Hubicka  

PR ipa/105739
* ipa-prop.c (ipa_load_from_parm_agg): Punt on volatile loads.

gcc/testsuite/ChangeLog:

2022-06-10  Jan Hubicka  

* gcc.dg/ipa/pr105739.c: New test.

(cherry picked from commit 8f6c317b3a16350698f3c9e0accb43a9b4acb4ae)

[Bug tree-optimization/105739] [10 Regression] Miscompilation of Linux kernel update.c

2022-06-19 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105739

--- Comment #13 from CVS Commits  ---
The releases/gcc-12 branch has been updated by Jakub Jelinek
:

https://gcc.gnu.org/g:bf4ba940673b80961c5979078f9d37a7bef2f5ff

commit r12-8493-gbf4ba940673b80961c5979078f9d37a7bef2f5ff
Author: Jan Hubicka 
Date:   Tue Jun 14 14:05:53 2022 +0200

Fix ipa-cp wrt volatile loads

Check for volatile flag to ipa_load_from_parm_agg.

gcc/ChangeLog:

2022-06-10  Jan Hubicka  

PR ipa/105739
* ipa-prop.cc (ipa_load_from_parm_agg): Punt on volatile loads.

gcc/testsuite/ChangeLog:

2022-06-10  Jan Hubicka  

* gcc.dg/ipa/pr105739.c: New test.

(cherry picked from commit 8f6c317b3a16350698f3c9e0accb43a9b4acb4ae)

[Bug tree-optimization/105739] [10 Regression] Miscompilation of Linux kernel update.c

2022-06-14 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105739

--- Comment #12 from Jakub Jelinek  ---
Thanks, I have verified that on the #c0 testcase on 10 branch it makes both
__builtin_unreachable calls go away.

[Bug tree-optimization/105739] [10 Regression] Miscompilation of Linux kernel update.c

2022-06-14 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105739

--- Comment #11 from CVS Commits  ---
The master branch has been updated by Jan Hubicka :

https://gcc.gnu.org/g:8f6c317b3a16350698f3c9e0accb43a9b4acb4ae

commit r13-1089-g8f6c317b3a16350698f3c9e0accb43a9b4acb4ae
Author: Jan Hubicka 
Date:   Tue Jun 14 14:05:53 2022 +0200

Fix ipa-cp wrt volatile loads

Check for volatile flag to ipa_load_from_parm_agg.

gcc/ChangeLog:

2022-06-10  Jan Hubicka  

PR ipa/105739
* ipa-prop.cc (ipa_load_from_parm_agg): Punt on volatile loads.

gcc/testsuite/ChangeLog:

2022-06-10  Jan Hubicka  

* gcc.dg/ipa/pr105739.c: New test.

[Bug tree-optimization/105739] [10 Regression] Miscompilation of Linux kernel update.c

2022-06-10 Thread hubicka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105739

--- Comment #10 from Jan Hubicka  ---
I am testing
diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc
index afd9222b5a2..c037668e7d8 100644
--- a/gcc/ipa-prop.cc
+++ b/gcc/ipa-prop.cc
@@ -1112,6 +1112,10 @@ ipa_load_from_parm_agg (struct ipa_func_body_info *fbi,
   if (!base)
 return false;

+  /* We can not propagate across volatile loads.  */
+  if (TREE_THIS_VOLATILE (op))
+return false;
+
   if (DECL_P (base))
 {
   int index = ipa_get_param_decl_index_1 (descriptors, base);

[Bug tree-optimization/105739] [10 Regression] Miscompilation of Linux kernel update.c

2022-06-10 Thread hubicka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105739

--- Comment #9 from Jan Hubicka  ---
Indeed volatile checks seems to be missing across ipa-prop code. Here is
smaller testcase:

__attribute__((noinline))
static int
test2(int a)
{
if (__builtin_constant_p (a))
__builtin_abort ();
return a;
}
/*__attribute__((noinline))*/
static int
test(int *a)
{
int val = *(volatile int *)a;
if (__builtin_constant_p (val))
__builtin_abort ();
if (val)
  return test2(val);
return 0;
}
int a;
int
main()
{
a = 0;
return test ();
}

is optimized to
main:
.LFB2:
.cfi_startproc
movl$0, a(%rip)
movla(%rip), %eax
xorl%eax, %eax
ret
.cfi_endproc

which I don't think is correct. The volatile load can be non-0 and thus we can
return non-0.
It does not trigger unreachable as I hoped for since vrp and fab passes seems
to jump to same conclusion as ipa-cp.

[Bug tree-optimization/105739] [10 Regression] Miscompilation of Linux kernel update.c

2022-06-09 Thread hubicka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105739

--- Comment #8 from Jan Hubicka  ---
After inlning I see:
IPA function summary for rcu_tasks_trace_pertask/5350 inlinable 
  global time: 13.535950
  self size:   11   
  global size: 16   
  min size:   11
  self stack:  0
  global stack:0
  estimated growth:5
size:8.00, time:5.807250
size:3.00, time:2.00,  executed if:(not inlined)
size:2.00, time:2.00,  nonconst if:(op0 changed)
  calls:
rcu_tasks_trace_pertask.part.0/5788 inlined 
  freq:0.62 
  Stack frame offset 0, callee self size 0  
  trc_wait_for_one_reader/5799 inlined  
freq:0.62   
Stack frame offset 0, callee self size 0
__builtin_unreachable/5800 unreachable  
  freq:0.00 loop depth: 0 size: 0 time:  0 predicate: (false)   
   op0 is compile time invariant
   op1 is compile time invariant
trc_wait_for_one_reader.part.0/5784 --param max-inline-insns-auto limit
reached
  freq:0.31 loop depth: 0 size: 3 time: 12 callee size:100 stack: 0 
__builtin_expect/5421 function body not available   
  freq:1.00 loop depth: 0 size: 0 time:  0  
   op1 is compile time invariant

So it seems that we determine call in trc_wait_for_one_reader unreachable.
It originally calls printk:
IPA function summary for trc_wait_for_one_reader/5348 inlinable 
  global time: 13.50
  self size:   20   
  global size: 20   
  min size:   1 
  self stack:  0
  global stack:0
size:1.00, time:1.00
size:3.00, time:2.00,  executed if:(not inlined)
size:0.50, time:0.50,  executed if:(not inlined),  nonconst
if:(op0[ref offset: 8672] changed) && (not inlined)
size:2.50, time:2.50,  nonconst if:(op0[ref offset: 8672] changed)  
size:1.50, time:0.25,  executed if:(op0[ref offset: 8672] != -1) &&
(not inlined)
size:3.50, time:1.25,  executed if:(op0[ref offset: 8672] != -1)
  calls:
trc_wait_for_one_reader.part.0/5784 function not considered for inlining
  freq:0.50 loop depth: 0 size: 3 time: 12 callee size:55 stack: 0
predicate: (op0[ref offset: 8672] == -1)
_printk/5452 function body not available
  freq:0.00 loop depth: 0 size: 5 time: 14 predicate: (op0[ref offset:
8672] != -1)
   op0 is compile time invariant

So we somehow figure out (op0[ref offset: 8672] != -1) here:
Enqueueing calls in rcu_tasks_trace_pertask.part.0/5788.
   Estimating body: trc_wait_for_one_reader/5348
   Known to be false: not inlined, op0[ref offset: 8672] != -1, op0[ref offset:
8672] changed
   size:4 time:7.00 nonspec time:12.00  

This seems to be based on:

Jump functions: 
  Jump functions of caller  rcu_tasks_trace_pertask.part.0/5788:
callsite  rcu_tasks_trace_pertask.part.0/5788 ->
trc_wait_for_one_reader/5348 :
   param 0: PASS THROUGH: 0, op nop_expr
 Aggregate passed by reference: 
   offset: 8672, type: int, CONST: -1   
 value: 0x0, mask: 

[Bug tree-optimization/105739] [10 Regression] Miscompilation of Linux kernel update.c

2022-06-04 Thread hubicka at kam dot mff.cuni.cz via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105739

--- Comment #7 from hubicka at kam dot mff.cuni.cz ---
> Honza, any estimate how long this could take?  I'd prefer to wait with 10.4 
> for
> it  if it isn't going to take too long.
I am at a conference this week with talk at Wednesday.  I will try to
debug this during the event.

Honza

[Bug tree-optimization/105739] [10 Regression] Miscompilation of Linux kernel update.c

2022-06-02 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105739

--- Comment #6 from Jakub Jelinek  ---
Honza, any estimate how long this could take?  I'd prefer to wait with 10.4 for
it  if it isn't going to take too long.

[Bug tree-optimization/105739] [10 Regression] Miscompilation of Linux kernel update.c

2022-05-27 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105739

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|9.5 |10.4

--- Comment #5 from Richard Biener  ---
GCC 9 branch is being closed