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