-
Notifications
You must be signed in to change notification settings - Fork 10.7k
/
InstrumentationRuntimeLibrary.h
56 lines (43 loc) · 1.82 KB
/
InstrumentationRuntimeLibrary.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//===- bolt/RuntimeLibs/InstrumentationRuntimeLibrary.h ---------*- 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 contains the declaration of the InstrumentationRuntimeLibrary
// class.
//
//===----------------------------------------------------------------------===//
#ifndef BOLT_RUNTIMELIBS_INSTRUMENTATION_RUNTIME_LIBRARY_H
#define BOLT_RUNTIMELIBS_INSTRUMENTATION_RUNTIME_LIBRARY_H
#include "bolt/Passes/InstrumentationSummary.h"
#include "bolt/RuntimeLibs/RuntimeLibrary.h"
#include <memory>
namespace llvm {
namespace bolt {
class InstrumentationRuntimeLibrary : public RuntimeLibrary {
public:
void setSummary(std::unique_ptr<InstrumentationSummary> &&S) {
Summary.swap(S);
}
void addRuntimeLibSections(std::vector<std::string> &SecNames) const final {
SecNames.push_back(".bolt.instr.counters");
}
void adjustCommandLineOptions(const BinaryContext &BC) const final;
void emitBinary(BinaryContext &BC, MCStreamer &Streamer) final;
void link(BinaryContext &BC, StringRef ToolPath, RuntimeDyld &RTDyld,
std::function<void(RuntimeDyld &)> OnLoad) final;
private:
std::string buildTables(BinaryContext &BC);
/// Create a non-allocatable ELF section with read-only tables necessary for
/// writing the instrumented data profile during program finish. The runtime
/// library needs to open the program executable file and read this data from
/// disk, this is not loaded by the system.
void emitTablesAsELFNote(BinaryContext &BC);
std::unique_ptr<InstrumentationSummary> Summary;
};
} // namespace bolt
} // namespace llvm
#endif