-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Remarks] Introduce tool to count remarks. #66214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zjaffal
merged 7 commits into
llvm:main
from
zjaffal:llvm/tools/llvm-remarkutil/remarkcounter
Oct 12, 2023
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a81a535
Remark Util introduce remark count
a21dd64
[Remark] Remove unrelated change for Remark header.
4951bd7
Update remark.rst file
779a3e1
Address nit comments from PR
b1dca6d
Rename `KeyCounter` to `ArgumentCounter`
d757f71
Update documentation for functions and nit comments from PR
2e96508
Remove std::variant from FilterMatcher class
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
llvm/test/tools/llvm-remarkutil/annotation-count-with-dbg-loc.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
RUN: llvm-remarkutil annotation-count --use-debug-loc --parser=yaml --annotation-type=remark %p/Inputs/annotation-count-with-dbg-loc.yaml | FileCheck %s | ||
RUN: llvm-remarkutil yaml2bitstream %p/Inputs/annotation-count-with-dbg-loc.yaml | llvm-remarkutil annotation-count --use-debug-loc --parser=bitstream --annotation-type=remark | FileCheck %s | ||
RUN: llvm-remarkutil count --parser=yaml --count-by=arg --group-by=function-with-loc --remark-name="AnnotationSummary" %p/Inputs/annotation-count-with-dbg-loc.yaml | FileCheck %s --check-prefix=COUNT-CHECK | ||
RUN: llvm-remarkutil yaml2bitstream %p/Inputs/annotation-count-with-dbg-loc.yaml | llvm-remarkutil count --parser=bitstream --count-by=arg --group-by=function-with-loc --remark-name="AnnotationSummary" | FileCheck %s --check-prefix=COUNT-CHECK | ||
|
||
; CHECK-LABEL: Source,Function,Count | ||
; CHECK: path/to/anno.c:1:2,func1,1 | ||
; CHECK: path/to/anno2.c:1:2,func2,2 | ||
; CHECK: path/to/anno3.c:1:2,func3,3 | ||
|
||
; COUNT-CHECK-LABEL: FuctionWithDebugLoc,count | ||
; COUNT-CHECK: path/to/anno.c:func1,1 | ||
; COUNT-CHECK: path/to/anno2.c:func2,2 | ||
; COUNT-CHECK: path/to/anno3.c:func3,3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
RUN: llvm-remarkutil annotation-count --parser=yaml --annotation-type=remark %p/Inputs/annotation-count.yaml | FileCheck %s | ||
RUN: llvm-remarkutil yaml2bitstream %p/Inputs/annotation-count.yaml | llvm-remarkutil annotation-count --parser=bitstream --annotation-type=remark | FileCheck %s | ||
RUN: llvm-remarkutil count --parser=yaml --count-by=arg --group-by=function --remark-name="AnnotationSummary" %p/Inputs/annotation-count.yaml | FileCheck %s --check-prefix=COUNT-CHECK | ||
RUN: llvm-remarkutil yaml2bitstream %p/Inputs/annotation-count.yaml | llvm-remarkutil count --parser=bitstream --count-by=arg --group-by=function --remark-name="AnnotationSummary" | FileCheck %s --check-prefix=COUNT-CHECK | ||
|
||
; CHECK-LABEL: Function,Count | ||
; CHECK: func1,1 | ||
; CHECK: func2,2 | ||
; CHECK: func3,3 | ||
|
||
; COUNT-CHECK-LABEL: Function,count | ||
; COUNT-CHECK: func1,1 | ||
; COUNT-CHECK: func2,2 | ||
; COUNT-CHECK: func3,3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
RUN: not llvm-remarkutil bitstream2yaml %p/Inputs/broken-remark -o - 2>&1 | FileCheck %s | ||
RUN: not llvm-remarkutil instruction-count --parser=bitstream %p/Inputs/broken-remark -o - 2>&1 | FileCheck %s | ||
RUN: not llvm-remarkutil annotation-count --parser=bitstream --annotation-type=remark %p/Inputs/broken-remark -o - 2>&1 | FileCheck %s | ||
RUN: not llvm-remarkutil count --parser=bitstream %p/Inputs/broken-remark -o - 2>&1 | FileCheck %s | ||
|
||
CHECK: error: Unknown magic number: expecting RMRK, got --- . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
RUN: not llvm-remarkutil yaml2bitstream %p/Inputs/broken-remark -o - 2>&1 | FileCheck %s | ||
RUN: not llvm-remarkutil instruction-count --parser=yaml %p/Inputs/broken-remark -o - 2>&1 | FileCheck %s | ||
RUN: not llvm-remarkutil annotation-count --parser=yaml --annotation-type=remark %p/Inputs/broken-remark -o - 2>&1 | FileCheck %s | ||
RUN: not llvm-remarkutil count --parser=yaml %p/Inputs/broken-remark -o - 2>&1 | FileCheck %s | ||
|
||
CHECK: error: Type, Pass, Name or Function missing |
43 changes: 43 additions & 0 deletions
43
llvm/test/tools/llvm-remarkutil/count/Inputs/remark-count-by.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- !Analysis | ||
Pass: generic-remarks-pass | ||
Name: Remark | ||
DebugLoc: { File: path/to/anno.c, Line: 1, Column: 2 } | ||
Function: func1 | ||
Args: | ||
- count1: '1' | ||
- count2: '2' | ||
- count3: '3' | ||
- count4: '4' | ||
- String: ' instructions with ' | ||
- type: remark | ||
--- !Analysis | ||
Pass: generic-remarks-pass | ||
Name: Remark2 | ||
DebugLoc: { File: path/to/anno2.c, Line: 1, Column: 2 } | ||
Function: func1 | ||
Args: | ||
- count1: '1' | ||
- count2: '2' | ||
- count3: '3' | ||
- String: ' instructions with ' | ||
- type: remark | ||
--- !Analysis | ||
Pass: generic-remarks-pass | ||
Name: Remark3 | ||
DebugLoc: { File: path/to/anno.c, Line: 1, Column: 2 } | ||
Function: func1 | ||
Args: | ||
- count1: '1' | ||
- String: ' instructions with ' | ||
- type: remark | ||
--- !Analysis | ||
Pass: generic-remarks-pass | ||
Name: Remark | ||
DebugLoc: { File: path/to/anno.c, Line: 1, Column: 2 } | ||
Function: func2 | ||
Args: | ||
- count1: '1' | ||
- count2: '2' | ||
- count3: '3' | ||
- String: ' instructions with ' | ||
- type: remark |
40 changes: 40 additions & 0 deletions
40
llvm/test/tools/llvm-remarkutil/count/Inputs/remark-filter-by.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- !Analysis | ||
Pass: generic-remarks-pass | ||
Name: Remark | ||
DebugLoc: { File: path/to/anno2.c, Line: 1, Column: 2 } | ||
Function: func1 | ||
Args: | ||
- count1: '1' | ||
- String: ' instructions with ' | ||
- type: remark | ||
--- !Analysis | ||
Pass: generic-remarks-pass2 | ||
Name: Remark2 | ||
DebugLoc: { File: path/to/anno2.c, Line: 1, Column: 2 } | ||
Function: func1 | ||
Args: | ||
- count1: '1' | ||
- count2: '2' | ||
- count3: '3' | ||
- String: ' instructions with ' | ||
- type: remark | ||
--- !Missed | ||
Pass: generic-remarks-pass | ||
Name: Remark3 | ||
DebugLoc: { File: path/to/anno.c, Line: 1, Column: 2 } | ||
Function: func1 | ||
Args: | ||
- count1: '1' | ||
- String: ' instructions with ' | ||
- type: remark | ||
--- !Passed | ||
Pass: generic-remarks-pass | ||
Name: Remark | ||
DebugLoc: { File: path/to/anno.c, Line: 1, Column: 2 } | ||
Function: func1 | ||
Args: | ||
- count1: '1' | ||
- count2: '2' | ||
- count3: '3' | ||
- String: ' instructions with ' | ||
- type: remark |
54 changes: 54 additions & 0 deletions
54
llvm/test/tools/llvm-remarkutil/count/Inputs/remark-group-by.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- !Analysis | ||
Pass: generic-remarks-pass | ||
Name: Remark | ||
DebugLoc: { File: path/to/anno.c, Line: 1, Column: 2 } | ||
Function: func1 | ||
Args: | ||
- count: '1' | ||
- String: ' instructions with ' | ||
- type: remark | ||
--- !Missed | ||
Pass: generic-remarks-pass | ||
Name: Remark | ||
DebugLoc: { File: path/to/anno.c, Line: 1, Column: 2 } | ||
Function: func1 | ||
Args: | ||
- count: '3' | ||
- String: ' instructions with ' | ||
- type: remark | ||
--- !Passed | ||
Pass: generic-remarks-pass | ||
Name: Remark | ||
DebugLoc: { File: path/to/anno.c, Line: 1, Column: 2 } | ||
Function: func2 | ||
Args: | ||
- count: '3' | ||
- String: ' instructions with ' | ||
- type: remark | ||
--- !Analysis | ||
Pass: generic-remarks-pass2 | ||
Name: Remark | ||
DebugLoc: { File: path/to/anno3.c, Line: 1, Column: 2 } | ||
Function: func1 | ||
Args: | ||
- count: '3' | ||
- String: ' instructions with ' | ||
- type: remark | ||
--- !Analysis | ||
Pass: generic-remarks-pass3 | ||
Name: Remark | ||
DebugLoc: { File: path/to/anno.c, Line: 1, Column: 2 } | ||
Function: func2 | ||
Args: | ||
- count: '2' | ||
- String: ' instructions with ' | ||
- type: remark | ||
--- !Analysis | ||
Pass: generic-remarks-pass4 | ||
Name: Remark | ||
DebugLoc: { File: path/to/anno2.c, Line: 1, Column: 2 } | ||
Function: func3 | ||
Args: | ||
- count: '2' | ||
- String: ' instructions with ' | ||
- type: remark |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
RUN: llvm-remarkutil count --parser=yaml --count-by=arg --group-by=source %p/Inputs/remark-count-by.yaml | FileCheck %s | ||
RUN: llvm-remarkutil count --parser=yaml --count-by=arg --group-by=function %p/Inputs/remark-count-by.yaml | FileCheck %s --check-prefix=CHECKFUNC | ||
RUN: llvm-remarkutil count --parser=yaml --count-by=arg --group-by=function-with-loc %p/Inputs/remark-count-by.yaml | FileCheck %s --check-prefix=CHECKFUNCLOC | ||
RUN: llvm-remarkutil count --parser=yaml --count-by=arg --group-by=total %p/Inputs/remark-count-by.yaml | FileCheck %s --check-prefix=CHECKTOTAL | ||
|
||
; CHECK-LABEL: Source,count1,count2,count3,count4 | ||
; CHECK: path/to/anno.c,3,4,6,4 | ||
; CHECK: path/to/anno2.c,1,2,3,0 | ||
|
||
; CHECKFUNC-LABEL: Function,count1,count2,count3,count4 | ||
; CHECKFUNC: func1,3,4,6,4 | ||
; CHECKFUNC: func2,1,2,3,0 | ||
|
||
; CHECKFUNCLOC-LABEL: FuctionWithDebugLoc,count1,count2,count3,count4 | ||
; CHECKFUNCLOC: path/to/anno.c:func1,2,2,3,4 | ||
; CHECKFUNCLOC: path/to/anno.c:func2,1,2,3,0 | ||
; CHECKFUNCLOC: path/to/anno2.c:func1,1,2,3,0 | ||
|
||
; CHECKTOTAL-LABEL: Total,count1,count2,count3,count4 | ||
; CHECKTOTAL: Total,4,6,9,4 |
20 changes: 20 additions & 0 deletions
20
llvm/test/tools/llvm-remarkutil/count/count-by-remark.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
RUN: llvm-remarkutil count --parser=yaml --count-by=remark-name --group-by=source %p/Inputs/remark-count-by.yaml | FileCheck %s | ||
RUN: llvm-remarkutil count --parser=yaml --count-by=remark-name --group-by=function %p/Inputs/remark-count-by.yaml | FileCheck %s --check-prefix=CHECKFUNC | ||
RUN: llvm-remarkutil count --parser=yaml --count-by=remark-name --group-by=function-with-loc %p/Inputs/remark-count-by.yaml | FileCheck %s --check-prefix=CHECKFUNCLOC | ||
RUN: llvm-remarkutil count --parser=yaml --count-by=remark-name --group-by=total %p/Inputs/remark-count-by.yaml | FileCheck %s --check-prefix=CHECKTOTAL | ||
|
||
; CHECK-LABEL: Source,Count | ||
; CHECK: path/to/anno.c,3 | ||
; CHECK: path/to/anno2.c,1 | ||
|
||
; CHECKFUNC-LABEL: Function,Count | ||
; CHECKFUNC: func1,3 | ||
; CHECKFUNC: func2,1 | ||
|
||
; CHECKFUNCLOC-LABEL: FuctionWithDebugLoc,Count | ||
; CHECKFUNCLOC: path/to/anno.c:func1,2 | ||
; CHECKFUNCLOC: path/to/anno.c:func2,1 | ||
; CHECKFUNCLOC: path/to/anno2.c:func1,1 | ||
|
||
; CHECKTOTAL-LABEL: Total,Count | ||
; CHECKTOTAL: Total,4 |
10 changes: 10 additions & 0 deletions
10
llvm/test/tools/llvm-remarkutil/count/filter-by-pass-name.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
RUN: llvm-remarkutil count --parser=yaml --pass-name=generic-remarks-pass %p/Inputs/remark-filter-by.yaml | FileCheck %s | ||
RUN: llvm-remarkutil count --parser=yaml --rpass-name=.* %p/Inputs/remark-filter-by.yaml | FileCheck %s --check-prefix=CHECKALL | ||
|
||
; CHECK-LABEL: Source,Count | ||
; CHECK: path/to/anno.c,2 | ||
; CHECK: path/to/anno2.c,1 | ||
|
||
; CHECKALL-LABEL: Source,Count | ||
; CHECKALL: path/to/anno.c,2 | ||
; CHECKALL: path/to/anno2.c,2 |
10 changes: 10 additions & 0 deletions
10
llvm/test/tools/llvm-remarkutil/count/filter-by-remark-name.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
RUN: llvm-remarkutil count --parser=yaml --remark-name=Remark %p/Inputs/remark-filter-by.yaml | FileCheck %s | ||
RUN: llvm-remarkutil count --parser=yaml --rremark-name=R.* %p/Inputs/remark-filter-by.yaml | FileCheck %s --check-prefix=CHECKALL | ||
|
||
; CHECK-LABEL: Source,Count | ||
; CHECK: path/to/anno.c,1 | ||
; CHECK: path/to/anno2.c,1 | ||
|
||
; CHECKALL-LABEL: Source,Count | ||
; CHECKALL: path/to/anno.c,2 | ||
; CHECKALL: path/to/anno2.c,2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
RUN: llvm-remarkutil count --parser=yaml --remark-type=missed %p/Inputs/remark-filter-by.yaml | FileCheck %s --check-prefix=MISSED | ||
RUN: llvm-remarkutil count --parser=yaml --remark-type=passed %p/Inputs/remark-filter-by.yaml | FileCheck %s --check-prefix=PASSED | ||
RUN: llvm-remarkutil count --parser=yaml --remark-type=analysis %p/Inputs/remark-filter-by.yaml | FileCheck %s --check-prefix=ANALYSIS | ||
RUN: llvm-remarkutil count --parser=yaml --remark-type=unknown %p/Inputs/remark-filter-by.yaml | FileCheck %s --check-prefix=UNKNOWN | ||
|
||
; MISSED-LABEL: Source,Count | ||
; MISSED: path/to/anno.c,1 | ||
|
||
; PASSED-LABEL: Source,Count | ||
; PASSED: path/to/anno.c,1 | ||
|
||
; ANALYSIS-LABEL: Source,Count | ||
; ANALYSIS: path/to/anno2.c,2 | ||
|
||
; UNKNOWN: Source,Count | ||
; UNKNOWN-EMPTY: |
7 changes: 7 additions & 0 deletions
7
llvm/test/tools/llvm-remarkutil/count/group-by-function-with-loc.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
RUN: llvm-remarkutil count --parser=yaml --group-by=function-with-loc %p/Inputs/remark-group-by.yaml | FileCheck %s | ||
|
||
; CHECK-LABEL: FuctionWithDebugLoc,Count | ||
; CHECK: path/to/anno.c:func1,2 | ||
; CHECK: path/to/anno.c:func2,2 | ||
; CHECK: path/to/anno2.c:func3,1 | ||
; CHECK: path/to/anno3.c:func1,1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
RUN: llvm-remarkutil count --parser=yaml --group-by=function %p/Inputs/remark-group-by.yaml | FileCheck %s | ||
|
||
; CHECK-LABEL: Function,Count | ||
; CHECK: func1,3 | ||
; CHECK: func2,2 | ||
; CHECK: func3,1 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have both name and regex for these options? Isn't the regex enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is just following the same idea that other tools have. For example
llvm-extract
has--func
and--rfunc
, I think if you pass something likeremark-name
to the llvm regex parser it will also match withremark-name1
,remark-name2
so it is better to seperate regex optionThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be fine to have them separately initially. Discussed this with Zain offline and having a separate
remark-name
makes it easier to match names exactly; with one option that takes a regex only the user would have to write a more complicated regex