Use std::unique_ptr for optinfo_item

As preliminary work towards an overhaul of how optinfo_items
interact with dump_pretty_printer, replace uses of optinfo_item * with
std::unique_ptr<optinfo_item> to make ownership clearer.

No functional change intended.

gcc/ChangeLog:
	* config/aarch64/aarch64.cc: Define INCLUDE_MEMORY.
	* config/arm/arm.cc: Likewise.
	* config/i386/i386.cc: Likewise.
	* config/loongarch/loongarch.cc: Likewise.
	* config/riscv/riscv-vector-costs.cc: Likewise.
	* config/riscv/riscv.cc: Likewise.
	* config/rs6000/rs6000.cc: Likewise.
	* dump-context.h (dump_context::emit_item): Convert "item" param
	from * to const &.
	(dump_pretty_printer::stash_item): Convert "item" param from
	optinfo_ * to std::unique_ptr<optinfo_item>.
	(dump_pretty_printer::emit_item): Likewise.
	* dumpfile.cc: Include "make-unique.h".
	(make_item_for_dump_gimple_stmt): Replace uses of optinfo_item *
	with std::unique_ptr<optinfo_item>.
	(dump_context::dump_gimple_stmt): Likewise.
	(make_item_for_dump_gimple_expr): Likewise.
	(dump_context::dump_gimple_expr): Likewise.
	(make_item_for_dump_generic_expr): Likewise.
	(dump_context::dump_generic_expr): Likewise.
	(make_item_for_dump_symtab_node): Likewise.
	(dump_pretty_printer::emit_items): Likewise.
	(dump_pretty_printer::emit_any_pending_textual_chunks): Likewise.
	(dump_pretty_printer::emit_item): Likewise.
	(dump_pretty_printer::stash_item): Likewise.
	(dump_pretty_printer::decode_format): Likewise.
	(dump_context::dump_printf_va): Fix overlong line.
	(make_item_for_dump_dec): Replace uses of optinfo_item * with
	std::unique_ptr<optinfo_item>.
	(dump_context::dump_dec): Likewise.
	(dump_context::dump_symtab_node): Likewise.
	(dump_context::begin_scope): Likewise.
	(dump_context::emit_item): Likewise.
	* gimple-loop-interchange.cc: Define INCLUDE_MEMORY.
	* gimple-loop-jam.cc: Likewise.
	* gimple-loop-versioning.cc: Likewise.
	* graphite-dependences.cc: Likewise.
	* graphite-isl-ast-to-gimple.cc: Likewise.
	* graphite-optimize-isl.cc: Likewise.
	* graphite-poly.cc: Likewise.
	* graphite-scop-detection.cc: Likewise.
	* graphite-sese-to-poly.cc: Likewise.
	* graphite.cc: Likewise.
	* opt-problem.cc: Likewise.
	* optinfo.cc (optinfo::add_item): Convert "item" param from
	optinfo_ * to std::unique_ptr<optinfo_item>.
	(optinfo::emit_for_opt_problem): Update for change to
	dump_context::emit_item.
	* optinfo.h: Add #error to fail immediately if INCLUDE_MEMORY
	wasn't defined, rather than fail to find std::unique_ptr.
	(optinfo::add_item): Convert "item" param from optinfo_ * to
	std::unique_ptr<optinfo_item>.
	* sese.cc: Define INCLUDE_MEMORY.
	* targhooks.cc: Likewise.
	* tree-data-ref.cc: Likewise.
	* tree-if-conv.cc: Likewise.
	* tree-loop-distribution.cc: Likewise.
	* tree-parloops.cc: Likewise.
	* tree-predcom.cc: Likewise.
	* tree-ssa-live.cc: Likewise.
	* tree-ssa-loop-ivcanon.cc: Likewise.
	* tree-ssa-loop-ivopts.cc: Likewise.
	* tree-ssa-loop-prefetch.cc: Likewise.
	* tree-ssa-loop-unswitch.cc: Likewise.
	* tree-ssa-phiopt.cc: Likewise.
	* tree-ssa-threadbackward.cc: Likewise.
	* tree-ssa-threadupdate.cc: Likewise.
	* tree-vect-data-refs.cc: Likewise.
	* tree-vect-generic.cc: Likewise.
	* tree-vect-loop-manip.cc: Likewise.
	* tree-vect-loop.cc: Likewise.
	* tree-vect-patterns.cc: Likewise.
	* tree-vect-slp-patterns.cc: Likewise.
	* tree-vect-slp.cc: Likewise.
	* tree-vect-stmts.cc: Likewise.
	* tree-vectorizer.cc: Likewise.

gcc/testsuite/ChangeLog:
	* gcc.dg/plugin/dump_plugin.c: Define INCLUDE_MEMORY.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
This commit is contained in:
David Malcolm 2024-08-29 18:48:16 -04:00
parent 6bfeba12c8
commit 464a3d2fe5
47 changed files with 137 additions and 88 deletions

View file

@ -22,6 +22,7 @@
#define INCLUDE_STRING
#define INCLUDE_ALGORITHM
#define INCLUDE_MEMORY
#define INCLUDE_VECTOR
#include "config.h"
#include "system.h"

View file

@ -23,6 +23,7 @@
#define IN_TARGET_CODE 1
#include "config.h"
#define INCLUDE_MEMORY
#define INCLUDE_STRING
#include "system.h"
#include "coretypes.h"

View file

@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#define INCLUDE_MEMORY
#define INCLUDE_STRING
#define IN_TARGET_CODE 1

View file

@ -21,6 +21,7 @@ along with GCC; see the file COPYING3. If not see
#define IN_TARGET_CODE 1
#define INCLUDE_MEMORY
#include "config.h"
#include "system.h"
#include "coretypes.h"

View file

@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see
#define IN_TARGET_CODE 1
#define INCLUDE_MEMORY
#define INCLUDE_STRING
#include "config.h"
#include "system.h"

View file

@ -21,6 +21,7 @@ along with GCC; see the file COPYING3. If not see
#define IN_TARGET_CODE 1
#define INCLUDE_MEMORY
#define INCLUDE_STRING
#include "config.h"
#include "system.h"

View file

@ -22,6 +22,7 @@
#define IN_TARGET_CODE 1
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -120,7 +120,7 @@ class dump_context
void end_any_optinfo ();
void emit_optinfo (const optinfo *info);
void emit_item (optinfo_item *item, dump_flags_t dump_kind);
void emit_item (const optinfo_item &item, dump_flags_t dump_kind);
bool apply_dump_filter_p (dump_flags_t dump_kind, dump_flags_t filter) const;
@ -186,11 +186,12 @@ private:
bool decode_format (text_info *text, const char *spec,
const char **buffer_ptr);
void stash_item (const char **buffer_ptr, optinfo_item *item);
void stash_item (const char **buffer_ptr,
std::unique_ptr<optinfo_item> item);
void emit_any_pending_textual_chunks (optinfo *dest);
void emit_item (optinfo_item *item, optinfo *dest);
void emit_item (std::unique_ptr<optinfo_item> item, optinfo *dest);
dump_context *m_context;
dump_flags_t m_dump_kind;

View file

@ -41,6 +41,7 @@ along with GCC; see the file COPYING3. If not see
#include "optinfo-emit-json.h"
#include "stringpool.h" /* for get_identifier. */
#include "spellcheck.h"
#include "make-unique.h"
/* If non-NULL, return one past-the-end of the matching SUBPART of
the WHOLE string. */
@ -628,7 +629,7 @@ dump_context::dump_loc_immediate (dump_flags_t dump_kind,
/* Make an item for the given dump call, equivalent to print_gimple_stmt. */
static optinfo_item *
static std::unique_ptr<optinfo_item>
make_item_for_dump_gimple_stmt (gimple *stmt, int spc, dump_flags_t dump_flags)
{
pretty_printer pp;
@ -636,9 +637,10 @@ make_item_for_dump_gimple_stmt (gimple *stmt, int spc, dump_flags_t dump_flags)
pp_gimple_stmt_1 (&pp, stmt, spc, dump_flags);
pp_newline (&pp);
optinfo_item *item
= new optinfo_item (OPTINFO_ITEM_KIND_GIMPLE, gimple_location (stmt),
xstrdup (pp_formatted_text (&pp)));
std::unique_ptr<optinfo_item> item
= make_unique<optinfo_item> (OPTINFO_ITEM_KIND_GIMPLE,
gimple_location (stmt),
xstrdup (pp_formatted_text (&pp)));
return item;
}
@ -650,17 +652,15 @@ dump_context::dump_gimple_stmt (const dump_metadata_t &metadata,
dump_flags_t extra_dump_flags,
gimple *gs, int spc)
{
optinfo_item *item
auto item
= make_item_for_dump_gimple_stmt (gs, spc, dump_flags | extra_dump_flags);
emit_item (item, metadata.get_dump_flags ());
emit_item (*item.get (), metadata.get_dump_flags ());
if (optinfo_enabled_p ())
{
optinfo &info = ensure_pending_optinfo (metadata);
info.add_item (item);
info.add_item (std::move (item));
}
else
delete item;
}
/* Similar to dump_gimple_stmt, except additionally print source location. */
@ -677,7 +677,7 @@ dump_context::dump_gimple_stmt_loc (const dump_metadata_t &metadata,
/* Make an item for the given dump call, equivalent to print_gimple_expr. */
static optinfo_item *
static std::unique_ptr<optinfo_item>
make_item_for_dump_gimple_expr (gimple *stmt, int spc, dump_flags_t dump_flags)
{
dump_flags |= TDF_RHS_ONLY;
@ -685,9 +685,10 @@ make_item_for_dump_gimple_expr (gimple *stmt, int spc, dump_flags_t dump_flags)
pp_needs_newline (&pp) = true;
pp_gimple_stmt_1 (&pp, stmt, spc, dump_flags);
optinfo_item *item
= new optinfo_item (OPTINFO_ITEM_KIND_GIMPLE, gimple_location (stmt),
xstrdup (pp_formatted_text (&pp)));
std::unique_ptr<optinfo_item> item
= make_unique<optinfo_item> (OPTINFO_ITEM_KIND_GIMPLE,
gimple_location (stmt),
xstrdup (pp_formatted_text (&pp)));
return item;
}
@ -700,17 +701,15 @@ dump_context::dump_gimple_expr (const dump_metadata_t &metadata,
dump_flags_t extra_dump_flags,
gimple *gs, int spc)
{
optinfo_item *item
std::unique_ptr<optinfo_item> item
= make_item_for_dump_gimple_expr (gs, spc, dump_flags | extra_dump_flags);
emit_item (item, metadata.get_dump_flags ());
emit_item (*item.get (), metadata.get_dump_flags ());
if (optinfo_enabled_p ())
{
optinfo &info = ensure_pending_optinfo (metadata);
info.add_item (item);
info.add_item (std::move (item));
}
else
delete item;
}
/* Similar to dump_gimple_expr, except additionally print source location. */
@ -728,7 +727,7 @@ dump_context::dump_gimple_expr_loc (const dump_metadata_t &metadata,
/* Make an item for the given dump call, equivalent to print_generic_expr. */
static optinfo_item *
static std::unique_ptr<optinfo_item>
make_item_for_dump_generic_expr (tree node, dump_flags_t dump_flags)
{
pretty_printer pp;
@ -740,9 +739,9 @@ make_item_for_dump_generic_expr (tree node, dump_flags_t dump_flags)
if (EXPR_HAS_LOCATION (node))
loc = EXPR_LOCATION (node);
optinfo_item *item
= new optinfo_item (OPTINFO_ITEM_KIND_TREE, loc,
xstrdup (pp_formatted_text (&pp)));
std::unique_ptr<optinfo_item> item
= make_unique<optinfo_item> (OPTINFO_ITEM_KIND_TREE, loc,
xstrdup (pp_formatted_text (&pp)));
return item;
}
@ -754,17 +753,15 @@ dump_context::dump_generic_expr (const dump_metadata_t &metadata,
dump_flags_t extra_dump_flags,
tree t)
{
optinfo_item *item
std::unique_ptr<optinfo_item> item
= make_item_for_dump_generic_expr (t, dump_flags | extra_dump_flags);
emit_item (item, metadata.get_dump_flags ());
emit_item (*item.get (), metadata.get_dump_flags ());
if (optinfo_enabled_p ())
{
optinfo &info = ensure_pending_optinfo (metadata);
info.add_item (item);
info.add_item (std::move (item));
}
else
delete item;
}
@ -783,13 +780,13 @@ dump_context::dump_generic_expr_loc (const dump_metadata_t &metadata,
/* Make an item for the given dump call. */
static optinfo_item *
static std::unique_ptr<optinfo_item>
make_item_for_dump_symtab_node (symtab_node *node)
{
location_t loc = DECL_SOURCE_LOCATION (node->decl);
optinfo_item *item
= new optinfo_item (OPTINFO_ITEM_KIND_SYMTAB_NODE, loc,
xstrdup (node->dump_name ()));
std::unique_ptr<optinfo_item> item
= make_unique<optinfo_item> (OPTINFO_ITEM_KIND_SYMTAB_NODE, loc,
xstrdup (node->dump_name ()));
return item;
}
@ -834,7 +831,9 @@ dump_pretty_printer::emit_items (optinfo *dest)
{
emit_any_pending_textual_chunks (dest);
/* This chunk has a stashed item: use it. */
emit_item (m_stashed_items[stashed_item_idx++].item, dest);
std::unique_ptr <optinfo_item> item
(m_stashed_items[stashed_item_idx++].item);
emit_item (std::move (item), dest);
}
else
/* This chunk is purely textual. Print it (to
@ -866,10 +865,10 @@ dump_pretty_printer::emit_any_pending_textual_chunks (optinfo *dest)
return;
char *formatted_text = xstrdup (pp_formatted_text (this));
optinfo_item *item
= new optinfo_item (OPTINFO_ITEM_KIND_TEXT, UNKNOWN_LOCATION,
formatted_text);
emit_item (item, dest);
std::unique_ptr<optinfo_item> item
= make_unique<optinfo_item> (OPTINFO_ITEM_KIND_TEXT, UNKNOWN_LOCATION,
formatted_text);
emit_item (std::move (item), dest);
/* Clear the pending text by unwinding formatted_text back to the start
of the buffer (without deallocating). */
@ -881,25 +880,25 @@ dump_pretty_printer::emit_any_pending_textual_chunks (optinfo *dest)
to DEST; otherwise delete ITEM. */
void
dump_pretty_printer::emit_item (optinfo_item *item, optinfo *dest)
dump_pretty_printer::emit_item (std::unique_ptr<optinfo_item> item,
optinfo *dest)
{
m_context->emit_item (item, m_dump_kind);
m_context->emit_item (*item.get (), m_dump_kind);
if (dest)
dest->add_item (item);
else
delete item;
dest->add_item (std::move (item));
}
/* Record that ITEM (generated in phase 2 of formatting) is to be used for
the chunk at BUFFER_PTR in phase 3 (by emit_items). */
void
dump_pretty_printer::stash_item (const char **buffer_ptr, optinfo_item *item)
dump_pretty_printer::stash_item (const char **buffer_ptr,
std::unique_ptr<optinfo_item> item)
{
gcc_assert (buffer_ptr);
gcc_assert (item);
gcc_assert (item.get ());
m_stashed_items.safe_push (stashed_item (buffer_ptr, item));
m_stashed_items.safe_push (stashed_item (buffer_ptr, item.release ()));
}
/* pp_format_decoder callback for dump_pretty_printer, and thus for
@ -953,8 +952,8 @@ dump_pretty_printer::decode_format (text_info *text, const char *spec,
cgraph_node *node = va_arg (*text->m_args_ptr, cgraph_node *);
/* Make an item for the node, and stash it. */
optinfo_item *item = make_item_for_dump_symtab_node (node);
stash_item (buffer_ptr, item);
auto item = make_item_for_dump_symtab_node (node);
stash_item (buffer_ptr, std::move (item));
return true;
}
@ -963,8 +962,8 @@ dump_pretty_printer::decode_format (text_info *text, const char *spec,
gimple *stmt = va_arg (*text->m_args_ptr, gimple *);
/* Make an item for the stmt, and stash it. */
optinfo_item *item = make_item_for_dump_gimple_expr (stmt, 0, TDF_SLIM);
stash_item (buffer_ptr, item);
auto item = make_item_for_dump_gimple_expr (stmt, 0, TDF_SLIM);
stash_item (buffer_ptr, std::move (item));
return true;
}
@ -973,8 +972,8 @@ dump_pretty_printer::decode_format (text_info *text, const char *spec,
gimple *stmt = va_arg (*text->m_args_ptr, gimple *);
/* Make an item for the stmt, and stash it. */
optinfo_item *item = make_item_for_dump_gimple_stmt (stmt, 0, TDF_SLIM);
stash_item (buffer_ptr, item);
auto item = make_item_for_dump_gimple_stmt (stmt, 0, TDF_SLIM);
stash_item (buffer_ptr, std::move (item));
return true;
}
@ -983,8 +982,8 @@ dump_pretty_printer::decode_format (text_info *text, const char *spec,
tree t = va_arg (*text->m_args_ptr, tree);
/* Make an item for the tree, and stash it. */
optinfo_item *item = make_item_for_dump_generic_expr (t, TDF_SLIM);
stash_item (buffer_ptr, item);
auto item = make_item_for_dump_generic_expr (t, TDF_SLIM);
stash_item (buffer_ptr, std::move (item));
return true;
}
@ -996,7 +995,8 @@ dump_pretty_printer::decode_format (text_info *text, const char *spec,
/* Output a formatted message using FORMAT on appropriate dump streams. */
void
dump_context::dump_printf_va (const dump_metadata_t &metadata, const char *format,
dump_context::dump_printf_va (const dump_metadata_t &metadata,
const char *format,
va_list *ap)
{
dump_pretty_printer pp (this, metadata.get_dump_flags ());
@ -1031,7 +1031,7 @@ dump_context::dump_printf_loc_va (const dump_metadata_t &metadata,
/* Make an item for the given dump call, equivalent to print_dec. */
template<unsigned int N, typename C>
static optinfo_item *
static std::unique_ptr<optinfo_item>
make_item_for_dump_dec (const poly_int<N, C> &value)
{
STATIC_ASSERT (poly_coeff_traits<C>::signedness >= 0);
@ -1051,9 +1051,9 @@ make_item_for_dump_dec (const poly_int<N, C> &value)
}
}
optinfo_item *item
= new optinfo_item (OPTINFO_ITEM_KIND_TEXT, UNKNOWN_LOCATION,
xstrdup (pp_formatted_text (&pp)));
auto item
= make_unique<optinfo_item> (OPTINFO_ITEM_KIND_TEXT, UNKNOWN_LOCATION,
xstrdup (pp_formatted_text (&pp)));
return item;
}
@ -1061,35 +1061,33 @@ make_item_for_dump_dec (const poly_int<N, C> &value)
template<unsigned int N, typename C>
void
dump_context::dump_dec (const dump_metadata_t &metadata, const poly_int<N, C> &value)
dump_context::dump_dec (const dump_metadata_t &metadata,
const poly_int<N, C> &value)
{
optinfo_item *item = make_item_for_dump_dec (value);
emit_item (item, metadata.get_dump_flags ());
auto item = make_item_for_dump_dec (value);
emit_item (*item.get (), metadata.get_dump_flags ());
if (optinfo_enabled_p ())
{
optinfo &info = ensure_pending_optinfo (metadata);
info.add_item (item);
info.add_item (std::move (item));
}
else
delete item;
}
/* Output the name of NODE on appropriate dump streams. */
void
dump_context::dump_symtab_node (const dump_metadata_t &metadata, symtab_node *node)
dump_context::dump_symtab_node (const dump_metadata_t &metadata,
symtab_node *node)
{
optinfo_item *item = make_item_for_dump_symtab_node (node);
emit_item (item, metadata.get_dump_flags ());
auto item = make_item_for_dump_symtab_node (node);
emit_item (*item.get (), metadata.get_dump_flags ());
if (optinfo_enabled_p ())
{
optinfo &info = ensure_pending_optinfo (metadata);
info.add_item (item);
info.add_item (std::move (item));
}
else
delete item;
}
/* Get the current dump scope-nesting depth.
@ -1132,10 +1130,10 @@ dump_context::begin_scope (const char *name,
pretty_printer pp;
pp_printf (&pp, "%s %s %s", "===", name, "===");
pp_newline (&pp);
optinfo_item *item
= new optinfo_item (OPTINFO_ITEM_KIND_TEXT, UNKNOWN_LOCATION,
xstrdup (pp_formatted_text (&pp)));
emit_item (item, MSG_NOTE);
std::unique_ptr<optinfo_item> item
= make_unique<optinfo_item> (OPTINFO_ITEM_KIND_TEXT, UNKNOWN_LOCATION,
xstrdup (pp_formatted_text (&pp)));
emit_item (*item.get (), MSG_NOTE);
if (optinfo_enabled_p ())
{
@ -1143,11 +1141,9 @@ dump_context::begin_scope (const char *name,
= begin_next_optinfo (dump_metadata_t (MSG_NOTE, impl_location),
user_location);
info.m_kind = OPTINFO_KIND_SCOPE;
info.add_item (item);
info.add_item (std::move (item));
end_any_optinfo ();
}
else
delete item;
}
/* Pop a nested dump scope. */
@ -1226,17 +1222,17 @@ dump_context::emit_optinfo (const optinfo *info)
consolidation into optinfo instances). */
void
dump_context::emit_item (optinfo_item *item, dump_flags_t dump_kind)
dump_context::emit_item (const optinfo_item &item, dump_flags_t dump_kind)
{
if (dump_file && apply_dump_filter_p (dump_kind, pflags))
fprintf (dump_file, "%s", item->get_text ());
fprintf (dump_file, "%s", item.get_text ());
if (alt_dump_file && apply_dump_filter_p (dump_kind, alt_flags))
fprintf (alt_dump_file, "%s", item->get_text ());
fprintf (alt_dump_file, "%s", item.get_text ());
/* Support for temp_dump_context in selftests. */
if (m_test_pp && apply_dump_filter_p (dump_kind, m_test_pp_flags))
pp_string (m_test_pp, item->get_text ());
pp_string (m_test_pp, item.get_text ());
}
/* The current singleton dump_context, and its default. */

View file

@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -18,6 +18,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "tree-pass.h"

View file

@ -18,6 +18,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#define INCLUDE_ISL
#define INCLUDE_MEMORY
#include "config.h"

View file

@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#define INCLUDE_ISL
#define INCLUDE_MEMORY
#include "config.h"

View file

@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#define INCLUDE_ISL
#define INCLUDE_MEMORY
#include "config.h"

View file

@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#define INCLUDE_ISL
#define INCLUDE_MEMORY
#include "config.h"

View file

@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#define INCLUDE_ISL
#define INCLUDE_MEMORY
#include "config.h"

View file

@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#define INCLUDE_ISL
#define INCLUDE_MEMORY
#include "config.h"

View file

@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see
the related work. */
#define INCLUDE_ISL
#define INCLUDE_MEMORY
#include "config.h"
#include "system.h"

View file

@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -84,10 +84,10 @@ optinfo::~optinfo ()
/* Add ITEM to this optinfo. */
void
optinfo::add_item (optinfo_item *item)
optinfo::add_item (std::unique_ptr<optinfo_item> item)
{
gcc_assert (item);
m_items.safe_push (item);
gcc_assert (item.get ());
m_items.safe_push (item.release ());
}
/* Get MSG_* flags corresponding to KIND. */
@ -123,7 +123,7 @@ optinfo::emit_for_opt_problem () const
unsigned i;
optinfo_item *item;
FOR_EACH_VEC_ELT (m_items, i, item)
dump_context::get ().emit_item (item, dump_kind);
dump_context::get ().emit_item (*item, dump_kind);
/* Re-emit to "non-immediate" destinations. */
dump_context::get ().emit_optinfo (this);

View file

@ -21,6 +21,15 @@ along with GCC; see the file COPYING3. If not see
#ifndef GCC_OPTINFO_H
#define GCC_OPTINFO_H
/* This header uses std::unique_ptr, but <memory> can't be directly
included due to issues with macros. Hence <memory> must be included
from system.h by defining INCLUDE_MEMORY in any source file using
optinfo.h. */
#ifndef INCLUDE_MEMORY
# error "You must define INCLUDE_MEMORY before including system.h to use optinfo.h"
#endif
/* An "optinfo" is a bundle of information describing part of an
optimization, which can be emitted to zero or more of several
destinations, such as:
@ -119,7 +128,7 @@ class optinfo
location_t get_location_t () const { return m_loc.get_location_t (); }
profile_count get_count () const { return m_loc.get_count (); }
void add_item (optinfo_item *item);
void add_item (std::unique_ptr<optinfo_item> item);
void emit_for_opt_problem () const;

View file

@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -47,6 +47,7 @@ along with GCC; see the file COPYING3. If not see
comment can thus be removed at that point. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "target.h"

View file

@ -1,5 +1,6 @@
/* Plugin for testing dumpfile.c. */
#define INCLUDE_MEMORY
#include "gcc-plugin.h"
#include "config.h"
#include "system.h"

View file

@ -74,6 +74,7 @@ along with GCC; see the file COPYING3. If not see
*/
#define INCLUDE_ALGORITHM
#define INCLUDE_MEMORY
#include "config.h"
#include "system.h"
#include "coretypes.h"

View file

@ -81,6 +81,7 @@ along with GCC; see the file COPYING3. If not see
*/
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -90,6 +90,7 @@ along with GCC; see the file COPYING3. If not see
data reuse. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -205,6 +205,7 @@ along with GCC; see the file COPYING3. If not see
i * i with ii_last + 2 * i + 1), to generalize strength reduction. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -36,6 +36,7 @@ along with GCC; see the file COPYING3. If not see
info). */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -90,6 +90,7 @@ along with GCC; see the file COPYING3. If not see
profitable. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -18,6 +18,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -18,6 +18,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -18,6 +18,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -18,6 +18,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -18,6 +18,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -18,6 +18,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#define INCLUDE_ALGORITHM
#define INCLUDE_MEMORY
#include "config.h"
#include "system.h"
#include "coretypes.h"

View file

@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -18,6 +18,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -21,6 +21,7 @@ along with GCC; see the file COPYING3. If not see
#include "config.h"
#define INCLUDE_ALGORITHM
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"

View file

@ -55,6 +55,7 @@ along with GCC; see the file COPYING3. If not see
*/
#include "config.h"
#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"