Add !annotation metadata and remarks pass.
authorFlorian Hahn <flo@fhahn.com>
Fri, 13 Nov 2020 09:46:55 +0000 (09:46 +0000)
committerFlorian Hahn <flo@fhahn.com>
Fri, 13 Nov 2020 13:24:10 +0000 (13:24 +0000)
commit8bb6347939b7a1f0dab6361e3a0f5cc4c75f5d3d
treec4344567ab449c57eefcaa6fb0fc66a4e9d0fb8f
parent7ad6c8414ce2c229129c93281835eb9457cf0bfb
Add !annotation metadata and remarks pass.

This patch adds a new !annotation metadata kind which can be used to
attach annotation strings to instructions.

It also adds a new pass that emits summary remarks per function with the
counts for each annotation kind.

The intended uses cases for this new metadata is annotating
'interesting' instructions and the remarks should provide additional
insight into transformations applied to a program.

To motivate this, consider these specific questions we would like to get answered:

* How many stores added for automatic variable initialization remain after optimizations? Where are they?
* How many runtime checks inserted by a frontend could be eliminated? Where are the ones that did not get eliminated?

Discussed on llvm-dev as part of 'RFC: Combining Annotation Metadata and Remarks'
(http://lists.llvm.org/pipermail/llvm-dev/2020-November/146393.html)

Reviewed By: thegameg, jdoerfert

Differential Revision: https://reviews.llvm.org/D91188
28 files changed:
llvm/docs/LangRef.rst
llvm/include/llvm/Analysis/OptimizationRemarkEmitter.h
llvm/include/llvm/IR/FixedMetadataKinds.def
llvm/include/llvm/InitializePasses.h
llvm/include/llvm/Transforms/Scalar.h
llvm/include/llvm/Transforms/Scalar/AnnotationRemarks.h [new file with mode: 0644]
llvm/lib/IR/Verifier.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassRegistry.def
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/lib/Transforms/Scalar/AnnotationRemarks.cpp [new file with mode: 0644]
llvm/lib/Transforms/Scalar/CMakeLists.txt
llvm/lib/Transforms/Scalar/Scalar.cpp
llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
llvm/test/Other/new-pm-defaults.ll
llvm/test/Other/new-pm-lto-defaults.ll
llvm/test/Other/new-pm-thinlto-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
llvm/test/Other/opt-LTO-pipeline.ll
llvm/test/Other/opt-O2-pipeline.ll
llvm/test/Other/opt-O3-pipeline-enable-matrix.ll
llvm/test/Other/opt-O3-pipeline.ll
llvm/test/Other/opt-Os-pipeline.ll
llvm/test/Transforms/Util/annotation-remarks.ll [new file with mode: 0644]
llvm/test/Verifier/annotation-metadata.ll [new file with mode: 0644]