+2018-07-24 David Malcolm <dmalcolm@redhat.com>
+
+ PR tree-optimization/86636
+ * json.cc (json::object::set): Fix comment. Add assertions.
+ (json::array::append): Move here from json.h. Add comment and an
+ assertion.
+ (json::string::string): Likewise.
+ * json.h (json::array::append): Move to json.cc.
+ (json::string::string): Likewise.
+ * optinfo-emit-json.cc
+ (optrecord_json_writer::impl_location_to_json): Assert that we
+ aren't attempting to write out UNKNOWN_LOCATION, or an ad-hoc
+ wrapper around it. Expand the location once, rather than three
+ times.
+ (optrecord_json_writer::inlining_chain_to_json): Fix the check for
+ UNKNOWN_LOCATION, to use LOCATION_LOCUS to look through ad-hoc
+ wrappers.
+ (optrecord_json_writer::optinfo_to_json): Likewise, in four
+ places. Fix some overlong lines.
+
2018-07-24 Matthew Malcomson <matthew.malcomson@arm.com>
* config/aarch64/aarch64-simd.md
pp_character (pp, '}');
}
-/* Set the json::value * for KEY, taking ownership of VALUE
+/* Set the json::value * for KEY, taking ownership of V
(and taking a copy of KEY if necessary). */
void
object::set (const char *key, value *v)
{
+ gcc_assert (key);
+ gcc_assert (v);
+
value **ptr = m_map.get (key);
if (ptr)
{
pp_character (pp, ']');
}
+/* Append non-NULL value V to a json::array, taking ownership of V. */
+
+void
+array::append (value *v)
+{
+ gcc_assert (v);
+ m_elements.safe_push (v);
+}
+
/* class json::number, a subclass of json::value, wrapping a double. */
/* Implementation of json::value::print for json::number. */
/* class json::string, a subclass of json::value. */
+/* json::string's ctor. */
+
+string::string (const char *utf8)
+{
+ gcc_assert (utf8);
+ m_utf8 = xstrdup (utf8);
+}
+
+/* Implementation of json::value::print for json::string. */
+
void
string::print (pretty_printer *pp) const
{
enum kind get_kind () const FINAL OVERRIDE { return JSON_ARRAY; }
void print (pretty_printer *pp) const FINAL OVERRIDE;
- void append (value *v) { m_elements.safe_push (v); }
+ void append (value *v);
private:
auto_vec<value *> m_elements;
class string : public value
{
public:
- string (const char *utf8) : m_utf8 (xstrdup (utf8)) {}
+ string (const char *utf8);
~string () { free (m_utf8); }
enum kind get_kind () const FINAL OVERRIDE { return JSON_STRING; }
json::object *
optrecord_json_writer::location_to_json (location_t loc)
{
+ gcc_assert (LOCATION_LOCUS (loc) != UNKNOWN_LOCATION);
+ expanded_location exploc = expand_location (loc);
json::object *obj = new json::object ();
- obj->set ("file", new json::string (LOCATION_FILE (loc)));
- obj->set ("line", new json::number (LOCATION_LINE (loc)));
- obj->set ("column", new json::number (LOCATION_COLUMN (loc)));
+ obj->set ("file", new json::string (exploc.file));
+ obj->set ("line", new json::number (exploc.line));
+ obj->set ("column", new json::number (exploc.column));
return obj;
}
const char *printable_name
= lang_hooks.decl_printable_name (fndecl, 2);
obj->set ("fndecl", new json::string (printable_name));
- if (*locus != UNKNOWN_LOCATION)
+ if (LOCATION_LOCUS (*locus) != UNKNOWN_LOCATION)
obj->set ("site", location_to_json (*locus));
array->append (obj);
}
json_item->set ("expr", new json::string (item->get_text ()));
/* Capture any location for the node. */
- if (item->get_location () != UNKNOWN_LOCATION)
- json_item->set ("location", location_to_json (item->get_location ()));
+ if (LOCATION_LOCUS (item->get_location ()) != UNKNOWN_LOCATION)
+ json_item->set ("location",
+ location_to_json (item->get_location ()));
message->append (json_item);
}
json_item->set ("stmt", new json::string (item->get_text ()));
/* Capture any location for the stmt. */
- if (item->get_location () != UNKNOWN_LOCATION)
- json_item->set ("location", location_to_json (item->get_location ()));
+ if (LOCATION_LOCUS (item->get_location ()) != UNKNOWN_LOCATION)
+ json_item->set ("location",
+ location_to_json (item->get_location ()));
message->append (json_item);
}
json_item->set ("symtab_node", new json::string (item->get_text ()));
/* Capture any location for the node. */
- if (item->get_location () != UNKNOWN_LOCATION)
- json_item->set ("location", location_to_json (item->get_location ()));
+ if (LOCATION_LOCUS (item->get_location ()) != UNKNOWN_LOCATION)
+ json_item->set ("location",
+ location_to_json (item->get_location ()));
message->append (json_item);
}
break;
+2018-07-24 David Malcolm <dmalcolm@redhat.com>
+
+ PR tree-optimization/86636
+ * gcc.c-torture/compile/pr86636.c: New test.
+
2018-07-24 Matthew Malcomson <matthew.malcomson@arm.com>
* gcc.target/aarch64/vect-su-add-sub.c: New.
--- /dev/null
+/* { dg-options "-fsave-optimization-record -ftree-loop-vectorize -ftree-parallelize-loops=2" } */
+
+void
+n2 (int ih)
+{
+ while (ih < 1)
+ ++ih;
+}