2019-03-19 22:11:07 +01:00
|
|
|
//===-- llvm/Remarks/Remark.h - The remark type -----------------*- C++/-*-===//
|
|
|
|
//
|
|
|
|
// 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 defines an abstraction for handling remarks.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_REMARKS_REMARK_H
|
|
|
|
#define LLVM_REMARKS_REMARK_H
|
|
|
|
|
|
|
|
#include "llvm-c/Remarks.h"
|
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
|
|
|
#include "llvm/ADT/Optional.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include "llvm/Support/CBindingWrapping.h"
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
namespace remarks {
|
|
|
|
|
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
|
|
|
/// The current version of the remark entry.
|
|
|
|
constexpr uint64_t CurrentRemarkVersion = 0;
|
2019-03-27 02:13:59 +01:00
|
|
|
|
2019-03-19 22:11:07 +01:00
|
|
|
/// The debug location used to track a remark back to the source file.
|
|
|
|
struct RemarkLocation {
|
|
|
|
/// Absolute path of the source file corresponding to this remark.
|
|
|
|
StringRef SourceFilePath;
|
|
|
|
unsigned SourceLine;
|
|
|
|
unsigned SourceColumn;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Create wrappers for C Binding types (see CBindingWrapping.h).
|
|
|
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(RemarkLocation, LLVMRemarkDebugLocRef)
|
|
|
|
|
|
|
|
/// A key-value pair with a debug location that is used to display the remarks
|
|
|
|
/// at the right place in the source.
|
|
|
|
struct Argument {
|
|
|
|
StringRef Key;
|
|
|
|
// FIXME: We might want to be able to store other types than strings here.
|
|
|
|
StringRef Val;
|
|
|
|
// If set, the debug location corresponding to the value.
|
|
|
|
Optional<RemarkLocation> Loc;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Create wrappers for C Binding types (see CBindingWrapping.h).
|
|
|
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Argument, LLVMRemarkArgRef)
|
|
|
|
|
|
|
|
/// The type of the remark.
|
|
|
|
enum class Type {
|
|
|
|
Unknown,
|
|
|
|
Passed,
|
|
|
|
Missed,
|
|
|
|
Analysis,
|
|
|
|
AnalysisFPCommute,
|
|
|
|
AnalysisAliasing,
|
|
|
|
Failure,
|
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
|
|
|
First = Unknown,
|
|
|
|
Last = Failure
|
2019-03-19 22:11:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/// A remark type used for both emission and parsing.
|
|
|
|
struct Remark {
|
|
|
|
/// The type of the remark.
|
2019-03-20 02:52:40 +01:00
|
|
|
Type RemarkType = Type::Unknown;
|
2019-03-19 22:11:07 +01:00
|
|
|
|
|
|
|
/// Name of the pass that triggers the emission of this remark.
|
|
|
|
StringRef PassName;
|
|
|
|
|
|
|
|
/// Textual identifier for the remark (single-word, camel-case). Can be used
|
|
|
|
/// by external tools reading the output file for remarks to identify the
|
|
|
|
/// remark.
|
|
|
|
StringRef RemarkName;
|
|
|
|
|
|
|
|
/// Mangled name of the function that triggers the emssion of this remark.
|
|
|
|
StringRef FunctionName;
|
|
|
|
|
|
|
|
/// The location in the source file of the remark.
|
|
|
|
Optional<RemarkLocation> Loc;
|
|
|
|
|
|
|
|
/// If profile information is available, this is the number of times the
|
|
|
|
/// corresponding code was executed in a profile instrumentation run.
|
|
|
|
Optional<uint64_t> Hotness;
|
|
|
|
|
|
|
|
/// Arguments collected via the streaming interface.
|
2019-07-16 17:25:05 +02:00
|
|
|
SmallVector<Argument, 5> Args;
|
|
|
|
|
|
|
|
Remark() = default;
|
|
|
|
Remark(Remark &&) = default;
|
|
|
|
Remark &operator=(Remark &&) = default;
|
2019-03-19 22:11:07 +01:00
|
|
|
|
|
|
|
/// Return a message composed from the arguments as a string.
|
|
|
|
std::string getArgsAsMsg() const;
|
2019-07-16 17:25:05 +02:00
|
|
|
|
|
|
|
/// Clone this remark to explicitly ask for a copy.
|
|
|
|
Remark clone() const { return *this; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// In order to avoid unwanted copies, "delete" the copy constructor.
|
|
|
|
/// If a copy is needed, it should be done through `Remark::clone()`.
|
|
|
|
Remark(const Remark &) = default;
|
|
|
|
Remark& operator=(const Remark &) = default;
|
2019-03-19 22:11:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Create wrappers for C Binding types (see CBindingWrapping.h).
|
|
|
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Remark, LLVMRemarkEntryRef)
|
|
|
|
|
|
|
|
} // end namespace remarks
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif /* LLVM_REMARKS_REMARK_H */
|