@@ -54,7 +54,8 @@ The following statistics can be recorded:
5454
5555 * For SILFunctions: the number of SIL basic blocks for each SILFunction, the
5656 number of SIL instructions, the number of SILInstructions of a specific
57- kind (e.g. a number of alloc_ref instructions)
57+ kind (e.g. a number of alloc_ref instructions), the number of debug
58+ variables
5859
5960 * For SILModules: the number of SIL basic blocks in the SILModule, the number
6061 of SIL instructions, the number of SILFunctions, the number of
@@ -118,6 +119,16 @@ e.g. `-Xllvm -sil-stats-only-instructions=alloc_ref,alloc_stack`. If you need to
118119collect stats about all kinds of SIL instructions, you can use this syntax:
119120` -Xllvm -sil-stats-only-instructions=all ` .
120121
122+ ### Debug variable level counters
123+ A different type of counter is the lost debug variables counter. It is enabled
124+ by using the ` -Xllvm -sil-stats-lost-variables ` command-line option. It only
125+ tracks statistics about lost variables in SILFunctions. It is not enabled by
126+ any other command-line option, but can be combined with the others. It is not
127+ compatible with thresholds, it always counts lost variables. Note that it does
128+ not track the number of debug variables: it counts the number of debug variables
129+ that were present, but aren't anymore. If a variable changes location or scope,
130+ which is not allowed, it will be counted as lost.
131+
121132## Configuring which counters changes should be recorded
122133
123134The user has a possibility to configure a number of thresholds, which control
@@ -181,9 +192,9 @@ And for counter stats it looks like this:
181192 * ` function_history ` corresponds to the verbose mode of function
182193 counters collection, when changes to the SILFunction counters are logged
183194 unconditionally, without any on-line filtering.
184- * ` CounterName ` is typically one of ` block ` , ` inst ` , ` function ` , ` memory ` ,
185- or ` inst_instruction_name ` if you collect counters for specific kinds of SIL
186- instructions.
195+ * ` CounterName ` is typically one of ` block ` , ` inst ` , ` function ` , ` memory ` ,
196+ ` lostvars ` , or ` inst_instruction_name ` if you collect counters for specific
197+ kinds of SIL instructions.
187198* ` Symbol ` is e.g. the name of a function
188199* ` StageName ` is the name of the current optimizer pipeline stage
189200* ` TransformName ` is the name of the current optimizer transformation/pass
@@ -192,6 +203,14 @@ And for counter stats it looks like this:
192203 want to reproduce the result later using
193204 ` -Xllvm -sil-opt-pass-count -Xllvm TransformPassNumber `
194205
206+ ## Extract Lost Variables per Pass
207+
208+ For lost variables, there is a script to output a CSV with only the amount of
209+ lost variables per pass. You can then easily open the resulting CSV in Numbers
210+ to make graphs.
211+
212+ ` utils/process-stats-lost-variables csv_file_with_counters > csv_aggregate `
213+
195214## Storing the produced statistics into a database
196215
197216To store the set of produced counters into a database, you can use the
@@ -345,4 +364,3 @@ from Counters C where C.counter = 'inst' and C.kind = 'module'
345364group by Stage
346365order by sum (C .Delta );
347366```
348-
0 commit comments