1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00
llvm-mirror/test/Transforms/Util/annotation-remarks.ll
Florian Hahn 041da6277f 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
2020-11-13 13:24:10 +00:00

53 lines
1.9 KiB
LLVM

; RUN: opt -annotation-remarks -pass-remarks-missed='annotation-remarks' -disable-output -pass-remarks-output=%t.opt.yaml %s
; RUN: FileCheck --input-file=%t.opt.yaml %s
; RUN: opt -passes='annotation-remarks' -pass-remarks-missed='annotation-remarks' -disable-output -pass-remarks-output=%t.opt.yaml %s
; RUN: FileCheck --input-file=%t.opt.yaml %s
; CHECK: --- !Analysis
; CHECK-NEXT: Pass: annotation-remarks
; CHECK-NEXT: Name: AnnotationSummary
; CHECK-NEXT: Function: test1
; CHECK-NEXT: Args:
; CHECK-NEXT: - String: 'Annotated '
; CHECK-NEXT: - count: '4'
; CHECK-NEXT: - String: ' instructions with '
; CHECK-NEXT: - type: _remarks1
; CHECK-NEXT: ...
; CHECK-NEXT: --- !Analysis
; CHECK-NEXT: Pass: annotation-remarks
; CHECK-NEXT: Name: AnnotationSummary
; CHECK-NEXT: Function: test1
; CHECK-NEXT: Args:
; CHECK-NEXT: - String: 'Annotated '
; CHECK-NEXT: - count: '3'
; CHECK-NEXT: - String: ' instructions with '
; CHECK-NEXT: - type: _remarks2
; CHECK-NEXT: ...
; CHECK-NEXT: --- !Analysis
; CHECK-NEXT: Pass: annotation-remarks
; CHECK-NEXT: Name: AnnotationSummary
; CHECK-NEXT: Function: test2
; CHECK-NEXT: Args:
; CHECK-NEXT: - String: 'Annotated '
; CHECK-NEXT: - count: '2'
; CHECK-NEXT: - String: ' instructions with '
; CHECK-NEXT: - type: _remarks1
; CHECK-NEXT: ...
define void @test1(float* %a) {
entry:
%a.addr = alloca float*, align 8, !annotation !0
store float* null, float** %a.addr, align 8, !annotation !1
store float* %a, float** %a.addr, align 8, !annotation !0
ret void, !annotation !0
}
define void @test2(float* %a) {
entry:
%a.addr = alloca float*, align 8, !annotation !1
ret void, !annotation !1
}
!0 = !{!"_remarks1", !"_remarks2"}
!1 = !{!"_remarks1"}