diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Basic/ProfileList.cpp | 20 | ||||
-rw-r--r-- | clang/lib/CodeGen/BackendUtil.cpp | 42 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenAction.cpp | 4 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 3 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Driver/ToolChains/Flang.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 6 |
7 files changed, 41 insertions, 40 deletions
diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp index bea6557..2d37014 100644 --- a/clang/lib/Basic/ProfileList.cpp +++ b/clang/lib/Basic/ProfileList.cpp @@ -70,24 +70,24 @@ ProfileList::ProfileList(ArrayRef<std::string> Paths, SourceManager &SM) ProfileList::~ProfileList() = default; -static StringRef getSectionName(llvm::driver::ProfileInstrKind Kind) { +static StringRef getSectionName(CodeGenOptions::ProfileInstrKind Kind) { switch (Kind) { - case llvm::driver::ProfileInstrKind::ProfileNone: + case CodeGenOptions::ProfileNone: return ""; - case llvm::driver::ProfileInstrKind::ProfileClangInstr: + case CodeGenOptions::ProfileClangInstr: return "clang"; - case llvm::driver::ProfileInstrKind::ProfileIRInstr: + case CodeGenOptions::ProfileIRInstr: return "llvm"; - case llvm::driver::ProfileInstrKind::ProfileCSIRInstr: + case CodeGenOptions::ProfileCSIRInstr: return "csllvm"; case CodeGenOptions::ProfileIRSampleColdCov: return "sample-coldcov"; } - llvm_unreachable("Unhandled llvm::driver::ProfileInstrKind enum"); + llvm_unreachable("Unhandled CodeGenOptions::ProfileInstrKind enum"); } ProfileList::ExclusionType -ProfileList::getDefault(llvm::driver::ProfileInstrKind Kind) const { +ProfileList::getDefault(CodeGenOptions::ProfileInstrKind Kind) const { StringRef Section = getSectionName(Kind); // Check for "default:<type>" if (SCL->inSection(Section, "default", "allow")) @@ -118,7 +118,7 @@ ProfileList::inSection(StringRef Section, StringRef Prefix, std::optional<ProfileList::ExclusionType> ProfileList::isFunctionExcluded(StringRef FunctionName, - llvm::driver::ProfileInstrKind Kind) const { + CodeGenOptions::ProfileInstrKind Kind) const { StringRef Section = getSectionName(Kind); // Check for "function:<regex>=<case>" if (auto V = inSection(Section, "function", FunctionName)) @@ -132,13 +132,13 @@ ProfileList::isFunctionExcluded(StringRef FunctionName, std::optional<ProfileList::ExclusionType> ProfileList::isLocationExcluded(SourceLocation Loc, - llvm::driver::ProfileInstrKind Kind) const { + CodeGenOptions::ProfileInstrKind Kind) const { return isFileExcluded(SM.getFilename(SM.getFileLoc(Loc)), Kind); } std::optional<ProfileList::ExclusionType> ProfileList::isFileExcluded(StringRef FileName, - llvm::driver::ProfileInstrKind Kind) const { + CodeGenOptions::ProfileInstrKind Kind) const { StringRef Section = getSectionName(Kind); // Check for "source:<regex>=<case>" if (auto V = inSection(Section, "source", FileName)) diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 03e10b1..cd5fc48 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -123,10 +123,17 @@ namespace clang { extern llvm::cl::opt<bool> ClSanitizeGuardChecks; } +// Default filename used for profile generation. +static std::string getDefaultProfileGenName() { + return DebugInfoCorrelate || ProfileCorrelate != InstrProfCorrelator::NONE + ? "default_%m.proflite" + : "default_%m.profraw"; +} + // Path and name of file used for profile generation static std::string getProfileGenName(const CodeGenOptions &CodeGenOpts) { std::string FileName = CodeGenOpts.InstrProfileOutput.empty() - ? llvm::driver::getDefaultProfileGenName() + ? getDefaultProfileGenName() : CodeGenOpts.InstrProfileOutput; if (CodeGenOpts.ContinuousProfileSync) FileName = "%c" + FileName; @@ -828,12 +835,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline( if (CodeGenOpts.hasProfileIRInstr()) // -fprofile-generate. - PGOOpt = PGOOptions( - getProfileGenName(CodeGenOpts), "", "", - CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr, - PGOOptions::NoCSAction, llvm::ClPGOColdFuncAttr, - CodeGenOpts.DebugInfoForProfiling, - /*PseudoProbeForProfiling=*/false, CodeGenOpts.AtomicProfileUpdate); + PGOOpt = PGOOptions(getProfileGenName(CodeGenOpts), "", "", + CodeGenOpts.MemoryProfileUsePath, nullptr, + PGOOptions::IRInstr, PGOOptions::NoCSAction, + ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling, + /*PseudoProbeForProfiling=*/false, + CodeGenOpts.AtomicProfileUpdate); else if (CodeGenOpts.hasProfileIRUse()) { // -fprofile-use. auto CSAction = CodeGenOpts.hasProfileCSIRUse() ? PGOOptions::CSIRUse @@ -841,32 +848,31 @@ void EmitAssemblyHelper::RunOptimizationPipeline( PGOOpt = PGOOptions(CodeGenOpts.ProfileInstrumentUsePath, "", CodeGenOpts.ProfileRemappingFile, CodeGenOpts.MemoryProfileUsePath, VFS, - PGOOptions::IRUse, CSAction, llvm::ClPGOColdFuncAttr, + PGOOptions::IRUse, CSAction, ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling); } else if (!CodeGenOpts.SampleProfileFile.empty()) // -fprofile-sample-use PGOOpt = PGOOptions( CodeGenOpts.SampleProfileFile, "", CodeGenOpts.ProfileRemappingFile, CodeGenOpts.MemoryProfileUsePath, VFS, PGOOptions::SampleUse, - PGOOptions::NoCSAction, llvm::ClPGOColdFuncAttr, + PGOOptions::NoCSAction, ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling, CodeGenOpts.PseudoProbeForProfiling); else if (!CodeGenOpts.MemoryProfileUsePath.empty()) // -fmemory-profile-use (without any of the above options) - PGOOpt = - PGOOptions("", "", "", CodeGenOpts.MemoryProfileUsePath, VFS, - PGOOptions::NoAction, PGOOptions::NoCSAction, - llvm::ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling); + PGOOpt = PGOOptions("", "", "", CodeGenOpts.MemoryProfileUsePath, VFS, + PGOOptions::NoAction, PGOOptions::NoCSAction, + ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling); else if (CodeGenOpts.PseudoProbeForProfiling) // -fpseudo-probe-for-profiling - PGOOpt = PGOOptions("", "", "", /*MemoryProfile=*/"", nullptr, - PGOOptions::NoAction, PGOOptions::NoCSAction, - llvm::ClPGOColdFuncAttr, - CodeGenOpts.DebugInfoForProfiling, true); + PGOOpt = + PGOOptions("", "", "", /*MemoryProfile=*/"", nullptr, + PGOOptions::NoAction, PGOOptions::NoCSAction, + ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling, true); else if (CodeGenOpts.DebugInfoForProfiling) // -fdebug-info-for-profiling PGOOpt = PGOOptions("", "", "", /*MemoryProfile=*/"", nullptr, PGOOptions::NoAction, PGOOptions::NoCSAction, - llvm::ClPGOColdFuncAttr, true); + ClPGOColdFuncAttr, true); // Check to see if we want to generate a CS profile. if (CodeGenOpts.hasProfileCSIRInstr()) { diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp index 5493cc9..1f5eb42 100644 --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -273,8 +273,8 @@ void BackendConsumer::HandleTranslationUnit(ASTContext &C) { std::unique_ptr<llvm::ToolOutputFile> OptRecordFile = std::move(*OptRecordFileOrErr); - if (OptRecordFile && CodeGenOpts.getProfileUse() != - llvm::driver::ProfileInstrKind::ProfileNone) + if (OptRecordFile && + CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone) Ctx.setDiagnosticsHotnessRequested(true); if (CodeGenOpts.MisExpect) { diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 30aec87c..4193f0a 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -940,8 +940,7 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, } } - if (CGM.getCodeGenOpts().getProfileInstr() != - llvm::driver::ProfileInstrKind::ProfileNone) { + if (CGM.getCodeGenOpts().getProfileInstr() != CodeGenOptions::ProfileNone) { switch (CGM.isFunctionBlockedFromProfileInstr(Fn, Loc)) { case ProfileList::Skip: Fn->addFnAttr(llvm::Attribute::SkipProfile); diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 264f1bd..6d2c705 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -3601,7 +3601,7 @@ CodeGenModule::isFunctionBlockedByProfileList(llvm::Function *Fn, // If the profile list is empty, then instrument everything. if (ProfileList.isEmpty()) return ProfileList::Allow; - llvm::driver::ProfileInstrKind Kind = getCodeGenOpts().getProfileInstr(); + CodeGenOptions::ProfileInstrKind Kind = getCodeGenOpts().getProfileInstr(); // First, check the function name. if (auto V = ProfileList.isFunctionExcluded(Fn->getName(), Kind)) return *V; diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index e303631..dcc46469 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -883,10 +883,6 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA, // TODO: Handle interactions between -w, -pedantic, -Wall, -WOption Args.AddLastArg(CmdArgs, options::OPT_w); - // recognise options: fprofile-generate -fprofile-use= - Args.addAllArgs( - CmdArgs, {options::OPT_fprofile_generate, options::OPT_fprofile_use_EQ}); - // Forward flags for OpenMP. We don't do this if the current action is an // device offloading action other than OpenMP. if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ, diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 11d0dc6..9c33910 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1499,11 +1499,11 @@ static void setPGOUseInstrumentor(CodeGenOptions &Opts, // which is available (might be one or both). if (PGOReader->isIRLevelProfile() || PGOReader->hasMemoryProfile()) { if (PGOReader->hasCSIRLevelProfile()) - Opts.setProfileUse(llvm::driver::ProfileInstrKind::ProfileCSIRInstr); + Opts.setProfileUse(CodeGenOptions::ProfileCSIRInstr); else - Opts.setProfileUse(llvm::driver::ProfileInstrKind::ProfileIRInstr); + Opts.setProfileUse(CodeGenOptions::ProfileIRInstr); } else - Opts.setProfileUse(llvm::driver::ProfileInstrKind::ProfileClangInstr); + Opts.setProfileUse(CodeGenOptions::ProfileClangInstr); } void CompilerInvocation::setDefaultPointerAuthOptions( |