Add an option to save the backend-produced YAML optimization record to a file
authorHal Finkel <hfinkel@anl.gov>
Tue, 11 Oct 2016 00:26:09 +0000 (00:26 +0000)
committerHal Finkel <hfinkel@anl.gov>
Tue, 11 Oct 2016 00:26:09 +0000 (00:26 +0000)
commit8f96e82cb8ccfee75e56328159a84c0c7002f83f
tree7c98131814a67ebc206de0f59963f38ffb8780bf
parent4043ca7394046be5c47740e9c5a83382ee734419
Add an option to save the backend-produced YAML optimization record to a file

The backend now has the capability to save information from optimizations, the
same information that can be used to generate optimization diagnostics but in
machine-consumable form, into an output file. This can be enabled when using
opt (see r282539), and this change enables it when using clang. The idea is
that other tools will be able to consume these files, and perhaps in
combination with the original source code, produce various kinds of
optimization reports for users (and for compiler developers).

We now have at-least two tools that can consume these files:
  * tools/llvm-opt-report
  * utils/opt-viewer

Using the flag -fsave-optimization-record will cause the YAML file to be
generated; the file name will be based on the output file name (if we're using
-c or -S and have an output name), or the input file name. When we're using
CUDA, or some other offloading mechanism, separate files are generated for each
backend target. The output file name can be specified by the user using
-foptimization-record-file=filename.

Differential Revision: https://reviews.llvm.org/D25225

llvm-svn: 283834
clang/include/clang/Driver/CC1Options.td
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/CodeGenOptions.h
clang/lib/CodeGen/CodeGenAction.cpp
clang/lib/Driver/Tools.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/Inputs/opt-record.proftext [new file with mode: 0644]
clang/test/CodeGen/opt-record.c [new file with mode: 0644]
clang/test/Driver/opt-record.c [new file with mode: 0644]