Skip to content

Commit fc2ad81

Browse files
committed
Updated Extensions.rst.
1 parent 9c0ea35 commit fc2ad81

File tree

1 file changed

+50
-9
lines changed

1 file changed

+50
-9
lines changed

llvm/docs/Extensions.rst

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -405,31 +405,72 @@ This section is emitted with ``-basic-block-address-map`` and will contain
405405
a BB address map table for every function.
406406

407407
The ``SHT_LLVM_BB_ADDR_MAP`` type provides backward compatibility to allow
408-
reading older versions of the BB address map generated by older compilers. Each
409-
function entry starts with a version byte which specifies the encoding version
410-
to use. The following versioning schemes are currently supported.
408+
reading older versions of the BB address map generated by older compilers (up to
409+
two years old). Each function entry starts with a version byte which specifies
410+
the encoding version to use. This follows by a feature byte which specifies the
411+
features specific to this particular entry. The function base address is stored
412+
as a full address. Other addresses in the entry (block begin and end addresses
413+
and callsite addresses) are stored in a running-offset fashion, as offset
414+
relative to the prior address.
411415

412-
Version 1 (newest): basic block address offsets are computed relative to the end
413-
of previous blocks.
416+
The following versioning schemes are currently supported (newer versions support
417+
features of the older versions).
418+
419+
Version 3 (newest): Capable of encoding callsite offsets. Enabled by the 6th bit
420+
of the feature byte.
414421

415422
Example:
416423

417424
.. code-block:: gas
418425
419426
.section ".llvm_bb_addr_map","",@llvm_bb_addr_map
420-
.byte 1 # version number
421-
.byte 0 # feature byte (reserved for future use)
427+
.byte 3 # version number
428+
.byte 32 # feature byte
422429
.quad .Lfunc_begin0 # address of the function
423430
.byte 2 # number of basic blocks
424431
# BB record for BB_0
425-
.uleb128 .Lfunc_beign0-.Lfunc_begin0 # BB_0 offset relative to function entry (always zero)
432+
.byte 0 # BB_0 ID
433+
.uleb128 .Lfunc_begin0-.Lfunc_begin0 # BB_0 offset relative to function entry (always zero)
434+
.byte 0 # number of callsites in this block
426435
.uleb128 .LBB_END0_0-.Lfunc_begin0 # BB_0 size
427436
.byte x # BB_0 metadata
428437
# BB record for BB_1
438+
.byte 1 # BB_1 ID
429439
.uleb128 .LBB0_1-.LBB_END0_0 # BB_1 offset relative to the end of last block (BB_0).
430-
.uleb128 .LBB_END0_1-.LBB0_1 # BB_1 size
440+
.byte 2 # number of callsites in this block
441+
.uleb128 .LBB0_1_CS0-.LBB0_1 # offset of callsite relative to the previous offset (.LBB0_1)
442+
.uleb128 .LBB0_1_CS1-.LBB0_1_CS0 # offset of callsite relative to the previous offset (.LBB0_1_CS0)
443+
.uleb128 .LBB_END0_1-.LBB0_1_CS1 # BB_1 size offset (Offset of the block end relative to the previous offset).
431444
.byte y # BB_1 metadata
432445
446+
Version 2: Capable of encoding split functions. Enabled by the 4th bit of the
447+
feature byte. The base address of each split range is stored as a full address.
448+
The first range corresponds to the function entry.
449+
450+
Example:
451+
452+
.. code-block:: gas
453+
.section ".llvm_bb_addr_map","",@llvm_bb_addr_map
454+
.byte 2 # version number
455+
.byte 8 # feature byte
456+
.byte 2 # number of basic block ranges
457+
# 1st BB range (corresponding to the function entry)
458+
.quad .Lfunc_begin0 # base address
459+
.byte 1 # number of basic blocks in this range
460+
# BB record for BB_0
461+
.byte 0 # BB_0 ID
462+
.uleb128 .Lfunc_begin0-.Lfunc_begin0 # BB_0 offset relative to function entry (always zero)
463+
.uleb128 .LBB_END0_0-.Lfunc_begin0 # BB_0 size
464+
.byte x # BB_0 metadata
465+
# 2nd BB range
466+
.quad func.part.1
467+
.byte 1 # number of basic blocks in this range
468+
# BB record for BB_1
469+
.byte 1 # BB_1 ID
470+
.uleb128 func.part.1-func.part.1 # BB_1 offset relative to the range begin (always zero)
471+
.uleb128 .LBB_END0_1-func.part.1 # BB_1 size
472+
.byte 1 # BB_1 metadata
473+
433474
PGO Analysis Map
434475
""""""""""""""""
435476

0 commit comments

Comments
 (0)