From 88f1bad0de1c27dcae842d509e25ed57fbf5489c Mon Sep 17 00:00:00 2001 From: Xinliang David Li Date: Wed, 6 Jan 2016 01:23:41 +0000 Subject: [PATCH] More fix to coverage documentation llvm-svn: 256895 --- docs/CoverageMappingFormat.rst | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/docs/CoverageMappingFormat.rst b/docs/CoverageMappingFormat.rst index ea40a1ddb8c..84cddff5ed9 100644 --- a/docs/CoverageMappingFormat.rst +++ b/docs/CoverageMappingFormat.rst @@ -241,7 +241,13 @@ For example, let’s consider a C file and how it gets compiled to LLVM: return 13; } -The coverage mapping variable generated by Clang is: +The coverage mapping variable generated by Clang has 3 fields: + +* Coverage mapping header. + +* An array of function records. + +* Coverage mapping data which is an array of bytes. Zero paddings are added at the end to force 8 byte alignment. .. code-block:: llvm @@ -266,12 +272,18 @@ The coverage mapping variable generated by Clang is: [40 x i8] c"..." ; Encoded data (dissected later) }, section "__llvm_covmap", align 8 -Version: --------- +Coverage Mapping Header: +------------------------ -The coverage mapping version number can have the following values: +The coverage mapping header has the following fields: -* 0 — The first (current) version of the coverage mapping format. +* The number of function records. + +* The length of the string in the third field of *__llvm_coverage_mapping* that contains the encoded translation unit filenames. + +* The length of the string in the third field of *__llvm_coverage_mapping* that contains the encoded coverage mapping data. + +* The format version. 0 is the first (current) version of the coverage mapping format. .. _function records: @@ -335,7 +347,7 @@ IR for the `coverage mapping sample`_ that was shown earlier: * The length of the substring that contains the encoded coverage mapping data for the first function is the value of the third field in the first structure in an array of `function records`_ stored in the - fifth field of the *__llvm_coverage_mapping* structure, which is the 9. + third field of the *__llvm_coverage_mapping* structure, which is the 9. Therefore, the coverage mapping for the first function record is encoded in this string: @@ -355,7 +367,7 @@ IR for the `coverage mapping sample`_ that was shown earlier: | ``0x01`` | The number of mapping regions that are stored in an array for the function's file id #0. | +----------+-------------------------------------------------------------------------------------------------------------------------+ | ``0x01`` | The coverage mapping counter for the first region in this function. The value of 1 tells us that it's a coverage | - | | mapping counter that is a reference ot the profile instrumentation counter with an index of 0. | + | | mapping counter that is a reference to the profile instrumentation counter with an index of 0. | +----------+-------------------------------------------------------------------------------------------------------------------------+ | ``0x01`` | The starting line of the first mapping region in this function. | +----------+-------------------------------------------------------------------------------------------------------------------------+