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

            Bug ID: 110846
           Summary: Noinline attribute on a destructor only honored when
                    on the member function declaration, does not wok on
                    definition
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jamborm at gcc dot gnu.org
  Target Milestone: ---

When noinline attribute on a destructor, it is honored:

---------- works.C ----------

void f ();

struct test
{
  test() {}
  [[gnu::noinline]]
  ~test() { f (); }
};

void
g ()
{
  test t;
}
-----------------------------

g++ -O3 -S works.C -fdump-tree-optimized
tail -15 works.C.257t.optimized

;; Function g (_Z1gv, funcdef_no=6, decl_uid=2810, cgraph_uid=7,
symbol_order=6)

void g ()
{
  struct test t;

  <bb 2> [local count: 1073741824]:
  test::~test (&t);
  t ={v} {CLOBBER(eol)};
  return;

}


But when it is just on the definition, it is not.

---------- doesnot.C ----------
void f ();

struct test
{
  test() {}
  ~test();
};

[[gnu::noinline]]
test::~test()
{
    f();
}

void
g ()
{
  test t;
}
-------------------------------

~/gcc/trunk/inst/bin/g++ -O3 -S doesnot.C -fdump-tree-optimized
cat doesnot.C.257t.optimized 

;; Function test::~test (_ZN4testD2Ev, funcdef_no=4, decl_uid=2799,
cgraph_uid=5, symbol_order=4)

__attribute__((noinline))
void test::~test (struct test * const this)
{
  <bb 2> [local count: 1073741824]:
  f ();
  return;

}



;; Function g (_Z1gv, funcdef_no=6, decl_uid=2814, cgraph_uid=7,
symbol_order=6)

void g ()
{
  <bb 2> [local count: 1073741824]:
  f ();
  return;

}


(Note that the attribute is present in the dump.)

Reply via email to