1 | //===- bolt/Profile/YAMLProfileWriter.h - Write profile in YAML -*- C++ -*-===// |
---|---|
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #ifndef BOLT_PROFILE_YAML_PROFILE_WRITER_H |
10 | #define BOLT_PROFILE_YAML_PROFILE_WRITER_H |
11 | |
12 | #include "bolt/Profile/ProfileYAMLMapping.h" |
13 | #include "llvm/Support/raw_ostream.h" |
14 | #include <system_error> |
15 | |
16 | namespace llvm { |
17 | namespace bolt { |
18 | class BoltAddressTranslation; |
19 | class RewriteInstance; |
20 | |
21 | class YAMLProfileWriter { |
22 | YAMLProfileWriter() = delete; |
23 | |
24 | std::string Filename; |
25 | |
26 | std::unique_ptr<raw_fd_ostream> OS; |
27 | |
28 | public: |
29 | explicit YAMLProfileWriter(const std::string &Filename) |
30 | : Filename(Filename) {} |
31 | |
32 | /// Save execution profile for that instance. |
33 | std::error_code writeProfile(const RewriteInstance &RI); |
34 | |
35 | static yaml::bolt::BinaryFunctionProfile |
36 | convert(const BinaryFunction &BF, bool UseDFS, |
37 | const BoltAddressTranslation *BAT = nullptr); |
38 | |
39 | /// Set CallSiteInfo destination fields from \p Symbol and return a target |
40 | /// BinaryFunction for that symbol. |
41 | static const BinaryFunction * |
42 | setCSIDestination(const BinaryContext &BC, yaml::bolt::CallSiteInfo &CSI, |
43 | const MCSymbol *Symbol, const BoltAddressTranslation *BAT, |
44 | uint32_t Offset = 0); |
45 | }; |
46 | |
47 | } // namespace bolt |
48 | } // namespace llvm |
49 | |
50 | #endif |
51 |