@@ -1425,6 +1425,7 @@ OBJS = \
omp-grid.o \
omp-low.o \
omp-simd-clone.o \
+ opt-problem.o \
optabs.o \
optabs-libfuncs.o \
optabs-query.o \
new file mode 100644
@@ -0,0 +1,96 @@
+/* Rich information on why an optimization wasn't possible.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ Contributed by David Malcolm <dmalcolm@redhat.com>.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+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/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "backend.h"
+#include "diagnostic.h"
+#include "tree.h"
+#include "gimple.h"
+#include "pretty-print.h"
+#include "gimple-pretty-print.h"
+#include "opt-problem.h"
+
+/* Emit a remark about an optimization. */
+
+bool
+opt_report::remark (dump_location_t loc, const char *gmsgid, ...)
+{
+ if (!flag_remarks)
+ return false;
+
+ va_list ap;
+ va_start (ap, gmsgid);
+ bool ret = emit_diagnostic_valist (DK_REMARK, loc.get_location_t (), -1,
+ gmsgid, &ap);
+ va_end (ap);
+
+ // FIXME: how should this interact with optinfo? (we don't want a duplicate remark)
+ return ret;
+}
+
+/* Emit a note about an optimization. */
+
+bool
+opt_report::note (dump_location_t loc, const char *gmsgid, ...)
+{
+ va_list ap;
+ va_start (ap, gmsgid);
+ bool ret = emit_diagnostic_valist (DK_NOTE, loc.get_location_t (), -1,
+ gmsgid, &ap);
+ va_end (ap);
+
+ // FIXME: how should this interact with optinfo? (we don't want a duplicate note)
+ return ret;
+}
+
+opt_problem *opt_problem::s_the_problem;
+
+// FIXME: some refactoring is needed, based on exactly where remarks land,
+// and how this interacts with the optinfo stuff. For now, this decl:
+
+extern void
+print_impl_location (pretty_printer *pp, const dump_impl_location_t &impl_loc);
+
+/* Emit a diagnostic note describing why an optimization wasn't possible. */
+
+void
+opt_problem::report_reason (opt_report &report)
+{
+ bool show_color = pp_show_color (global_dc->printer);
+
+ pretty_printer pp;
+ pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_string (&pp, m_text);
+ if (m_stmt)
+ {
+ pp_string (&pp, ": ");
+ pp_begin_quote (&pp, show_color);
+ pp_gimple_stmt_1 (&pp, m_stmt, 0, TDF_SLIM);
+ pp_end_quote (&pp, show_color);
+ }
+
+ print_impl_location (&pp, m_location.get_impl_location ());
+
+ const char *msg = pp_formatted_text (&pp);
+
+ report.note (m_location, "%s", msg);
+}