Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
14 | pmbaty | 1 | //===------ PGOOptions.h -- PGO option tunables ----------------*- 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 | /// \file |
||
9 | /// |
||
10 | /// Define option tunables for PGO. |
||
11 | /// |
||
12 | //===----------------------------------------------------------------------===// |
||
13 | |||
14 | #ifndef LLVM_SUPPORT_PGOOPTIONS_H |
||
15 | #define LLVM_SUPPORT_PGOOPTIONS_H |
||
16 | |||
17 | #include "llvm/Support/Error.h" |
||
18 | |||
19 | namespace llvm { |
||
20 | |||
21 | /// A struct capturing PGO tunables. |
||
22 | struct PGOOptions { |
||
23 | enum PGOAction { NoAction, IRInstr, IRUse, SampleUse }; |
||
24 | enum CSPGOAction { NoCSAction, CSIRInstr, CSIRUse }; |
||
25 | PGOOptions(std::string ProfileFile = "", std::string CSProfileGenFile = "", |
||
26 | std::string ProfileRemappingFile = "", PGOAction Action = NoAction, |
||
27 | CSPGOAction CSAction = NoCSAction, |
||
28 | bool DebugInfoForProfiling = false, |
||
29 | bool PseudoProbeForProfiling = false) |
||
30 | : ProfileFile(ProfileFile), CSProfileGenFile(CSProfileGenFile), |
||
31 | ProfileRemappingFile(ProfileRemappingFile), Action(Action), |
||
32 | CSAction(CSAction), DebugInfoForProfiling(DebugInfoForProfiling || |
||
33 | (Action == SampleUse && |
||
34 | !PseudoProbeForProfiling)), |
||
35 | PseudoProbeForProfiling(PseudoProbeForProfiling) { |
||
36 | // Note, we do allow ProfileFile.empty() for Action=IRUse LTO can |
||
37 | // callback with IRUse action without ProfileFile. |
||
38 | |||
39 | // If there is a CSAction, PGOAction cannot be IRInstr or SampleUse. |
||
40 | assert(this->CSAction == NoCSAction || |
||
41 | (this->Action != IRInstr && this->Action != SampleUse)); |
||
42 | |||
43 | // For CSIRInstr, CSProfileGenFile also needs to be nonempty. |
||
44 | assert(this->CSAction != CSIRInstr || !this->CSProfileGenFile.empty()); |
||
45 | |||
46 | // If CSAction is CSIRUse, PGOAction needs to be IRUse as they share |
||
47 | // a profile. |
||
48 | assert(this->CSAction != CSIRUse || this->Action == IRUse); |
||
49 | |||
50 | // If neither Action nor CSAction, DebugInfoForProfiling or |
||
51 | // PseudoProbeForProfiling needs to be true. |
||
52 | assert(this->Action != NoAction || this->CSAction != NoCSAction || |
||
53 | this->DebugInfoForProfiling || this->PseudoProbeForProfiling); |
||
54 | } |
||
55 | std::string ProfileFile; |
||
56 | std::string CSProfileGenFile; |
||
57 | std::string ProfileRemappingFile; |
||
58 | PGOAction Action; |
||
59 | CSPGOAction CSAction; |
||
60 | bool DebugInfoForProfiling; |
||
61 | bool PseudoProbeForProfiling; |
||
62 | }; |
||
63 | } // namespace llvm |
||
64 | |||
65 | #endif |