1 | //===------ PGOOptions.cpp -- 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 | |
9 | #include "llvm/Support/PGOOptions.h" |
10 | #include "llvm/Support/VirtualFileSystem.h" |
11 | |
12 | using namespace llvm; |
13 | |
14 | PGOOptions::PGOOptions(std::string ProfileFile, std::string CSProfileGenFile, |
15 | std::string ProfileRemappingFile, |
16 | std::string MemoryProfile, |
17 | IntrusiveRefCntPtr<vfs::FileSystem> FS, PGOAction Action, |
18 | CSPGOAction CSAction, ColdFuncOpt ColdType, |
19 | bool DebugInfoForProfiling, bool PseudoProbeForProfiling, |
20 | bool AtomicCounterUpdate) |
21 | : ProfileFile(ProfileFile), CSProfileGenFile(CSProfileGenFile), |
22 | ProfileRemappingFile(ProfileRemappingFile), MemoryProfile(MemoryProfile), |
23 | Action(Action), CSAction(CSAction), ColdOptType(ColdType), |
24 | DebugInfoForProfiling(DebugInfoForProfiling || |
25 | (Action == SampleUse && !PseudoProbeForProfiling)), |
26 | PseudoProbeForProfiling(PseudoProbeForProfiling), |
27 | AtomicCounterUpdate(AtomicCounterUpdate), FS(std::move(FS)) { |
28 | // Note, we do allow ProfileFile.empty() for Action=IRUse LTO can |
29 | // callback with IRUse action without ProfileFile. |
30 | |
31 | // If there is a CSAction, PGOAction cannot be IRInstr or SampleUse. |
32 | assert(this->CSAction == NoCSAction || |
33 | (this->Action != IRInstr && this->Action != SampleUse)); |
34 | |
35 | // For CSIRInstr, CSProfileGenFile also needs to be nonempty. |
36 | assert(this->CSAction != CSIRInstr || !this->CSProfileGenFile.empty()); |
37 | |
38 | // If CSAction is CSIRUse, PGOAction needs to be IRUse as they share |
39 | // a profile. |
40 | assert(this->CSAction != CSIRUse || this->Action == IRUse); |
41 | |
42 | // Cannot optimize with MemProf profile during IR instrumentation. |
43 | assert(this->MemoryProfile.empty() || this->Action != PGOOptions::IRInstr); |
44 | |
45 | // If neither Action nor CSAction nor MemoryProfile are set, |
46 | // DebugInfoForProfiling or PseudoProbeForProfiling needs to be true. |
47 | assert(this->Action != NoAction || this->CSAction != NoCSAction || |
48 | !this->MemoryProfile.empty() || this->DebugInfoForProfiling || |
49 | this->PseudoProbeForProfiling); |
50 | |
51 | // If we need to use the profile, the VFS cannot be nullptr. |
52 | assert(this->FS || !(this->Action == IRUse || this->CSAction == CSIRUse || |
53 | !this->MemoryProfile.empty())); |
54 | } |
55 | |
56 | PGOOptions::PGOOptions(const PGOOptions &) = default; |
57 | |
58 | PGOOptions &PGOOptions::operator=(const PGOOptions &O) = default; |
59 | |
60 | PGOOptions::~PGOOptions() = default; |
61 | |