1*06c3fb27SDimitry Andric //===------ PGOOptions.cpp -- PGO option tunables --------------*- C++ -*--===// 2*06c3fb27SDimitry Andric // 3*06c3fb27SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*06c3fb27SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*06c3fb27SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*06c3fb27SDimitry Andric // 7*06c3fb27SDimitry Andric //===----------------------------------------------------------------------===// 8*06c3fb27SDimitry Andric 9*06c3fb27SDimitry Andric #include "llvm/Support/PGOOptions.h" 10*06c3fb27SDimitry Andric #include "llvm/Support/VirtualFileSystem.h" 11*06c3fb27SDimitry Andric 12*06c3fb27SDimitry Andric using namespace llvm; 13*06c3fb27SDimitry Andric 14*06c3fb27SDimitry Andric PGOOptions::PGOOptions(std::string ProfileFile, std::string CSProfileGenFile, 15*06c3fb27SDimitry Andric std::string ProfileRemappingFile, 16*06c3fb27SDimitry Andric std::string MemoryProfile, 17*06c3fb27SDimitry Andric IntrusiveRefCntPtr<vfs::FileSystem> FS, PGOAction Action, 18*06c3fb27SDimitry Andric CSPGOAction CSAction, bool DebugInfoForProfiling, 19*06c3fb27SDimitry Andric bool PseudoProbeForProfiling) 20*06c3fb27SDimitry Andric : ProfileFile(ProfileFile), CSProfileGenFile(CSProfileGenFile), 21*06c3fb27SDimitry Andric ProfileRemappingFile(ProfileRemappingFile), MemoryProfile(MemoryProfile), 22*06c3fb27SDimitry Andric Action(Action), CSAction(CSAction), 23*06c3fb27SDimitry Andric DebugInfoForProfiling(DebugInfoForProfiling || 24*06c3fb27SDimitry Andric (Action == SampleUse && !PseudoProbeForProfiling)), 25*06c3fb27SDimitry Andric PseudoProbeForProfiling(PseudoProbeForProfiling), FS(std::move(FS)) { 26*06c3fb27SDimitry Andric // Note, we do allow ProfileFile.empty() for Action=IRUse LTO can 27*06c3fb27SDimitry Andric // callback with IRUse action without ProfileFile. 28*06c3fb27SDimitry Andric 29*06c3fb27SDimitry Andric // If there is a CSAction, PGOAction cannot be IRInstr or SampleUse. 30*06c3fb27SDimitry Andric assert(this->CSAction == NoCSAction || 31*06c3fb27SDimitry Andric (this->Action != IRInstr && this->Action != SampleUse)); 32*06c3fb27SDimitry Andric 33*06c3fb27SDimitry Andric // For CSIRInstr, CSProfileGenFile also needs to be nonempty. 34*06c3fb27SDimitry Andric assert(this->CSAction != CSIRInstr || !this->CSProfileGenFile.empty()); 35*06c3fb27SDimitry Andric 36*06c3fb27SDimitry Andric // If CSAction is CSIRUse, PGOAction needs to be IRUse as they share 37*06c3fb27SDimitry Andric // a profile. 38*06c3fb27SDimitry Andric assert(this->CSAction != CSIRUse || this->Action == IRUse); 39*06c3fb27SDimitry Andric 40*06c3fb27SDimitry Andric // Cannot optimize with MemProf profile during IR instrumentation. 41*06c3fb27SDimitry Andric assert(this->MemoryProfile.empty() || this->Action != PGOOptions::IRInstr); 42*06c3fb27SDimitry Andric 43*06c3fb27SDimitry Andric // If neither Action nor CSAction nor MemoryProfile are set, 44*06c3fb27SDimitry Andric // DebugInfoForProfiling or PseudoProbeForProfiling needs to be true. 45*06c3fb27SDimitry Andric assert(this->Action != NoAction || this->CSAction != NoCSAction || 46*06c3fb27SDimitry Andric !this->MemoryProfile.empty() || this->DebugInfoForProfiling || 47*06c3fb27SDimitry Andric this->PseudoProbeForProfiling); 48*06c3fb27SDimitry Andric 49*06c3fb27SDimitry Andric // If we need to use the profile, the VFS cannot be nullptr. 50*06c3fb27SDimitry Andric assert(this->FS || !(this->Action == IRUse || this->CSAction == CSIRUse || 51*06c3fb27SDimitry Andric !this->MemoryProfile.empty())); 52*06c3fb27SDimitry Andric } 53*06c3fb27SDimitry Andric 54*06c3fb27SDimitry Andric PGOOptions::PGOOptions(const PGOOptions &) = default; 55*06c3fb27SDimitry Andric 56*06c3fb27SDimitry Andric PGOOptions &PGOOptions::operator=(const PGOOptions &O) = default; 57*06c3fb27SDimitry Andric 58*06c3fb27SDimitry Andric PGOOptions::~PGOOptions() = default; 59