aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2024-08-29 18:48:16 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2024-08-29 18:48:16 -0400
commit464a3d2fe53362281eba123c3099346f625edd58 (patch)
treeb3429ce6f82dbc7a670e4c5a4a1752786837e072 /gcc
parent6bfeba12c86b4d0dae27d99b484f64774dd49398 (diff)
downloadgcc-464a3d2fe53362281eba123c3099346f625edd58.zip
gcc-464a3d2fe53362281eba123c3099346f625edd58.tar.gz
gcc-464a3d2fe53362281eba123c3099346f625edd58.tar.bz2
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>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/aarch64/aarch64.cc1
-rw-r--r--gcc/config/arm/arm.cc1
-rw-r--r--gcc/config/i386/i386.cc1
-rw-r--r--gcc/config/loongarch/loongarch.cc1
-rw-r--r--gcc/config/riscv/riscv-vector-costs.cc1
-rw-r--r--gcc/config/riscv/riscv.cc1
-rw-r--r--gcc/config/rs6000/rs6000.cc1
-rw-r--r--gcc/dump-context.h7
-rw-r--r--gcc/dumpfile.cc156
-rw-r--r--gcc/gimple-loop-interchange.cc1
-rw-r--r--gcc/gimple-loop-jam.cc1
-rw-r--r--gcc/gimple-loop-versioning.cc1
-rw-r--r--gcc/graphite-dependences.cc1
-rw-r--r--gcc/graphite-isl-ast-to-gimple.cc1
-rw-r--r--gcc/graphite-optimize-isl.cc1
-rw-r--r--gcc/graphite-poly.cc1
-rw-r--r--gcc/graphite-scop-detection.cc1
-rw-r--r--gcc/graphite-sese-to-poly.cc1
-rw-r--r--gcc/graphite.cc1
-rw-r--r--gcc/opt-problem.cc1
-rw-r--r--gcc/optinfo.cc8
-rw-r--r--gcc/optinfo.h11
-rw-r--r--gcc/sese.cc1
-rw-r--r--gcc/targhooks.cc1
-rw-r--r--gcc/testsuite/gcc.dg/plugin/dump_plugin.c1
-rw-r--r--gcc/tree-data-ref.cc1
-rw-r--r--gcc/tree-if-conv.cc1
-rw-r--r--gcc/tree-loop-distribution.cc1
-rw-r--r--gcc/tree-parloops.cc1
-rw-r--r--gcc/tree-predcom.cc1
-rw-r--r--gcc/tree-ssa-live.cc1
-rw-r--r--gcc/tree-ssa-loop-ivcanon.cc1
-rw-r--r--gcc/tree-ssa-loop-ivopts.cc1
-rw-r--r--gcc/tree-ssa-loop-prefetch.cc1
-rw-r--r--gcc/tree-ssa-loop-unswitch.cc1
-rw-r--r--gcc/tree-ssa-phiopt.cc1
-rw-r--r--gcc/tree-ssa-threadbackward.cc1
-rw-r--r--gcc/tree-ssa-threadupdate.cc1
-rw-r--r--gcc/tree-vect-data-refs.cc1
-rw-r--r--gcc/tree-vect-generic.cc1
-rw-r--r--gcc/tree-vect-loop-manip.cc1
-rw-r--r--gcc/tree-vect-loop.cc1
-rw-r--r--gcc/tree-vect-patterns.cc1
-rw-r--r--gcc/tree-vect-slp-patterns.cc1
-rw-r--r--gcc/tree-vect-slp.cc1
-rw-r--r--gcc/tree-vect-stmts.cc1
-rw-r--r--gcc/tree-vectorizer.cc1
47 files changed, 137 insertions, 88 deletions
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 033ea61..27e24ba 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -22,6 +22,7 @@
#define INCLUDE_STRING
#define INCLUDE_ALGORITHM
+#define INCLUDE_MEMORY
#define INCLUDE_VECTOR
#include "config.h"
#include "system.h"
diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index d54564a..1748544 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -23,6 +23,7 @@
#define IN_TARGET_CODE 1
#include "config.h"
+#define INCLUDE_MEMORY
#define INCLUDE_STRING
#include "system.h"
#include "coretypes.h"
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 224a78c..a1f65d4 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -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
diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
index c7a0210..f956ee4 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -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"
diff --git a/gcc/config/riscv/riscv-vector-costs.cc b/gcc/config/riscv/riscv-vector-costs.cc
index a80e167..25570bd 100644
--- a/gcc/config/riscv/riscv-vector-costs.cc
+++ b/gcc/config/riscv/riscv-vector-costs.cc
@@ -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"
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 3f5dfb8..496dd17 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -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"
diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 94c0db4..08579bc 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -22,6 +22,7 @@
#define IN_TARGET_CODE 1
#include "config.h"
+#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "backend.h"
diff --git a/gcc/dump-context.h b/gcc/dump-context.h
index b2aed28..5992956 100644
--- a/gcc/dump-context.h
+++ b/gcc/dump-context.h
@@ -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;
diff --git a/gcc/dumpfile.cc b/gcc/dumpfile.cc
index 6353c08..2971c69 100644
--- a/gcc/dumpfile.cc
+++ b/gcc/dumpfile.cc
@@ -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. */
diff --git a/gcc/gimple-loop-interchange.cc b/gcc/gimple-loop-interchange.cc
index b422804..a4ea818 100644
--- a/gcc/gimple-loop-interchange.cc
+++ b/gcc/gimple-loop-interchange.cc
@@ -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"
diff --git a/gcc/gimple-loop-jam.cc b/gcc/gimple-loop-jam.cc
index 306d5ce..bf01e0b 100644
--- a/gcc/gimple-loop-jam.cc
+++ b/gcc/gimple-loop-jam.cc
@@ -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"
diff --git a/gcc/gimple-loop-versioning.cc b/gcc/gimple-loop-versioning.cc
index adea207..107b002 100644
--- a/gcc/gimple-loop-versioning.cc
+++ b/gcc/gimple-loop-versioning.cc
@@ -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"
diff --git a/gcc/graphite-dependences.cc b/gcc/graphite-dependences.cc
index a35f712..41e1114 100644
--- a/gcc/graphite-dependences.cc
+++ b/gcc/graphite-dependences.cc
@@ -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"
diff --git a/gcc/graphite-isl-ast-to-gimple.cc b/gcc/graphite-isl-ast-to-gimple.cc
index a27402b..ff539b1 100644
--- a/gcc/graphite-isl-ast-to-gimple.cc
+++ b/gcc/graphite-isl-ast-to-gimple.cc
@@ -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"
diff --git a/gcc/graphite-optimize-isl.cc b/gcc/graphite-optimize-isl.cc
index 2222dd6..ff3dd6b 100644
--- a/gcc/graphite-optimize-isl.cc
+++ b/gcc/graphite-optimize-isl.cc
@@ -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"
diff --git a/gcc/graphite-poly.cc b/gcc/graphite-poly.cc
index c78ff98..76aba03 100644
--- a/gcc/graphite-poly.cc
+++ b/gcc/graphite-poly.cc
@@ -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"
diff --git a/gcc/graphite-scop-detection.cc b/gcc/graphite-scop-detection.cc
index 9e44f10..de7c111 100644
--- a/gcc/graphite-scop-detection.cc
+++ b/gcc/graphite-scop-detection.cc
@@ -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"
diff --git a/gcc/graphite-sese-to-poly.cc b/gcc/graphite-sese-to-poly.cc
index 5ce8985..1e7818a 100644
--- a/gcc/graphite-sese-to-poly.cc
+++ b/gcc/graphite-sese-to-poly.cc
@@ -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"
diff --git a/gcc/graphite.cc b/gcc/graphite.cc
index 80e6a5d..65b970f 100644
--- a/gcc/graphite.cc
+++ b/gcc/graphite.cc
@@ -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"
diff --git a/gcc/opt-problem.cc b/gcc/opt-problem.cc
index f40f481..d76ddaf 100644
--- a/gcc/opt-problem.cc
+++ b/gcc/opt-problem.cc
@@ -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"
diff --git a/gcc/optinfo.cc b/gcc/optinfo.cc
index 7a82561..48a270cbf 100644
--- a/gcc/optinfo.cc
+++ b/gcc/optinfo.cc
@@ -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);
diff --git a/gcc/optinfo.h b/gcc/optinfo.h
index 986ef75..db92294 100644
--- a/gcc/optinfo.h
+++ b/gcc/optinfo.h
@@ -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;
diff --git a/gcc/sese.cc b/gcc/sese.cc
index e5c4605..e9b17fa 100644
--- a/gcc/sese.cc
+++ b/gcc/sese.cc
@@ -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"
diff --git a/gcc/targhooks.cc b/gcc/targhooks.cc
index 793932a..dc040df 100644
--- a/gcc/targhooks.cc
+++ b/gcc/targhooks.cc
@@ -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"
diff --git a/gcc/testsuite/gcc.dg/plugin/dump_plugin.c b/gcc/testsuite/gcc.dg/plugin/dump_plugin.c
index 12573d6..fc76d69 100644
--- a/gcc/testsuite/gcc.dg/plugin/dump_plugin.c
+++ b/gcc/testsuite/gcc.dg/plugin/dump_plugin.c
@@ -1,5 +1,6 @@
/* Plugin for testing dumpfile.c. */
+#define INCLUDE_MEMORY
#include "gcc-plugin.h"
#include "config.h"
#include "system.h"
diff --git a/gcc/tree-data-ref.cc b/gcc/tree-data-ref.cc
index bd61069..48798f4 100644
--- a/gcc/tree-data-ref.cc
+++ b/gcc/tree-data-ref.cc
@@ -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"
diff --git a/gcc/tree-if-conv.cc b/gcc/tree-if-conv.cc
index 735e477..0346a13 100644
--- a/gcc/tree-if-conv.cc
+++ b/gcc/tree-if-conv.cc
@@ -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"
diff --git a/gcc/tree-loop-distribution.cc b/gcc/tree-loop-distribution.cc
index 10f261a..f0430ed 100644
--- a/gcc/tree-loop-distribution.cc
+++ b/gcc/tree-loop-distribution.cc
@@ -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"
diff --git a/gcc/tree-parloops.cc b/gcc/tree-parloops.cc
index 888a834f..f446865 100644
--- a/gcc/tree-parloops.cc
+++ b/gcc/tree-parloops.cc
@@ -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"
diff --git a/gcc/tree-predcom.cc b/gcc/tree-predcom.cc
index 9844fee..eed878b 100644
--- a/gcc/tree-predcom.cc
+++ b/gcc/tree-predcom.cc
@@ -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"
diff --git a/gcc/tree-ssa-live.cc b/gcc/tree-ssa-live.cc
index 60dfc05..0739faa 100644
--- a/gcc/tree-ssa-live.cc
+++ b/gcc/tree-ssa-live.cc
@@ -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"
diff --git a/gcc/tree-ssa-loop-ivcanon.cc b/gcc/tree-ssa-loop-ivcanon.cc
index 5ef24a9..a8d25ad 100644
--- a/gcc/tree-ssa-loop-ivcanon.cc
+++ b/gcc/tree-ssa-loop-ivcanon.cc
@@ -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"
diff --git a/gcc/tree-ssa-loop-ivopts.cc b/gcc/tree-ssa-loop-ivopts.cc
index c3218a3..dfe1b254 100644
--- a/gcc/tree-ssa-loop-ivopts.cc
+++ b/gcc/tree-ssa-loop-ivopts.cc
@@ -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"
diff --git a/gcc/tree-ssa-loop-prefetch.cc b/gcc/tree-ssa-loop-prefetch.cc
index bb5d5de..52ea3ba 100644
--- a/gcc/tree-ssa-loop-prefetch.cc
+++ b/gcc/tree-ssa-loop-prefetch.cc
@@ -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"
diff --git a/gcc/tree-ssa-loop-unswitch.cc b/gcc/tree-ssa-loop-unswitch.cc
index 14b0df1..7601d91 100644
--- a/gcc/tree-ssa-loop-unswitch.cc
+++ b/gcc/tree-ssa-loop-unswitch.cc
@@ -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"
diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index 95bac33..9a009e1 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -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"
diff --git a/gcc/tree-ssa-threadbackward.cc b/gcc/tree-ssa-threadbackward.cc
index ea8d7b8..4bc72ec 100644
--- a/gcc/tree-ssa-threadbackward.cc
+++ b/gcc/tree-ssa-threadbackward.cc
@@ -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"
diff --git a/gcc/tree-ssa-threadupdate.cc b/gcc/tree-ssa-threadupdate.cc
index fa61ba9..c88cc1d 100644
--- a/gcc/tree-ssa-threadupdate.cc
+++ b/gcc/tree-ssa-threadupdate.cc
@@ -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"
diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc
index 5b0d548..fe7fdec 100644
--- a/gcc/tree-vect-data-refs.cc
+++ b/gcc/tree-vect-data-refs.cc
@@ -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"
diff --git a/gcc/tree-vect-generic.cc b/gcc/tree-vect-generic.cc
index 4bcab71..3041fb8 100644
--- a/gcc/tree-vect-generic.cc
+++ b/gcc/tree-vect-generic.cc
@@ -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"
diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc
index 57dbcbe..cb7843f 100644
--- a/gcc/tree-vect-loop-manip.cc
+++ b/gcc/tree-vect-loop-manip.cc
@@ -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"
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 6456220..1fb7bbd 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -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"
diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index 9158af9..3162250 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -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"
diff --git a/gcc/tree-vect-slp-patterns.cc b/gcc/tree-vect-slp-patterns.cc
index 4a582ec..8adae8a 100644
--- a/gcc/tree-vect-slp-patterns.cc
+++ b/gcc/tree-vect-slp-patterns.cc
@@ -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"
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index fe49811..cfdf59a 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -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"
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 9eb73a5..03c65f0 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -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"
diff --git a/gcc/tree-vectorizer.cc b/gcc/tree-vectorizer.cc
index 1fb4fb3..0efabcb 100644
--- a/gcc/tree-vectorizer.cc
+++ b/gcc/tree-vectorizer.cc
@@ -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"