mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
83f4e4b65a
* Add support for uniquing strings in the remark streamer and emitting the string table in the remarks section. * Add parsing support for the string table in the RemarkParser. From this remark: ``` --- !Missed Pass: inline Name: NoDefinition DebugLoc: { File: 'test-suite/SingleSource/UnitTests/2002-04-17-PrintfChar.c', Line: 7, Column: 3 } Function: printArgsNoRet Args: - Callee: printf - String: ' will not be inlined into ' - Caller: printArgsNoRet DebugLoc: { File: 'test-suite/SingleSource/UnitTests/2002-04-17-PrintfChar.c', Line: 6, Column: 0 } - String: ' because its definition is unavailable' ... ``` to: ``` --- !Missed Pass: 0 Name: 1 DebugLoc: { File: 3, Line: 7, Column: 3 } Function: 2 Args: - Callee: 4 - String: 5 - Caller: 2 DebugLoc: { File: 3, Line: 6, Column: 0 } - String: 6 ... ``` And the string table in the .remarks/__remarks section containing: ``` inline\0NoDefinition\0printArgsNoRet\0 test-suite/SingleSource/UnitTests/2002-04-17-PrintfChar.c\0printf\0 will not be inlined into \0 because its definition is unavailable\0 ``` This is mostly supposed to be used for testing purposes, but it gives us a 2x reduction in the remark size, and is an incremental change for the updates to the remarks file format. Differential Revision: https://reviews.llvm.org/D60227 llvm-svn: 359050
65 lines
2.0 KiB
C++
65 lines
2.0 KiB
C++
//===-- 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 provides an interface for parsing remarks in LLVM.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_REMARKS_REMARK_PARSER_H
|
|
#define LLVM_REMARKS_REMARK_PARSER_H
|
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
#include "llvm/ADT/StringRef.h"
|
|
#include "llvm/Remarks/Remark.h"
|
|
#include "llvm/Support/Error.h"
|
|
#include <memory>
|
|
|
|
namespace llvm {
|
|
namespace remarks {
|
|
|
|
struct ParserImpl;
|
|
|
|
/// Parser used to parse a raw buffer to remarks::Remark objects.
|
|
struct Parser {
|
|
/// The hidden implementation of the parser.
|
|
std::unique_ptr<ParserImpl> Impl;
|
|
|
|
/// Create a parser parsing \p Buffer to Remark objects.
|
|
/// This constructor should be only used for parsing YAML remarks.
|
|
Parser(StringRef Buffer);
|
|
|
|
/// Create a parser parsing \p Buffer to Remark objects, using \p StrTabBuf as
|
|
/// string table.
|
|
/// This constructor should be only used for parsing YAML remarks.
|
|
Parser(StringRef Buffer, StringRef StrTabBuf);
|
|
|
|
// Needed because ParserImpl is an incomplete type.
|
|
~Parser();
|
|
|
|
/// Returns an empty Optional if it reached the end.
|
|
/// Returns a valid remark otherwise.
|
|
Expected<const Remark *> getNext() const;
|
|
};
|
|
|
|
/// In-memory representation of the string table parsed from a buffer (e.g. the
|
|
/// remarks section).
|
|
struct ParsedStringTable {
|
|
/// The buffer mapped from the section contents.
|
|
StringRef Buffer;
|
|
/// Collection of offsets in the buffer for each string entry.
|
|
SmallVector<size_t, 8> Offsets;
|
|
|
|
Expected<StringRef> operator[](size_t Index);
|
|
ParsedStringTable(StringRef Buffer);
|
|
};
|
|
|
|
} // end namespace remarks
|
|
} // end namespace llvm
|
|
|
|
#endif /* LLVM_REMARKS_REMARK_PARSER_H */
|