Reland: [Remarks] Add an LLVM-bitstream-based remark serializer
Add a new serializer, using a binary format based on the LLVM bitstream
format.
This format provides a way to serialize the remarks in two modes:
1) Separate mode: the metadata is separate from the remark entries.
2) Standalone mode: the metadata and the remark entries are in the same
file.
The format contains:
* a meta block: container version, container type, string table,
external file path, remark version
* a remark block: type, remark name, pass name, function name, debug
file, debug line, debug column, hotness, arguments (key, value, debug
file, debug line, debug column)
A string table is required for this format, which will be dumped in the
meta block to be consumed before parsing the remark blocks.
On clang itself, we noticed a size reduction of 13.4x compared to YAML,
and a compile-time reduction of between 1.7% and 3.5% on CTMark.
Differential Revision: https://reviews.llvm.org/D63466
Original llvm-svn: 367364
Revert llvm-svn: 367370
llvm-svn: 367372
2019-07-31 02:13:51 +02:00
|
|
|
//===-- BitstreamRemarkContainer.h - Container for remarks --------------*-===//
|
|
|
|
//
|
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file provides declarations for things used in the various types of
|
|
|
|
// remark containers.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2021-02-06 06:02:06 +01:00
|
|
|
#ifndef LLVM_REMARKS_BITSTREAMREMARKCONTAINER_H
|
|
|
|
#define LLVM_REMARKS_BITSTREAMREMARKCONTAINER_H
|
Reland: [Remarks] Add an LLVM-bitstream-based remark serializer
Add a new serializer, using a binary format based on the LLVM bitstream
format.
This format provides a way to serialize the remarks in two modes:
1) Separate mode: the metadata is separate from the remark entries.
2) Standalone mode: the metadata and the remark entries are in the same
file.
The format contains:
* a meta block: container version, container type, string table,
external file path, remark version
* a remark block: type, remark name, pass name, function name, debug
file, debug line, debug column, hotness, arguments (key, value, debug
file, debug line, debug column)
A string table is required for this format, which will be dumped in the
meta block to be consumed before parsing the remark blocks.
On clang itself, we noticed a size reduction of 13.4x compared to YAML,
and a compile-time reduction of between 1.7% and 3.5% on CTMark.
Differential Revision: https://reviews.llvm.org/D63466
Original llvm-svn: 367364
Revert llvm-svn: 367370
llvm-svn: 367372
2019-07-31 02:13:51 +02:00
|
|
|
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include "llvm/Bitstream/BitCodes.h"
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
namespace remarks {
|
|
|
|
|
|
|
|
/// The current version of the remark container.
|
|
|
|
/// Note: this is different from the version of the remark entry.
|
|
|
|
constexpr uint64_t CurrentContainerVersion = 0;
|
|
|
|
/// The magic number used for identifying remark blocks.
|
2019-09-13 18:46:23 +02:00
|
|
|
constexpr StringLiteral ContainerMagic("RMRK");
|
Reland: [Remarks] Add an LLVM-bitstream-based remark serializer
Add a new serializer, using a binary format based on the LLVM bitstream
format.
This format provides a way to serialize the remarks in two modes:
1) Separate mode: the metadata is separate from the remark entries.
2) Standalone mode: the metadata and the remark entries are in the same
file.
The format contains:
* a meta block: container version, container type, string table,
external file path, remark version
* a remark block: type, remark name, pass name, function name, debug
file, debug line, debug column, hotness, arguments (key, value, debug
file, debug line, debug column)
A string table is required for this format, which will be dumped in the
meta block to be consumed before parsing the remark blocks.
On clang itself, we noticed a size reduction of 13.4x compared to YAML,
and a compile-time reduction of between 1.7% and 3.5% on CTMark.
Differential Revision: https://reviews.llvm.org/D63466
Original llvm-svn: 367364
Revert llvm-svn: 367370
llvm-svn: 367372
2019-07-31 02:13:51 +02:00
|
|
|
|
|
|
|
/// Type of the remark container.
|
|
|
|
/// The remark container has two modes:
|
|
|
|
/// * separate: the metadata is separate from the remarks and points to the
|
|
|
|
/// auxiliary file that contains the remarks.
|
|
|
|
/// * standalone: the metadata and the remarks are emitted together.
|
|
|
|
enum class BitstreamRemarkContainerType {
|
|
|
|
/// The metadata emitted separately.
|
|
|
|
/// This will contain the following:
|
|
|
|
/// * Container version and type
|
|
|
|
/// * String table
|
|
|
|
/// * External file
|
|
|
|
SeparateRemarksMeta,
|
|
|
|
/// The remarks emitted separately.
|
|
|
|
/// This will contain the following:
|
|
|
|
/// * Container version and type
|
|
|
|
/// * Remark version
|
|
|
|
SeparateRemarksFile,
|
|
|
|
/// Everything is emitted together.
|
|
|
|
/// This will contain the following:
|
|
|
|
/// * Container version and type
|
|
|
|
/// * Remark version
|
|
|
|
/// * String table
|
|
|
|
Standalone,
|
|
|
|
First = SeparateRemarksMeta,
|
|
|
|
Last = Standalone,
|
|
|
|
};
|
|
|
|
|
|
|
|
/// The possible blocks that will be encountered in a bitstream remark
|
|
|
|
/// container.
|
|
|
|
enum BlockIDs {
|
|
|
|
/// The metadata block is mandatory. It should always come after the
|
|
|
|
/// BLOCKINFO_BLOCK, and contains metadata that should be used when parsing
|
|
|
|
/// REMARK_BLOCKs.
|
|
|
|
/// There should always be only one META_BLOCK.
|
|
|
|
META_BLOCK_ID = bitc::FIRST_APPLICATION_BLOCKID,
|
|
|
|
/// One remark entry is represented using a REMARK_BLOCK. There can be
|
|
|
|
/// multiple REMARK_BLOCKs in the same file.
|
|
|
|
REMARK_BLOCK_ID
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr StringRef MetaBlockName = StringRef("Meta", 4);
|
|
|
|
constexpr StringRef RemarkBlockName = StringRef("Remark", 6);
|
|
|
|
|
|
|
|
/// The possible records that can be encountered in the previously described
|
|
|
|
/// blocks.
|
|
|
|
enum RecordIDs {
|
|
|
|
// Meta block records.
|
|
|
|
RECORD_META_CONTAINER_INFO = 1,
|
|
|
|
RECORD_META_REMARK_VERSION,
|
|
|
|
RECORD_META_STRTAB,
|
|
|
|
RECORD_META_EXTERNAL_FILE,
|
|
|
|
// Remark block records.
|
|
|
|
RECORD_REMARK_HEADER,
|
|
|
|
RECORD_REMARK_DEBUG_LOC,
|
|
|
|
RECORD_REMARK_HOTNESS,
|
|
|
|
RECORD_REMARK_ARG_WITH_DEBUGLOC,
|
|
|
|
RECORD_REMARK_ARG_WITHOUT_DEBUGLOC,
|
|
|
|
// Helpers.
|
|
|
|
RECORD_FIRST = RECORD_META_CONTAINER_INFO,
|
|
|
|
RECORD_LAST = RECORD_REMARK_ARG_WITHOUT_DEBUGLOC
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr StringRef MetaContainerInfoName = StringRef("Container info", 14);
|
|
|
|
constexpr StringRef MetaRemarkVersionName = StringRef("Remark version", 14);
|
|
|
|
constexpr StringRef MetaStrTabName = StringRef("String table", 12);
|
|
|
|
constexpr StringRef MetaExternalFileName = StringRef("External File", 13);
|
|
|
|
constexpr StringRef RemarkHeaderName = StringRef("Remark header", 13);
|
|
|
|
constexpr StringRef RemarkDebugLocName = StringRef("Remark debug location", 21);
|
|
|
|
constexpr StringRef RemarkHotnessName = StringRef("Remark hotness", 14);
|
|
|
|
constexpr StringRef RemarkArgWithDebugLocName =
|
|
|
|
StringRef("Argument with debug location", 28);
|
|
|
|
constexpr StringRef RemarkArgWithoutDebugLocName = StringRef("Argument", 8);
|
|
|
|
|
|
|
|
} // end namespace remarks
|
|
|
|
} // end namespace llvm
|
|
|
|
|
2021-02-06 06:02:06 +01:00
|
|
|
#endif // LLVM_REMARKS_BITSTREAMREMARKCONTAINER_H
|