diff options
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 8771f9e7f56d..537cb78611b4 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2895,44 +2895,46 @@ bool CodeGenModule::imbueXRayAttrs(llvm::Function *Fn, SourceLocation Loc, return true; } -ProfileList::ExclusionType -CodeGenModule::isFunctionBlockedByProfileList(llvm::Function *Fn, - SourceLocation Loc) const { +bool CodeGenModule::isFunctionBlockedByProfileList(llvm::Function *Fn, + SourceLocation Loc) const { const auto &ProfileList = getContext().getProfileList(); // If the profile list is empty, then instrument everything. if (ProfileList.isEmpty()) - return ProfileList::Allow; + return false; CodeGenOptions::ProfileInstrKind Kind = getCodeGenOpts().getProfileInstr(); // First, check the function name. - if (auto V = ProfileList.isFunctionExcluded(Fn->getName(), Kind)) + Optional<bool> V = ProfileList.isFunctionExcluded(Fn->getName(), Kind); + if (V) return *V; // Next, check the source location. - if (Loc.isValid()) - if (auto V = ProfileList.isLocationExcluded(Loc, Kind)) + if (Loc.isValid()) { + Optional<bool> V = ProfileList.isLocationExcluded(Loc, Kind); + if (V) return *V; + } // If location is unknown, this may be a compiler-generated function. Assume // it's located in the main file. auto &SM = Context.getSourceManager(); - if (const auto *MainFile = SM.getFileEntryForID(SM.getMainFileID())) - if (auto V = ProfileList.isFileExcluded(MainFile->getName(), Kind)) + if (const auto *MainFile = SM.getFileEntryForID(SM.getMainFileID())) { + Optional<bool> V = ProfileList.isFileExcluded(MainFile->getName(), Kind); + if (V) return *V; - return ProfileList.getDefault(Kind); + } + return ProfileList.getDefault(); } -ProfileList::ExclusionType -CodeGenModule::isFunctionBlockedFromProfileInstr(llvm::Function *Fn, - SourceLocation Loc) const { - auto V = isFunctionBlockedByProfileList(Fn, Loc); - if (V != ProfileList::Allow) - return V; +bool CodeGenModule::isFunctionBlockedFromProfileInstr( + llvm::Function *Fn, SourceLocation Loc) const { + if (isFunctionBlockedByProfileList(Fn, Loc)) + return true; auto NumGroups = getCodeGenOpts().ProfileTotalFunctionGroups; if (NumGroups > 1) { auto Group = llvm::crc32(arrayRefFromStringRef(Fn->getName())) % NumGroups; if (Group != getCodeGenOpts().ProfileSelectedFunctionGroup) - return ProfileList::Skip; + return true; } - return ProfileList::Allow; + return false; } bool CodeGenModule::MustBeEmitted(const ValueDecl *Global) { |
