1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00
llvm-mirror/include/llvm/ProfileData
Fangrui Song 506848f563 [llvm-cov gcov] Replace Donald B. Johnson's cycle enumeration with iterative cycle finding
gcov computes the line execution count as the sum of (a) counts from
predecessors on other lines and (b) the sum of loop execution counts of blocks
on the same line (think of loops on one line).

For (b), we use Donald B. Johnson's cycle enumeration algorithm and perform
cycle cancelling for each cycle. This number of candidate cycles were
exponential and D93036 made it polynomial by skipping zero count cycles.  The
time complexity is high (O(V*E^2) (it could be O(E^2) but the linear `Blocks`
check made it higher) and the implementation is complex.

We could just identify loops and sum all back edges. However, this requires a
dominator tree construction which is more complex. The time complexity can be
decreased to almost linear, though.

This patch just performs cycle cancelling iteratively. Add two members
`traversable` and `incoming` to GCOVArc. There are 3 states:

* `!traversable`: blocks not on this line or explored blocks
* `traversable && incoming == nullptr`: unexplored blocks
* `traversable && incoming != nullptr`: blocks which are being explored (on the stack)

If an arc points to a block being explored, a cycle has been found.

Let E be the number of arcs. Every time a cycle is found, at least one arc is
saturated (`edgeCount` reduced to 0), so there are at most E cycles. Finding one
cycle takes O(E) time, so the overall time complexity is O(E^2). Note that we
always augment through a back edge and never need to augment its reverse edge so
reverse edges in traditional flow networks are not needed.

Reviewed By: xinhaoyuan

Differential Revision: https://reviews.llvm.org/D93073
2020-12-11 18:28:16 -08:00
..
Coverage [llvm-cov] Warn when -arch spec is missing/invalid for universal binary (reland) 2020-10-13 16:46:03 -07:00
GCOV.h [llvm-cov gcov] Replace Donald B. Johnson's cycle enumeration with iterative cycle finding 2020-12-11 18:28:16 -08:00
InstrProf.h [PGO] Remove the old memop value profiling buckets. 2020-10-15 10:09:49 -07:00
InstrProfData.inc [PGO] Remove the old memop value profiling buckets. 2020-10-15 10:09:49 -07:00
InstrProfReader.h [PGO] Supporting code for always instrumenting entry block 2020-07-22 15:01:53 -07:00
InstrProfWriter.h Supplement instr profile with sample profile. 2020-07-27 20:17:40 -07:00
ProfileCommon.h [CodeGen] Add text section prefix for COFF object file 2020-12-08 18:56:21 +08:00
SampleProf.h [SampleFDO] Store fixed length MD5 in NameTable instead of using ULEB128 if 2020-12-08 16:21:01 -08:00
SampleProfReader.h [SampleFDO] Store fixed length MD5 in NameTable instead of using ULEB128 if 2020-12-08 16:21:01 -08:00
SampleProfWriter.h [SampleFDO] Store fixed length MD5 in NameTable instead of using ULEB128 if 2020-12-08 16:21:01 -08:00