Commit be40afb2 by David Malcolm Committed by David Malcolm

-fsave-optimization-record: compress the output using zlib

gcc/ChangeLog:
	* doc/invoke.texi (-fsave-optimization-record): Note that the
	output is compressed.
	* optinfo-emit-json.cc: Include <zlib.h>.
	(optrecord_json_writer::write): Compress the output.

From-SVN: r266078
parent f824e18c
2018-11-13 David Malcolm <dmalcolm@redhat.com>
* doc/invoke.texi (-fsave-optimization-record): Note that the
output is compressed.
* optinfo-emit-json.cc: Include <zlib.h>.
(optrecord_json_writer::write): Compress the output.
2018-11-13 Aldy Hernandez <aldyh@redhat.com>
* tree-vrp.c (value_range_base::dump): Dump type.
......@@ -14524,11 +14524,11 @@ dumps from the vectorizer about missed opportunities.
@item -fsave-optimization-record
@opindex fsave-optimization-record
Write a SRCFILE.opt-record.json file detailing what optimizations
Write a SRCFILE.opt-record.json.gz file detailing what optimizations
were performed, for those optimizations that support @option{-fopt-info}.
This option is experimental and the format of the data within the JSON
file is subject to change.
This option is experimental and the format of the data within the
compressed JSON file is subject to change.
It is roughly equivalent to a machine-readable version of
@option{-fopt-info-all}, as a collection of messages with source file,
......@@ -45,6 +45,7 @@ along with GCC; see the file COPYING3. If not see
#include "pass_manager.h"
#include "selftest.h"
#include "dump-context.h"
#include <zlib.h>
/* A class for writing out optimization records in JSON format. */
......@@ -133,16 +134,34 @@ optrecord_json_writer::~optrecord_json_writer ()
void
optrecord_json_writer::write () const
{
char *filename = concat (dump_base_name, ".opt-record.json", NULL);
FILE *outfile = fopen (filename, "w");
if (outfile)
pretty_printer pp;
m_root_tuple->print (&pp);
bool emitted_error = false;
char *filename = concat (dump_base_name, ".opt-record.json.gz", NULL);
gzFile outfile = gzopen (filename, "w");
if (outfile == NULL)
{
m_root_tuple->dump (outfile);
fclose (outfile);
error_at (UNKNOWN_LOCATION, "cannot open file %qs for writing optimization records",
filename); // FIXME: more info?
goto cleanup;
}
else
error_at (UNKNOWN_LOCATION, "unable to write optimization records to %qs",
filename); // FIXME: more info?
if (gzputs (outfile, pp_formatted_text (&pp)) <= 0)
{
int tmp;
error_at (UNKNOWN_LOCATION, "error writing optimization records to %qs: %s",
filename, gzerror (outfile, &tmp));
emitted_error = true;
}
cleanup:
if (outfile)
if (gzclose (outfile) != Z_OK)
if (!emitted_error)
error_at (UNKNOWN_LOCATION, "error closing optimization records %qs",
filename);
free (filename);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment