public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "slyfox at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug gcov-profile/111559] [14 regression] ICE when building Python with PGO
Date: Wed, 27 Sep 2023 08:03:56 +0000	[thread overview]
Message-ID: <bug-111559-4-kqfALJFBRg@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111559-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
Looks like identical code folding creates uninitialized profile counters if
there are any edges in folded functions.

I think cvise did a decent job extracting the reproducer below. Here is a
single-file trigger on `--enable-checking=yes` `gcc` from `master`:

```
// $ cat bug.c
__attribute__((noipa)) static void edge(void) {}

static void rule1(int *p) {
    edge();
    if (*p) edge();
}

static void rule1_same(int *p) {
    edge();
    if (*p) edge();
}

__attribute__((noipa)) int main(void) {
    int p = 0;
    rule1(&p);
    rule1_same(&p);
}
```

Trigger:

```
$ echo PG
$ gcc -O2 -fprofile-generate bug.c -o b -fopt-info
$ echo RUN
$ ./b
$ echo PU
$ gcc -O2 -fprofile-use -fprofile-correction bug.c -o b -fopt-info
```

Running:

```
PG
$ gcc -O2 -fprofile-generate bug.c -o b -fopt-info
bug.c:15:5: optimized:  Inlined rule1.constprop/28 into main/3 which now has
time 75.280000 and size 51, net change of -6.
bug.c:16:5: optimized:  Inlined rule1_same.constprop/27 into main/3 which now
has time 94.560000 and size 72, net change of -6.

RUN
$ ./b

PU
$ gcc -O2 -fprofile-use -fprofile-correction bug.c -o b -fopt-info
bug.c:3:13: optimized: Semantic equality hit:rule1/1->rule1_same/2
bug.c:3:13: optimized: Assembler symbol names:rule1/1->rule1_same/2
bug.c:15:5: optimized:  Inlined rule1.constprop/5 into main/3 which now has
time 26.000000 and size 10, net change of +2.
bug.c:16:5: optimized:  Inlined rule1.constprop/4 into main/3 which now has
time 27.000000 and size 12, net change of -6.

bug.c: In function 'main':
bug.c:13:28: error: probability of edge 3->4 not initialized
   13 | __attribute__((noipa)) int main(void) {
      |                            ^~~~
bug.c:13:28: error: probability of edge 5->6 not initialized
during IPA pass: inline
bug.c:13:28: internal compiler error: verify_flow_info failed
```

  parent reply	other threads:[~2023-09-27  8:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-23 21:42 [Bug other/111559] New: " sjames at gcc dot gnu.org
2023-09-23 21:48 ` [Bug other/111559] " sjames at gcc dot gnu.org
2023-09-23 21:49 ` [Bug gcov-profile/111559] " pinskia at gcc dot gnu.org
2023-09-24  9:03 ` slyfox at gcc dot gnu.org
2023-09-24  9:15 ` sirl at gcc dot gnu.org
2023-09-27  8:03 ` slyfox at gcc dot gnu.org [this message]
2023-09-27  8:11 ` slyfox at gcc dot gnu.org
2023-09-27 13:21 ` slyfox at gcc dot gnu.org
2023-09-27 14:46 ` slyfox at gcc dot gnu.org
2023-09-28 14:17 ` sirl at gcc dot gnu.org
2023-10-05 16:14 ` cvs-commit at gcc dot gnu.org
2023-10-05 16:16 ` slyfox at gcc dot gnu.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-111559-4-kqfALJFBRg@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).