public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/108552] Linux i386 kernel 5.14 memory corruption for pre_compound_page() when gcov is enabled
Date: Fri, 27 Jan 2023 15:13:26 +0000	[thread overview]
Message-ID: <bug-108552-4-cdC6wGvENq@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108552-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #26 from Richard Biener <rguenth at gcc dot gnu.org> ---
And yes, to IV optimization the gcov counter for the loop body is just another
IV candidate that can be used, and in this case it allows to elide the
otherwise
unused original IV.

Now, in principle we should have applied store-motion and not only PRE which
would have avoided the issue, not tricking the RA into reloading the value
from where we store it in the loop, but the kernel uses -fno-tree-loop-im,
preventing that.  If you enable that you'd get

  <bb 7> [local count: 105119324]:
  __gcov0.prep_compound_page_I_lsm.1755_4 = __gcov0.prep_compound_page[7];
  _92 = (long unsigned int) page_12(D);
  _57 = _92 + 1;
  _119 = page_12(D) + 40;
  ivtmp.1762_136 = (unsigned int) _119;

  <bb 8> [local count: 955630225]:
  # i_66 = PHI <i_17(8), 1(7)>
  # ivtmp.1762_6 = PHI <ivtmp.1762_46(8), ivtmp.1762_136(7)>
  p_15 = (struct page *) ivtmp.1762_6;
  MEM <struct address_space *> [(union  *)p_15 + 12B] = 1024B;
  MEM[(volatile long unsigned int *)p_15 + 4B] ={v} _57;
  i_17 = i_66 + 1;
  ivtmp.1762_46 = ivtmp.1762_6 + 40;
  if (nr_pages_11 != i_17)
    goto <bb 8>; [89.00%]
  else
    goto <bb 9>; [11.00%]

  <bb 9> [local count: 105119324]:
  _73 = (unsigned int) nr_pages_11;
  _163 = _73 + 4294967294;
  _159 = (long long int) _163;
  _1 = __gcov0.prep_compound_page_I_lsm.1755_4 + 1;
  PROF_edge_counter_74 = _1 + _159;
  __gcov0.prep_compound_page[7] = PROF_edge_counter_74;

which is the desired optimization, handling the counter in the loop like
an induction variable instead of going through memory.

  parent reply	other threads:[~2023-01-27 15:13 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26  8:00 [Bug c/108552] New: " feng.tang at intel dot com
2023-01-26  8:01 ` [Bug c/108552] " feng.tang at intel dot com
2023-01-26  8:02 ` [Bug target/108552] " pinskia at gcc dot gnu.org
2023-01-26  8:05 ` pinskia at gcc dot gnu.org
2023-01-26  8:13 ` feng.tang at intel dot com
2023-01-26  8:19 ` pinskia at gcc dot gnu.org
2023-01-26 11:35 ` feng.tang at intel dot com
2023-01-26 11:37 ` feng.tang at intel dot com
2023-01-26 11:39 ` feng.tang at intel dot com
2023-01-26 16:03 ` feng.tang at intel dot com
2023-01-26 16:07 ` feng.tang at intel dot com
2023-01-26 19:06 ` pinskia at gcc dot gnu.org
2023-01-26 19:22 ` torvalds@linux-foundation.org
2023-01-27  9:52 ` ubizjak at gmail dot com
2023-01-27 10:47 ` ubizjak at gmail dot com
2023-01-27 10:56 ` ubizjak at gmail dot com
2023-01-27 12:23 ` ubizjak at gmail dot com
2023-01-27 12:29 ` ubizjak at gmail dot com
2023-01-27 12:31 ` [Bug tree-optimization/108552] " ubizjak at gmail dot com
2023-01-27 12:51 ` ubizjak at gmail dot com
2023-01-27 12:52 ` ubizjak at gmail dot com
2023-01-27 13:17 ` jakub at gcc dot gnu.org
2023-01-27 13:40 ` ubizjak at gmail dot com
2023-01-27 14:14 ` jakub at gcc dot gnu.org
2023-01-27 14:59 ` rguenth at gcc dot gnu.org
2023-01-27 15:01 ` rguenth at gcc dot gnu.org
2023-01-27 15:13 ` rguenth at gcc dot gnu.org [this message]
2023-01-27 15:15 ` jakub at gcc dot gnu.org
2023-01-27 15:18 ` rguenth at gcc dot gnu.org
2023-01-27 15:20 ` jakub at gcc dot gnu.org
2023-01-27 17:00 ` torvalds@linux-foundation.org
2023-01-27 17:05 ` torvalds@linux-foundation.org
2023-01-27 17:15 ` torvalds@linux-foundation.org
2023-01-27 17:19 ` jakub at gcc dot gnu.org
2023-01-27 17:29 ` jakub at gcc dot gnu.org
2023-01-27 22:30 ` vmakarov at gcc dot gnu.org
2023-01-28 14:20 ` feng.tang at intel dot com
2023-01-28 14:27 ` feng.tang at intel dot com
2023-01-28 14:29 ` feng.tang at intel dot com
2023-01-28 23:40 ` hubicka at ucw dot cz
2023-01-29 10:08 ` jakub at gcc dot gnu.org
2023-01-30  7:05 ` rguenth at gcc dot gnu.org
2023-01-30  7:09 ` rguenth at gcc dot gnu.org
2023-01-30  8:06 ` torvalds@linux-foundation.org
2023-01-30  8:30 ` jakub at gcc dot gnu.org
2023-01-30  8:44 ` rguenth at gcc dot gnu.org
2023-01-30  8:46 ` rguenther at suse dot de
2023-01-30 18:54 ` torvalds@linux-foundation.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-108552-4-cdC6wGvENq@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).