This is an archive of the discontinued LLVM Phabricator instance.

Remark Util introduce remark count
Needs ReviewPublic

Authored by zjaffal on Aug 2 2023, 2:41 AM.

Details

Summary

This tool is a generic remark counter reporting count based on specified
properties. The counter can be used to count remarks individually and
filter them based on name, type and pass or count using remark
arguments.

Usage:
llvm-remarkutil count [options] <input file>

Options:

--count-by=<value>      - Specify the property to collect remarks by
  =remark-name          -   Counts individual remarks based on how many of the remark exists
  =key                  -   Counts based on the value each specified key has. The key has to have a number value to be considered.
--group-by=<value>      - Specify the property to group remarks by
  =source               -   Display the count broken down by the filepath of each remark emitted. Requires remarks to have DebugLoc information.
  =function             -   Breakdown the count by function name.
  =function-with-loc    -   Breakdown the count by function name taking into consideration the filepath info from the DebugLoc of the remark.
  =total                -   Output the total number corresponding to the count for the provided input file
--keys[=<keys>]           - Specify key(es) to count.
-o <filename>           - Output
--parser=<value>        - Input remark format to parse
  =yaml                 -   YAML
  =bitstream            -   Bitstream
--pass-name[=<string>]    - optional remark pass name to filter collection by.
--remark-name[=<string>]  - optional remark name to filter collection by.
--remark-type=<value>   - remark name to collect using (accepts regular expressions)
  =unknown              -   UNKOWN
  =passed               -   PASSED
  =missed               -   MISSED
  =analysis             -   ANALYSIS
  =analysis-fp-commute  -   ANALYSIS_FP_COMMUTE
  =analysis-aliasing    -   ANALYSIS_ALIASING
  =failure              -   FAILURE
--rkeys[=<keys>]          - Specify key(es) to count using regular expression.
--rpass-name[=<string>]   - optional remark pass name to filter collection by (accepts regular expressions)
--rremark-name[=<string>] - optional remark name to filter collection by (accepts regular expressions)

Diff Detail

Event Timeline

zjaffal created this revision.Aug 2 2023, 2:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 2 2023, 2:41 AM
zjaffal requested review of this revision.Aug 2 2023, 2:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 2 2023, 2:41 AM

cool!

llvm/test/tools/llvm-remarkutil/annotation-count.test
15

add newline

llvm/test/tools/llvm-remarkutil/count/Inputs/remark-count-by.yaml
44

add newline (or the YAML parser might not actually parse this)

llvm/tools/llvm-remarkutil/RemarkCounter.cpp
93
  • if you use \p Key and \p Remark, it'll show up nice in the doxygen
  • it's only the parsed integer value when you successfully find a RemarkArg, right? so the comment isn't totally accurate here IMO
104

probably want doxygen comments for all functions

116

can you fold these ifs?

if (RemarkNameFilter && !RemarkNameFilter->match(Remark.RemarkName))
  return false;
llvm/tools/llvm-remarkutil/RemarkCounter.h
24

doxygen?

28

doxygen?

37

doxygen?

51

doxygen?

69

can you expand on "properties"?

96

doxygen

113

can you expand on "info"?

115
127
  • can this be a DenseMap?
  • also why map strings and not the GroupBy enum?
134

comment?

138

can this be const?

194

add newline

zjaffal marked 6 inline comments as done.Aug 11 2023, 8:25 AM
zjaffal added inline comments.
llvm/tools/llvm-remarkutil/RemarkCounter.h
127

Because I am using std::string DenseMap won't work.

The reason for why it is not the GroupBy enum is because this map acts as the columns for the collection so first we collect all the keys that match the specified keys and then based on GroupBy we decide what the rows will be
for example of GroupBy is by source you will get something like

sourcekey1key2key3
path/to/file1013
path/to/file2102
path/to/file3231

if GroupBy is function you will get

functionkey1key2key3
func1013
func2102
func3231
zjaffal updated this revision to Diff 549415.Aug 11 2023, 8:25 AM

Address nit comments

zjaffal retitled this revision from Remark Util intoduce remark count to Remark Util introduce remark count.Aug 11 2023, 8:26 AM
zjaffal edited the summary of this revision. (Show Details)