public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94175] New: [10 Regression] Passing constexpr empty class variable to function since r10-599
@ 2020-03-14 12:49 jakub at gcc dot gnu.org
  2020-03-14 12:50 ` [Bug c++/94175] " jakub at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-03-14 12:49 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94175
           Summary: [10 Regression] Passing constexpr empty class variable
                    to function since r10-599
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

Since r10-599-gc652ff83124334837dc16626f9e1040e4fe41fc9 following testcase with
-O2 -m32 (or -O0 -m32 or any arch other than x86_64 64-bit):
struct Foo
{
  struct NoStartBar {};
  static constexpr NoStartBar noStartBar = NoStartBar();
  [[gnu::noinline, gnu::noclone]] Foo(int x, NoStartBar) : f (x) { f++; }
  Foo(double x) : Foo(0, noStartBar) {}
  int f;
};
Foo a = 6.0;
needs the Foo::noStartBar definition, while before it didn't and just passed
NoStartBar {}.
Is passing the static data member an ODR use of it or not?
In any case, looks like a missed optimization, there shouldn't be reason to
copy the empty class from a variable rather than just passing uninitialized
bytes.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/94175] [10 Regression] Passing constexpr empty class variable to function since r10-599
  2020-03-14 12:49 [Bug c++/94175] New: [10 Regression] Passing constexpr empty class variable to function since r10-599 jakub at gcc dot gnu.org
@ 2020-03-14 12:50 ` jakub at gcc dot gnu.org
  2020-03-17 12:14 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-03-14 12:50 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Target Milestone|---                         |10.0
     Ever confirmed|0                           |1
                 CC|                            |jason at gcc dot gnu.org
   Last reconfirmed|                            |2020-03-14

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/94175] [10 Regression] Passing constexpr empty class variable to function since r10-599
  2020-03-14 12:49 [Bug c++/94175] New: [10 Regression] Passing constexpr empty class variable to function since r10-599 jakub at gcc dot gnu.org
  2020-03-14 12:50 ` [Bug c++/94175] " jakub at gcc dot gnu.org
@ 2020-03-17 12:14 ` jakub at gcc dot gnu.org
  2020-03-19 14:32 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-03-17 12:14 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/94175] [10 Regression] Passing constexpr empty class variable to function since r10-599
  2020-03-14 12:49 [Bug c++/94175] New: [10 Regression] Passing constexpr empty class variable to function since r10-599 jakub at gcc dot gnu.org
  2020-03-14 12:50 ` [Bug c++/94175] " jakub at gcc dot gnu.org
  2020-03-17 12:14 ` jakub at gcc dot gnu.org
@ 2020-03-19 14:32 ` jason at gcc dot gnu.org
  2020-03-19 14:48 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2020-03-19 14:32 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/94175] [10 Regression] Passing constexpr empty class variable to function since r10-599
  2020-03-14 12:49 [Bug c++/94175] New: [10 Regression] Passing constexpr empty class variable to function since r10-599 jakub at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-03-19 14:32 ` jason at gcc dot gnu.org
@ 2020-03-19 14:48 ` jason at gcc dot gnu.org
  2020-03-19 15:08 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2020-03-19 14:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> ---
Testcase using fewer C++ features:

struct A {};
extern A a;

int i;
[[gnu::noinline, gnu::noclone]]
void f(A) { ++i; }

int main()
{
  f(a);
}

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/94175] [10 Regression] Passing constexpr empty class variable to function since r10-599
  2020-03-14 12:49 [Bug c++/94175] New: [10 Regression] Passing constexpr empty class variable to function since r10-599 jakub at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2020-03-19 14:48 ` jason at gcc dot gnu.org
@ 2020-03-19 15:08 ` jakub at gcc dot gnu.org
  2020-03-20  3:54 ` cvs-commit at gcc dot gnu.org
  2020-03-20  4:04 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-03-19 15:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
But for #c1 it is just a missed-optimization, while if the passing of a
constexpr var to a function isn't an ODR use, isn't it then a standard
violation that we aren't optimizing the variable read into its value?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/94175] [10 Regression] Passing constexpr empty class variable to function since r10-599
  2020-03-14 12:49 [Bug c++/94175] New: [10 Regression] Passing constexpr empty class variable to function since r10-599 jakub at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2020-03-19 15:08 ` jakub at gcc dot gnu.org
@ 2020-03-20  3:54 ` cvs-commit at gcc dot gnu.org
  2020-03-20  4:04 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-03-20  3:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:94e2418780f1d13235f3e2e6e5c09dbe821c1ce3

commit r10-7284-g94e2418780f1d13235f3e2e6e5c09dbe821c1ce3
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Mar 19 11:06:52 2020 -0400

    c++: Avoid unnecessary empty class copy [94175].

    A simple empty class copy is still simple when wrapped in a TARGET_EXPR, so
    we need to strip that as well.  This change also exposed some unnecessary
    copies in return statements, which when returning by invisible reference
led
    to <RETURN_EXPR <MEM_REF <RESULT_DECL>>>, which gimplify_return_expr didn't
    like.  So we also need to strip the _REF when we eliminate the INIT_EXPR.

    gcc/cp/ChangeLog
    2020-03-19  Jason Merrill  <jason@redhat.com>

            PR c++/94175
            * cp-gimplify.c (simple_empty_class_p): Look through
            SIMPLE_TARGET_EXPR_P.
            (cp_gimplify_expr) [MODIFY_EXPR]: Likewise.
            [RETURN_EXPR]: Avoid producing 'return *retval;'.
            * call.c (build_call_a): Strip TARGET_EXPR from empty class arg.
            * cp-tree.h (SIMPLE_TARGET_EXPR_P): Check that TARGET_EXPR_INITIAL
            is non-null.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/94175] [10 Regression] Passing constexpr empty class variable to function since r10-599
  2020-03-14 12:49 [Bug c++/94175] New: [10 Regression] Passing constexpr empty class variable to function since r10-599 jakub at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2020-03-20  3:54 ` cvs-commit at gcc dot gnu.org
@ 2020-03-20  4:04 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2020-03-20  4:04 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #2)
> But for #c1 it is just a missed-optimization, while if the passing of a
> constexpr var to a function isn't an ODR use, isn't it then a standard
> violation that we aren't optimizing the variable read into its value?

True, but the fix is the same.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-03-20  4:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-14 12:49 [Bug c++/94175] New: [10 Regression] Passing constexpr empty class variable to function since r10-599 jakub at gcc dot gnu.org
2020-03-14 12:50 ` [Bug c++/94175] " jakub at gcc dot gnu.org
2020-03-17 12:14 ` jakub at gcc dot gnu.org
2020-03-19 14:32 ` jason at gcc dot gnu.org
2020-03-19 14:48 ` jason at gcc dot gnu.org
2020-03-19 15:08 ` jakub at gcc dot gnu.org
2020-03-20  3:54 ` cvs-commit at gcc dot gnu.org
2020-03-20  4:04 ` jason at gcc dot gnu.org

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).