* [Bug middle-end/115135] [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants
2024-05-17 12:52 [Bug target/115135] New: [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants clopez at igalia dot com
@ 2024-05-17 13:25 ` pinskia at gcc dot gnu.org
2024-05-17 15:51 ` clopez at igalia dot com
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-17 13:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115135
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Does either -fno-ivopts or -fno-ipa-modref help?
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/115135] [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants
2024-05-17 12:52 [Bug target/115135] New: [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants clopez at igalia dot com
2024-05-17 13:25 ` [Bug middle-end/115135] " pinskia at gcc dot gnu.org
@ 2024-05-17 15:51 ` clopez at igalia dot com
2024-05-20 18:10 ` clopez at igalia dot com
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: clopez at igalia dot com @ 2024-05-17 15:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115135
--- Comment #2 from Carlos Alberto Lopez Perez <clopez at igalia dot com> ---
(In reply to Andrew Pinski from comment #1)
> Does either -fno-ivopts or -fno-ipa-modref help?
-fno-ivopts does not help
-fno-ipa-modref helps! passing this flag makes the compiled program is correct
:)
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/115135] [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants
2024-05-17 12:52 [Bug target/115135] New: [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants clopez at igalia dot com
2024-05-17 13:25 ` [Bug middle-end/115135] " pinskia at gcc dot gnu.org
2024-05-17 15:51 ` clopez at igalia dot com
@ 2024-05-20 18:10 ` clopez at igalia dot com
2024-05-20 18:50 ` clopez at igalia dot com
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: clopez at igalia dot com @ 2024-05-20 18:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115135
--- Comment #3 from Carlos Alberto Lopez Perez <clopez at igalia dot com> ---
Note: I just tested to build GCC from master branch (version 15.0.0 20240520:
commit e14c673ea9ab2eca5de4db91b478f0b5297ef321) and the issue is still
reproducible with it.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/115135] [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants
2024-05-17 12:52 [Bug target/115135] New: [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants clopez at igalia dot com
` (2 preceding siblings ...)
2024-05-20 18:10 ` clopez at igalia dot com
@ 2024-05-20 18:50 ` clopez at igalia dot com
2024-05-21 13:29 ` [Bug ipa/115135] " sjames at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: clopez at igalia dot com @ 2024-05-20 18:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115135
--- Comment #4 from Carlos Alberto Lopez Perez <clopez at igalia dot com> ---
FYI: Another way to workaround the issue and make the test pass is to tell GCC
to not in-line the function doTest().
--- a/test.cpp 2024-05-17 03:15:07.275473492 +0000
+++ b/test.cpp 2024-05-20 13:18:51.334943200 +0000
@@ -75,7 +75,7 @@
class mTest;
-int doTest(mTest& mObj, std::variant<std::unique_ptr<aTest>,
std::unique_ptr<bTest>>&& dVar, std::shared_ptr<aTest> aPtr, bTest bObj)
+int __attribute__ ((noinline)) doTest(mTest& mObj,
std::variant<std::unique_ptr<aTest>, std::unique_ptr<bTest>>&& dVar,
std::shared_ptr<aTest> aPtr, bTest bObj)
{
return switchOn(dVar,
[&](std::unique_ptr<aTest>& ptr_a) -> int {
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug ipa/115135] [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants
2024-05-17 12:52 [Bug target/115135] New: [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants clopez at igalia dot com
` (3 preceding siblings ...)
2024-05-20 18:50 ` clopez at igalia dot com
@ 2024-05-21 13:29 ` sjames at gcc dot gnu.org
2024-05-21 13:31 ` clopez at igalia dot com
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-05-21 13:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115135
Sam James <sjames at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|middle-end |ipa
--- Comment #5 from Sam James <sjames at gcc dot gnu.org> ---
(In reply to Carlos Alberto Lopez Perez from comment #2)
> -fno-ipa-modref helps! passing this flag makes the compiled program is
> correct :)
-> calling it an IPA issue.
Carlos, if you can find a version which worked before, could you bisect?
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug ipa/115135] [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants
2024-05-17 12:52 [Bug target/115135] New: [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants clopez at igalia dot com
` (4 preceding siblings ...)
2024-05-21 13:29 ` [Bug ipa/115135] " sjames at gcc dot gnu.org
@ 2024-05-21 13:31 ` clopez at igalia dot com
2024-05-21 13:36 ` clopez at igalia dot com
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: clopez at igalia dot com @ 2024-05-21 13:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115135
--- Comment #6 from Carlos Alberto Lopez Perez <clopez at igalia dot com> ---
(In reply to Sam James from comment #5)
> (In reply to Carlos Alberto Lopez Perez from comment #2)
> > -fno-ipa-modref helps! passing this flag makes the compiled program is
> > correct :)
>
> -> calling it an IPA issue.
>
> Carlos, if you can find a version which worked before, could you bisect?
Unfortunately all versions of GCC that I tested fail.
I even tested with a nightly build of GCC (built yesterday at version 15.0.0
20240520 from GCC commit e14c673ea9ab2eca5de4db91b478f0b5297ef321). It also
fails.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug ipa/115135] [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants
2024-05-17 12:52 [Bug target/115135] New: [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants clopez at igalia dot com
` (5 preceding siblings ...)
2024-05-21 13:31 ` clopez at igalia dot com
@ 2024-05-21 13:36 ` clopez at igalia dot com
2024-05-21 13:38 ` sjames at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: clopez at igalia dot com @ 2024-05-21 13:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115135
--- Comment #7 from Carlos Alberto Lopez Perez <clopez at igalia dot com> ---
Well, I just tested with gcc-11 now and that one works.
So the failure was introduced between 11 and 12.
$ g++-11 --version
g++-11 (Debian 11.3.0-12) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ g++-11 -std=c++20 -O3 -fno-exceptions test.cpp && ./a.out
[DEBUG] aPtr at 0xffffe61eeee0 points to 0xaaaae4a7e2c0 which has value 10 [At
initTest()]
[DEBUG] bObj at 0xffffe61eeed0 has value 11 [At initTest()]
[DEBUG] aPtr at 0xffffe61eeef0 points to 0xaaaae4a7e2c0 which has value 10 [At
doTest():aTest]
[DEBUG] bObj at 0xffffe61eeed8 has value 11 [At doTest():aTest]
[DEBUG] mObj at 0xffffe61eef68 [At doTest():aTest]
[DEBUG] mObj at 0xffffe61eef68 has value 33 [At main()]
[OK] Everything went as expected. Program compiled correctly :)
$ g++-12 --version
g++-12 (Debian 12.2.0-14) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ g++-12 -std=c++20 -O3 -fno-exceptions test.cpp && ./a.out
[DEBUG] aPtr at 0xffffd052ba00 points to 0xaaaae95d02c0 which has value 10 [At
initTest()]
[DEBUG] bObj at 0xffffd052b9f0 has value 11 [At initTest()]
[DEBUG] aPtr at 0xffffd052ba10 points to 0xffffd052bbc8 which has value
-799881990 [At doTest():aTest]
[DEBUG] bObj at 0xffffd052b9f8 has value -1136642444 [At doTest():aTest]
[DEBUG] mObj at 0xffffd052ba48 [At doTest():aTest]
[DEBUG] mObj at 0xffffd052ba48 has value -1936524422 [At main()]
[ERROR] Something went wrong compiling the program!: mObj.m_data should be 33
but is -1936524422
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug ipa/115135] [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants
2024-05-17 12:52 [Bug target/115135] New: [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants clopez at igalia dot com
` (6 preceding siblings ...)
2024-05-21 13:36 ` clopez at igalia dot com
@ 2024-05-21 13:38 ` sjames at gcc dot gnu.org
2024-05-21 14:00 ` [Bug ipa/115135] [12/13/14/15 regression] " clopez at igalia dot com
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-05-21 13:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115135
--- Comment #8 from Sam James <sjames at gcc dot gnu.org> ---
(godbolt is great for this, btw)
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug ipa/115135] [12/13/14/15 regression] [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants
2024-05-17 12:52 [Bug target/115135] New: [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants clopez at igalia dot com
` (7 preceding siblings ...)
2024-05-21 13:38 ` sjames at gcc dot gnu.org
@ 2024-05-21 14:00 ` clopez at igalia dot com
2024-05-29 11:37 ` [Bug ipa/115135] [12/13/14/15 regression] [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants since r12-5113-gd70ef65692fced sjames at gcc dot gnu.org
2024-06-23 3:00 ` pinskia at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: clopez at igalia dot com @ 2024-05-21 14:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115135
--- Comment #9 from Carlos Alberto Lopez Perez <clopez at igalia dot com> ---
(In reply to Sam James from comment #8)
> (godbolt is great for this, btw)
good idea. I tried it but for target ARM64 it doesn't allow to execute the
code, only see the generated assembly. And I'm not versed enough on reading
assembly to easily spot the issue there.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug ipa/115135] [12/13/14/15 regression] [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants since r12-5113-gd70ef65692fced
2024-05-17 12:52 [Bug target/115135] New: [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants clopez at igalia dot com
` (8 preceding siblings ...)
2024-05-21 14:00 ` [Bug ipa/115135] [12/13/14/15 regression] " clopez at igalia dot com
@ 2024-05-29 11:37 ` sjames at gcc dot gnu.org
2024-06-23 3:00 ` pinskia at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-05-29 11:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115135
Sam James <sjames at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[12/13/14/15 regression] |[12/13/14/15 regression]
|[C++] GCC produces wrong |[C++] GCC produces wrong
|code at certain inlining |code at certain inlining
|levels on Aarch64 with |levels on Aarch64 with
|-fno-exceptions, related to |-fno-exceptions, related to
|lambdas and variants |lambdas and variants since
| |r12-5113-gd70ef65692fced
--- Comment #10 from Sam James <sjames at gcc dot gnu.org> ---
r12-5113-gd70ef65692fced is the first bad commit
commit r12-5113-gd70ef65692fced
Author: Jan Hubicka <jh@suse.cz>
Date: Wed Nov 10 13:08:41 2021 +0100
Make EAF flags more regular (and expressive)
[...]
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug ipa/115135] [12/13/14/15 regression] [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants since r12-5113-gd70ef65692fced
2024-05-17 12:52 [Bug target/115135] New: [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants clopez at igalia dot com
` (9 preceding siblings ...)
2024-05-29 11:37 ` [Bug ipa/115135] [12/13/14/15 regression] [C++] GCC produces wrong code at certain inlining levels on Aarch64 with -fno-exceptions, related to lambdas and variants since r12-5113-gd70ef65692fced sjames at gcc dot gnu.org
@ 2024-06-23 3:00 ` pinskia at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-23 3:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115135
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=115033
--- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Looking the same as PR 115033 ...
^ permalink raw reply [flat|nested] 12+ messages in thread