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 middle-end/107661] [13 Regression] lambdas get merged incorrectly in tempaltes, cause llvm-12 miscompilation since r13-3358-ge0403e95689af7
Date: Tue, 15 Nov 2022 23:21:45 +0000	[thread overview]
Message-ID: <bug-107661-4-0HBVvnq1mv@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107661-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #7 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
Looking -fdump-ipa-cp-all I see the following clone

```
IPA decision stage:


Evaluating opportunities for static void function_ref::callback_fn(void*) [with
Callable = seemingly_unused_foo(int)::L]/30.

Evaluating opportunities for static void function_ref::callback_fn(void*) [with
Callable = void()]/29.

Evaluating opportunities for void getWaitStatesSince3(int, function_ref)/18.
 - considering value callback_fn for param #1 Expired, offset: 0 (caller_count:
1)
     good_cloning_opportunity_p (time: 33, size: 37, freq_sum: 1) ->
evaluation: 891.89, threshold: 500
  Creating a specialized node of void getWaitStatesSince3(int,
function_ref)/18.
                Accounting size:5.00, time:14.00 on predicate exec:(true)
     the new node is void getWaitStatesSince3.constprop(int, function_ref)/33.
     Aggregate replacements: 1[0]=callback_fn
     overall size reached 88

Evaluating opportunities for void getWaitStatesSince6(int, int, int,
function_ref)/17.
 - considering value 0 for param #0 MBB (caller_count: 2)
     good_cloning_opportunity_p (time: 1, size: 21, freq_sum: 2, self_scc,
single_call) -> evaluation: 80.95, threshold: 500
     good_cloning_opportunity_p (time: 1, size: 21, freq_sum: 2, self_scc,
single_call) -> evaluation: 80.95, threshold: 500
 - considering value 42 for param #2 WaitStates (caller_count: 2)
     good_cloning_opportunity_p (time: 1.5, size: 20, freq_sum: 2, self_scc,
single_call) -> evaluation: 127.50, threshold: 500
     good_cloning_opportunity_p (time: 1.5, size: 20, freq_sum: 2, self_scc,
single_call) -> evaluation: 127.50, threshold: 500
 - considering value callback_fn for param #3 Expired, offset: 0 (caller_count:
2)
     good_cloning_opportunity_p (time: 33, size: 29, freq_sum: 1.4888,
self_scc, single_call) -> evaluation: 1440.03, threshold: 500
  Creating a specialized node of void getWaitStatesSince6(int, int, int,
function_ref)/17.
                Accounting size:2.00, time:11.00 on predicate exec:(true)
                Accounting size:3.00, time:12.00 on predicate exec:(true)
                Accounting size:3.00, time:12.00 on predicate exec:(true)
                Accounting size:5.00, time:6.84 on predicate exec:(true)
     the new node is void getWaitStatesSince6.constprop(int, int, int,
function_ref)/34.
     Aggregate replacements: 3[0]=callback_fn
     overall size reached 109

Evaluating opportunities for void getWaitStatesSince6(int, int, int,
function_ref)/17.
 - considering value 0 for param #0 MBB (caller_count: 1)
     good_cloning_opportunity_p (time: 1, size: 21, freq_sum: 1, self_scc,
single_call) -> evaluation: 40.48, threshold: 500
     good_cloning_opportunity_p (time: 1, size: 21, freq_sum: 1, self_scc,
single_call) -> evaluation: 40.48, threshold: 500
 - considering value 42 for param #2 WaitStates (caller_count: 1)
     good_cloning_opportunity_p (time: 1.5, size: 20, freq_sum: 1, self_scc,
single_call) -> evaluation: 63.75, threshold: 500
     good_cloning_opportunity_p (time: 1.5, size: 20, freq_sum: 1, self_scc,
single_call) -> evaluation: 63.75, threshold: 500
 - adding an extra caller void getWaitStatesSince6(int, int, int,
function_ref)/17 of void getWaitStatesSince6.constprop(int, int, int,
function_ref)/34

Evaluating opportunities for void Exec(function_ref)/13.
 - considering value callback_fn for param #0 fr, offset: 0 (caller_count: 1)
     good_cloning_opportunity_p (time: 33, size: 8, freq_sum: 1) -> evaluation:
4125.00, threshold: 500
  Creating a specialized node of void Exec(function_ref)/13.
                Accounting size:4.00, time:16.00 on predicate exec:(true)
     the new node is void Exec.constprop(function_ref)/35.
     Aggregate replacements: 0[0]=callback_fn
ipa-prop: Discovered an indirect call to a known target (void
Exec.constprop(function_ref)/35 -> static void function_ref::callback_fn(void*)
[with Callable = seemingly_unused_foo(int)::L]/30), for stmt _1 (_2);
../a.cc:37:14: optimized: converting indirect call in void
Exec.constprop(function_ref)/35 to direct call to static void
function_ref::callback_fn(void*) [with Callable =
seemingly_unused_foo(int)::L]/30
                Accounting size:2.00, time:11.00 on predicate exec:(true)
     overall size reached 117

Evaluating opportunities for void Exec(function_ref)/13.
Not considering void Exec.constprop(function_ref)/35 for ipa bitwise
propagation ; -fipa-bit-cp: disabled.
...

IPA constant propagation end
```

When debug reports unqualified `Aggregate replacements: 1[0]=callback_fn` does
it mean ipa-cp does not distinguish between:
  * static void function_ref::callback_fn(void*) [with Callable =
seemingly_unused_foo(int)::L]/30.
  * static void function_ref::callback_fn(void*) [with Callable = void()]/29.
?

I suspect it does not and that results in a wrong callback_fn inline.

  parent reply	other threads:[~2022-11-15 23:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-12 18:06 [Bug middle-end/107661] New: [13 Regression] lambdas get merged incorrectly in tempaltes, cause llvm-12 miscompilation slyfox at gcc dot gnu.org
2022-11-12 18:13 ` [Bug middle-end/107661] " pinskia at gcc dot gnu.org
2022-11-12 18:21 ` slyfox at gcc dot gnu.org
2022-11-12 20:16 ` slyfox at gcc dot gnu.org
2022-11-12 22:47 ` slyfox at gcc dot gnu.org
2022-11-13 14:23 ` [Bug middle-end/107661] [13 Regression] lambdas get merged incorrectly in tempaltes, cause llvm-12 miscompilation since r13-3358-ge0403e95689af7 slyfox at gcc dot gnu.org
2022-11-13 14:57 ` jamborm at gcc dot gnu.org
2022-11-14 13:55 ` rguenth at gcc dot gnu.org
2022-11-15 23:21 ` slyfox at gcc dot gnu.org [this message]
2022-11-18  8:42 ` slyfox at gcc dot gnu.org
2022-11-18  8:43 ` slyfox at gcc dot gnu.org
2022-11-18  8:54 ` slyfox at gcc dot gnu.org
2022-11-19 20:11 ` slyfox at gcc dot gnu.org
2022-11-19 20:29 ` slyfox at gcc dot gnu.org
2022-11-20 21:26 ` slyfox at gcc dot gnu.org
2022-11-21 22:52 ` jamborm at gcc dot gnu.org
2022-11-22 14:13 ` [Bug ipa/107661] " jamborm at gcc dot gnu.org
2022-11-22 17:30 ` cvs-commit at gcc dot gnu.org
2022-11-22 17:33 ` jamborm at gcc dot gnu.org
2022-11-24 22:46 ` 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-107661-4-0HBVvnq1mv@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).