1c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===- InstrProf.h - Instrumented profiling format support ------*- C++ -*-===// 2c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// 3c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// The LLVM Compiler Infrastructure 4c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// 5c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// This file is distributed under the University of Illinois Open Source 6c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// License. See LICENSE.TXT for details. 7c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// 8c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===----------------------------------------------------------------------===// 9c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// 10c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// Instrumentation-based profiling data is generated by instrumented 11c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// binaries through library functions in compiler-rt, and read by the clang 12c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// frontend to feed PGO. 13c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// 14c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===----------------------------------------------------------------------===// 15c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 16c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#ifndef LLVM_PROFILEDATA_INSTRPROF_H 17c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#define LLVM_PROFILEDATA_INSTRPROF_H 18c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 19c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/ArrayRef.h" 20c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/STLExtras.h" 21c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/StringRef.h" 22c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/StringSet.h" 23c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/Triple.h" 24c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/IR/GlobalValue.h" 25c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/IR/ProfileSummary.h" 26c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ProfileData/InstrProfData.inc" 27c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Support/Compiler.h" 28c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Support/Endian.h" 29c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Support/Error.h" 30c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Support/ErrorHandling.h" 31c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Support/Host.h" 32c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Support/MD5.h" 33c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Support/MathExtras.h" 34c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Support/raw_ostream.h" 35c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <algorithm> 36c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <cassert> 37c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <cstddef> 38c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <cstdint> 39c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <cstring> 40c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <list> 41c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <memory> 42c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <string> 43c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <system_error> 44c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <utility> 45c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <vector> 46c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 47c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotnamespace llvm { 48c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 49c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass Function; 50c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass GlobalVariable; 51c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotstruct InstrProfRecord; 52c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass InstrProfSymtab; 53c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass Instruction; 54c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MDNode; 55c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass Module; 56c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 57c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotenum InstrProfSectKind { 58c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#define INSTR_PROF_SECT_ENTRY(Kind, SectNameCommon, SectNameCoff, Prefix) Kind, 59c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ProfileData/InstrProfData.inc" 60c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}; 61c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 62c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the name of the profile section corresponding to \p IPSK. 63c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// 64c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// The name of the section depends on the object format type \p OF. If 65c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \p AddSegmentInfo is true, a segment prefix and additional linker hints may 66c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// be added to the section name (this is the default). 67c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotstd::string getInstrProfSectionName(InstrProfSectKind IPSK, 68c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Triple::ObjectFormatType OF, 69c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot bool AddSegmentInfo = true); 70c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 71c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the name profile runtime entry point to do value profiling 72c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// for a given site. 73c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline StringRef getInstrProfValueProfFuncName() { 74c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return INSTR_PROF_VALUE_PROF_FUNC_STR; 75c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 76c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 77c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the name profile runtime entry point to do value range profiling. 78c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline StringRef getInstrProfValueRangeProfFuncName() { 79c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return INSTR_PROF_VALUE_RANGE_PROF_FUNC_STR; 80c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 81c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 82c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the name prefix of variables containing instrumented function names. 83c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline StringRef getInstrProfNameVarPrefix() { return "__profn_"; } 84c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 85c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the name prefix of variables containing per-function control data. 86c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline StringRef getInstrProfDataVarPrefix() { return "__profd_"; } 87c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 88c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the name prefix of profile counter variables. 89c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline StringRef getInstrProfCountersVarPrefix() { return "__profc_"; } 90c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 91c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the name prefix of value profile variables. 92c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline StringRef getInstrProfValuesVarPrefix() { return "__profvp_"; } 93c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 94c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the name of value profile node array variables: 95c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline StringRef getInstrProfVNodesVarName() { return "__llvm_prf_vnodes"; } 96c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 97c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the name prefix of the COMDAT group for instrumentation variables 98c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// associated with a COMDAT function. 99c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline StringRef getInstrProfComdatPrefix() { return "__profv_"; } 100c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 101c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the name of the variable holding the strings (possibly compressed) 102c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// of all function's PGO names. 103c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline StringRef getInstrProfNamesVarName() { 104c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return "__llvm_prf_nm"; 105c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 106c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 107c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the name of a covarage mapping variable (internal linkage) 108c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// for each instrumented source module. Such variables are allocated 109c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// in the __llvm_covmap section. 110c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline StringRef getCoverageMappingVarName() { 111c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return "__llvm_coverage_mapping"; 112c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 113c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 114c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the name of the internal variable recording the array 115c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// of PGO name vars referenced by the coverage mapping. The owning 116c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// functions of those names are not emitted by FE (e.g, unused inline 117c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// functions.) 118c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline StringRef getCoverageUnusedNamesVarName() { 119c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return "__llvm_coverage_names"; 120c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 121c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 122c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the name of function that registers all the per-function control 123c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// data at program startup time by calling __llvm_register_function. This 124c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// function has internal linkage and is called by __llvm_profile_init 125c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// runtime method. This function is not generated for these platforms: 126c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Darwin, Linux, and FreeBSD. 127c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline StringRef getInstrProfRegFuncsName() { 128c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return "__llvm_profile_register_functions"; 129c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 130c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 131c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the name of the runtime interface that registers per-function control 132c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// data for one instrumented function. 133c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline StringRef getInstrProfRegFuncName() { 134c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return "__llvm_profile_register_function"; 135c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 136c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 137c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the name of the runtime interface that registers the PGO name strings. 138c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline StringRef getInstrProfNamesRegFuncName() { 139c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return "__llvm_profile_register_names_function"; 140c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 141c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 142c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the name of the runtime initialization method that is generated by 143c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// the compiler. The function calls __llvm_profile_register_functions and 144c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// __llvm_profile_override_default_filename functions if needed. This function 145c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// has internal linkage and invoked at startup time via init_array. 146c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline StringRef getInstrProfInitFuncName() { return "__llvm_profile_init"; } 147c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 148c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the name of the hook variable defined in profile runtime library. 149c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// A reference to the variable causes the linker to link in the runtime 150c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// initialization module (which defines the hook variable). 151c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline StringRef getInstrProfRuntimeHookVarName() { 152c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_RUNTIME_VAR); 153c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 154c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 155c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the name of the compiler generated function that references the 156c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// runtime hook variable. The function is a weak global. 157c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline StringRef getInstrProfRuntimeHookVarUseFuncName() { 158c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return "__llvm_profile_runtime_user"; 159c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 160c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 161c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the marker used to separate PGO names during serialization. 162c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline StringRef getInstrProfNameSeparator() { return "\01"; } 163c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 164c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the modified name for function \c F suitable to be 165c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// used the key for profile lookup. Variable \c InLTO indicates if this 166c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// is called in LTO optimization passes. 167c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotstd::string getPGOFuncName(const Function &F, bool InLTO = false, 168c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t Version = INSTR_PROF_INDEX_VERSION); 169c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 170c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the modified name for a function suitable to be 171c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// used the key for profile lookup. The function's original 172c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// name is \c RawFuncName and has linkage of type \c Linkage. 173c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// The function is defined in module \c FileName. 174c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotstd::string getPGOFuncName(StringRef RawFuncName, 175c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot GlobalValue::LinkageTypes Linkage, 176c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot StringRef FileName, 177c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t Version = INSTR_PROF_INDEX_VERSION); 178c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 179c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the name of the global variable used to store a function 180c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// name in PGO instrumentation. \c FuncName is the name of the function 181c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// returned by the \c getPGOFuncName call. 182c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotstd::string getPGOFuncNameVarName(StringRef FuncName, 183c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot GlobalValue::LinkageTypes Linkage); 184c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 185c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Create and return the global variable for function name used in PGO 186c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// instrumentation. \c FuncName is the name of the function returned 187c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// by \c getPGOFuncName call. 188c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team RobotGlobalVariable *createPGOFuncNameVar(Function &F, StringRef PGOFuncName); 189c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 190c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Create and return the global variable for function name used in PGO 191c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// instrumentation. /// \c FuncName is the name of the function 192c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// returned by \c getPGOFuncName call, \c M is the owning module, 193c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// and \c Linkage is the linkage of the instrumented function. 194c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team RobotGlobalVariable *createPGOFuncNameVar(Module &M, 195c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot GlobalValue::LinkageTypes Linkage, 196c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot StringRef PGOFuncName); 197c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 198c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the initializer in string of the PGO name var \c NameVar. 199c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team RobotStringRef getPGOFuncNameVarInitializer(GlobalVariable *NameVar); 200c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 201c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Given a PGO function name, remove the filename prefix and return 202c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// the original (static) function name. 203c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team RobotStringRef getFuncNameWithoutPrefix(StringRef PGOFuncName, 204c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot StringRef FileName = "<unknown>"); 205c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 206c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Given a vector of strings (function PGO names) \c NameStrs, the 207c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// method generates a combined string \c Result thatis ready to be 208c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// serialized. The \c Result string is comprised of three fields: 209c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// The first field is the legnth of the uncompressed strings, and the 210c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// the second field is the length of the zlib-compressed string. 211c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Both fields are encoded in ULEB128. If \c doCompress is false, the 212c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// third field is the uncompressed strings; otherwise it is the 213c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// compressed string. When the string compression is off, the 214c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// second field will have value zero. 215c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team RobotError collectPGOFuncNameStrings(ArrayRef<std::string> NameStrs, 216c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot bool doCompression, std::string &Result); 217c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 218c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Produce \c Result string with the same format described above. The input 219c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// is vector of PGO function name variables that are referenced. 220c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team RobotError collectPGOFuncNameStrings(ArrayRef<GlobalVariable *> NameVars, 221c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot std::string &Result, bool doCompression = true); 222c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 223c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \c NameStrings is a string composed of one of more sub-strings encoded in 224c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// the format described above. The substrings are separated by 0 or more zero 225c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// bytes. This method decodes the string and populates the \c Symtab. 226c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team RobotError readPGOFuncNameStrings(StringRef NameStrings, InstrProfSymtab &Symtab); 227c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 228c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Check if INSTR_PROF_RAW_VERSION_VAR is defined. This global is only being 229c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// set in IR PGO compilation. 230c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotbool isIRPGOFlagSet(const Module *M); 231c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 232c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Check if we can safely rename this Comdat function. Instances of the same 233c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// comdat function may have different control flows thus can not share the 234c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// same counter variable. 235c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotbool canRenameComdatFunc(const Function &F, bool CheckAddressTaken = false); 236c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 237c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotenum InstrProfValueKind : uint32_t { 238c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#define VALUE_PROF_KIND(Enumerator, Value) Enumerator = Value, 239c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ProfileData/InstrProfData.inc" 240c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}; 241c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 242c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Get the value profile data for value site \p SiteIdx from \p InstrProfR 243c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// and annotate the instruction \p Inst with the value profile meta data. 244c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Annotate up to \p MaxMDCount (default 3) number of records per value site. 245c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotvoid annotateValueSite(Module &M, Instruction &Inst, 246c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const InstrProfRecord &InstrProfR, 247c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot InstrProfValueKind ValueKind, uint32_t SiteIndx, 248c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint32_t MaxMDCount = 3); 249c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 250c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Same as the above interface but using an ArrayRef, as well as \p Sum. 251c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotvoid annotateValueSite(Module &M, Instruction &Inst, 252c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot ArrayRef<InstrProfValueData> VDs, 253c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t Sum, InstrProfValueKind ValueKind, 254c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint32_t MaxMDCount); 255c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 256c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Extract the value profile data from \p Inst which is annotated with 257c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// value profile meta data. Return false if there is no value data annotated, 258c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// otherwise return true. 259c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotbool getValueProfDataFromInst(const Instruction &Inst, 260c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot InstrProfValueKind ValueKind, 261c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint32_t MaxNumValueData, 262c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot InstrProfValueData ValueData[], 263c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint32_t &ActualNumValueData, uint64_t &TotalC); 264c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 265c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline StringRef getPGOFuncNameMetadataName() { return "PGOFuncName"; } 266c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 267c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the PGOFuncName meta data associated with a function. 268c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team RobotMDNode *getPGOFuncNameMetadata(const Function &F); 269c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 270c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Create the PGOFuncName meta data if PGOFuncName is different from 271c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// function's raw name. This should only apply to internal linkage functions 272c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// declared by users only. 273c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotvoid createPGOFuncNameMetadata(Function &F, StringRef PGOFuncName); 274c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 275c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Check if we can use Comdat for profile variables. This will eliminate 276c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// the duplicated profile variables for Comdat functions. 277c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotbool needsComdatForCounter(const Function &F, const Module &M); 278c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 279c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotconst std::error_category &instrprof_category(); 280c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 281c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotenum class instrprof_error { 282c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot success = 0, 283c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot eof, 284c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot unrecognized_format, 285c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot bad_magic, 286c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot bad_header, 287c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot unsupported_version, 288c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot unsupported_hash_type, 289c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot too_large, 290c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot truncated, 291c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot malformed, 292c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot unknown_function, 293c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot hash_mismatch, 294c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot count_mismatch, 295c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot counter_overflow, 296c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot value_site_count_mismatch, 297c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot compress_failed, 298c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uncompress_failed, 299c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot empty_raw_profile 300c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}; 301c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 302c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline std::error_code make_error_code(instrprof_error E) { 303c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return std::error_code(static_cast<int>(E), instrprof_category()); 304c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 305c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 306c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass InstrProfError : public ErrorInfo<InstrProfError> { 307c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic: 308c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot InstrProfError(instrprof_error Err) : Err(Err) { 309c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot assert(Err != instrprof_error::success && "Not an error"); 310c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 311c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 312c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot std::string message() const override; 313c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 314c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot void log(raw_ostream &OS) const override { OS << message(); } 315c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 316c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot std::error_code convertToErrorCode() const override { 317c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return make_error_code(Err); 318c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 319c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 320c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot instrprof_error get() const { return Err; } 321c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 322c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Consume an Error and return the raw enum value contained within it. The 323c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Error must either be a success value, or contain a single InstrProfError. 324c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot static instrprof_error take(Error E) { 325c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot auto Err = instrprof_error::success; 326c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot handleAllErrors(std::move(E), [&Err](const InstrProfError &IPE) { 327c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot assert(Err == instrprof_error::success && "Multiple errors encountered"); 328c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Err = IPE.get(); 329c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot }); 330c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return Err; 331c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 332c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 333c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot static char ID; 334c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 335c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprivate: 336c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot instrprof_error Err; 337c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}; 338c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 339c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass SoftInstrProfErrors { 340c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Count the number of soft instrprof_errors encountered and keep track of 341c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// the first such error for reporting purposes. 342c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 343c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// The first soft error encountered. 344c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot instrprof_error FirstError = instrprof_error::success; 345c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 346c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// The number of hash mismatches. 347c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot unsigned NumHashMismatches = 0; 348c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 349c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// The number of count mismatches. 350c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot unsigned NumCountMismatches = 0; 351c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 352c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// The number of counter overflows. 353c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot unsigned NumCounterOverflows = 0; 354c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 355c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// The number of value site count mismatches. 356c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot unsigned NumValueSiteCountMismatches = 0; 357c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 358c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic: 359c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot SoftInstrProfErrors() = default; 360c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 361c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot ~SoftInstrProfErrors() { 362c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot assert(FirstError == instrprof_error::success && 363c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot "Unchecked soft error encountered"); 364c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 365c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 366c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Track a soft error (\p IE) and increment its associated counter. 367c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot void addError(instrprof_error IE); 368c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 369c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Get the number of hash mismatches. 370c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot unsigned getNumHashMismatches() const { return NumHashMismatches; } 371c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 372c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Get the number of count mismatches. 373c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot unsigned getNumCountMismatches() const { return NumCountMismatches; } 374c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 375c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Get the number of counter overflows. 376c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot unsigned getNumCounterOverflows() const { return NumCounterOverflows; } 377c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 378c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Get the number of value site count mismatches. 379c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot unsigned getNumValueSiteCountMismatches() const { 380c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return NumValueSiteCountMismatches; 381c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 382c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 383c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Return the first encountered error and reset FirstError to a success 384c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// value. 385c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Error takeError() { 386c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot if (FirstError == instrprof_error::success) 387c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return Error::success(); 388c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot auto E = make_error<InstrProfError>(FirstError); 389c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot FirstError = instrprof_error::success; 390c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return E; 391c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 392c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}; 393c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 394c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotnamespace object { 395c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 396c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass SectionRef; 397c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 398c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} // end namespace object 399c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 400c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotnamespace IndexedInstrProf { 401c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 402c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotuint64_t ComputeHash(StringRef K); 403c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 404c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} // end namespace IndexedInstrProf 405c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 406c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// A symbol table used for function PGO name look-up with keys 407c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// (such as pointers, md5hash values) to the function. A function's 408c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// PGO name or name's md5hash are used in retrieving the profile 409c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// data of the function. See \c getPGOFuncName() method for details 410c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// on how PGO name is formed. 411c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass InstrProfSymtab { 412c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic: 413c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot typedef std::vector<std::pair<uint64_t, uint64_t>> AddrHashMap; 414c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 415c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprivate: 416c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot StringRef Data; 417c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t Address = 0; 418c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // Unique name strings. 419c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot StringSet<> NameTab; 420c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // A map from MD5 keys to function name strings. 421c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot std::vector<std::pair<uint64_t, StringRef>> MD5NameMap; 422c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // A map from MD5 keys to function define. We only populate this map 423c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // when build the Symtab from a Module. 424c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot std::vector<std::pair<uint64_t, Function *>> MD5FuncMap; 425c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // A map from function runtime address to function name MD5 hash. 426c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // This map is only populated and used by raw instr profile reader. 427c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot AddrHashMap AddrToMD5Map; 428c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 429c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic: 430c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot InstrProfSymtab() = default; 431c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 432c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Create InstrProfSymtab from an object file section which 433c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// contains function PGO names. When section may contain raw 434c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// string data or string data in compressed form. This method 435c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// only initialize the symtab with reference to the data and 436c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// the section base address. The decompression will be delayed 437c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// until before it is used. See also \c create(StringRef) method. 438c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Error create(object::SectionRef &Section); 439c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 440c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// This interface is used by reader of CoverageMapping test 441c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// format. 442c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot inline Error create(StringRef D, uint64_t BaseAddr); 443c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 444c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// \c NameStrings is a string composed of one of more sub-strings 445c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// encoded in the format described in \c collectPGOFuncNameStrings. 446c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// This method is a wrapper to \c readPGOFuncNameStrings method. 447c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot inline Error create(StringRef NameStrings); 448c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 449c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// A wrapper interface to populate the PGO symtab with functions 450c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// decls from module \c M. This interface is used by transformation 451c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// passes such as indirect function call promotion. Variable \c InLTO 452c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// indicates if this is called from LTO optimization passes. 453c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot void create(Module &M, bool InLTO = false); 454c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 455c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Create InstrProfSymtab from a set of names iteratable from 456c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// \p IterRange. This interface is used by IndexedProfReader. 457c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot template <typename NameIterRange> void create(const NameIterRange &IterRange); 458c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 459c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // If the symtab is created by a series of calls to \c addFuncName, \c 460c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // finalizeSymtab needs to be called before looking up function names. 461c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // This is required because the underlying map is a vector (for space 462c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // efficiency) which needs to be sorted. 463c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot inline void finalizeSymtab(); 464c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 465c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Update the symtab by adding \p FuncName to the table. This interface 466c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// is used by the raw and text profile readers. 467c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot void addFuncName(StringRef FuncName) { 468c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot auto Ins = NameTab.insert(FuncName); 469c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot if (Ins.second) 470c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot MD5NameMap.push_back(std::make_pair( 471c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot IndexedInstrProf::ComputeHash(FuncName), Ins.first->getKey())); 472c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 473c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 474c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Map a function address to its name's MD5 hash. This interface 475c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// is only used by the raw profiler reader. 476c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot void mapAddress(uint64_t Addr, uint64_t MD5Val) { 477c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot AddrToMD5Map.push_back(std::make_pair(Addr, MD5Val)); 478c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 479c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 480c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot AddrHashMap &getAddrHashMap() { return AddrToMD5Map; } 481c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 482c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Return function's PGO name from the function name's symbol 483c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// address in the object file. If an error occurs, return 484c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// an empty string. 485c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot StringRef getFuncName(uint64_t FuncNameAddress, size_t NameSize); 486c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 487c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Return function's PGO name from the name's md5 hash value. 488c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// If not found, return an empty string. 489c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot inline StringRef getFuncName(uint64_t FuncMD5Hash); 490c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 491c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Return function from the name's md5 hash. Return nullptr if not found. 492c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot inline Function *getFunction(uint64_t FuncMD5Hash); 493c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 494c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Return the function's original assembly name by stripping off 495c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// the prefix attached (to symbols with priviate linkage). For 496c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// global functions, it returns the same string as getFuncName. 497c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot inline StringRef getOrigFuncName(uint64_t FuncMD5Hash); 498c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 499c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Return the name section data. 500c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot inline StringRef getNameData() const { return Data; } 501c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}; 502c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 503c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team RobotError InstrProfSymtab::create(StringRef D, uint64_t BaseAddr) { 504c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Data = D; 505c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Address = BaseAddr; 506c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return Error::success(); 507c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 508c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 509c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team RobotError InstrProfSymtab::create(StringRef NameStrings) { 510c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return readPGOFuncNameStrings(NameStrings, *this); 511c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 512c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 513c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robottemplate <typename NameIterRange> 514c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotvoid InstrProfSymtab::create(const NameIterRange &IterRange) { 515c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot for (auto Name : IterRange) 516c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot addFuncName(Name); 517c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 518c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot finalizeSymtab(); 519c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 520c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 521c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotvoid InstrProfSymtab::finalizeSymtab() { 522c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot std::sort(MD5NameMap.begin(), MD5NameMap.end(), less_first()); 523c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot std::sort(MD5FuncMap.begin(), MD5FuncMap.end(), less_first()); 524c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot std::sort(AddrToMD5Map.begin(), AddrToMD5Map.end(), less_first()); 525c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot AddrToMD5Map.erase(std::unique(AddrToMD5Map.begin(), AddrToMD5Map.end()), 526c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot AddrToMD5Map.end()); 527c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 528c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 529c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team RobotStringRef InstrProfSymtab::getFuncName(uint64_t FuncMD5Hash) { 530c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot auto Result = 531c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot std::lower_bound(MD5NameMap.begin(), MD5NameMap.end(), FuncMD5Hash, 532c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot [](const std::pair<uint64_t, std::string> &LHS, 533c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t RHS) { return LHS.first < RHS; }); 534c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot if (Result != MD5NameMap.end() && Result->first == FuncMD5Hash) 535c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return Result->second; 536c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return StringRef(); 537c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 538c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 539c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team RobotFunction* InstrProfSymtab::getFunction(uint64_t FuncMD5Hash) { 540c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot auto Result = 541c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot std::lower_bound(MD5FuncMap.begin(), MD5FuncMap.end(), FuncMD5Hash, 542c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot [](const std::pair<uint64_t, Function*> &LHS, 543c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t RHS) { return LHS.first < RHS; }); 544c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot if (Result != MD5FuncMap.end() && Result->first == FuncMD5Hash) 545c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return Result->second; 546c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return nullptr; 547c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 548c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 549c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// See also getPGOFuncName implementation. These two need to be 550c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// matched. 551c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team RobotStringRef InstrProfSymtab::getOrigFuncName(uint64_t FuncMD5Hash) { 552c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot StringRef PGOName = getFuncName(FuncMD5Hash); 553c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot size_t S = PGOName.find_first_of(':'); 554c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot if (S == StringRef::npos) 555c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return PGOName; 556c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return PGOName.drop_front(S + 1); 557c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 558c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 559c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotstruct InstrProfValueSiteRecord { 560c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Value profiling data pairs at a given value site. 561c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot std::list<InstrProfValueData> ValueData; 562c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 563c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot InstrProfValueSiteRecord() { ValueData.clear(); } 564c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot template <class InputIterator> 565c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot InstrProfValueSiteRecord(InputIterator F, InputIterator L) 566c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot : ValueData(F, L) {} 567c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 568c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Sort ValueData ascending by Value 569c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot void sortByTargetValues() { 570c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot ValueData.sort( 571c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot [](const InstrProfValueData &left, const InstrProfValueData &right) { 572c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return left.Value < right.Value; 573c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot }); 574c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 575c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Sort ValueData Descending by Count 576c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot inline void sortByCount(); 577c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 578c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Merge data from another InstrProfValueSiteRecord 579c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Optionally scale merged counts by \p Weight. 580c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot void merge(SoftInstrProfErrors &SIPE, InstrProfValueSiteRecord &Input, 581c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t Weight = 1); 582c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Scale up value profile data counts. 583c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot void scale(SoftInstrProfErrors &SIPE, uint64_t Weight); 584c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}; 585c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 586c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Profiling information for a single function. 587c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotstruct InstrProfRecord { 588c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot StringRef Name; 589c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t Hash; 590c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot std::vector<uint64_t> Counts; 591c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot SoftInstrProfErrors SIPE; 592c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 593c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot InstrProfRecord() = default; 594c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot InstrProfRecord(StringRef Name, uint64_t Hash, std::vector<uint64_t> Counts) 595c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot : Name(Name), Hash(Hash), Counts(std::move(Counts)) {} 596c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 597c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot typedef std::vector<std::pair<uint64_t, uint64_t>> ValueMapType; 598c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 599c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Return the number of value profile kinds with non-zero number 600c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// of profile sites. 601c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot inline uint32_t getNumValueKinds() const; 602c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 603c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Return the number of instrumented sites for ValueKind. 604c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot inline uint32_t getNumValueSites(uint32_t ValueKind) const; 605c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 606c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Return the total number of ValueData for ValueKind. 607c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot inline uint32_t getNumValueData(uint32_t ValueKind) const; 608c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 609c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Return the number of value data collected for ValueKind at profiling 610c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// site: Site. 611c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot inline uint32_t getNumValueDataForSite(uint32_t ValueKind, 612c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint32_t Site) const; 613c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 614c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Return the array of profiled values at \p Site. If \p TotalC 615c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// is not null, the total count of all target values at this site 616c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// will be stored in \c *TotalC. 617c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot inline std::unique_ptr<InstrProfValueData[]> 618c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot getValueForSite(uint32_t ValueKind, uint32_t Site, 619c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t *TotalC = nullptr) const; 620c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 621c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Get the target value/counts of kind \p ValueKind collected at site 622c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// \p Site and store the result in array \p Dest. Return the total 623c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// counts of all target values at this site. 624c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot inline uint64_t getValueForSite(InstrProfValueData Dest[], uint32_t ValueKind, 625c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint32_t Site) const; 626c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 627c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Reserve space for NumValueSites sites. 628c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot inline void reserveSites(uint32_t ValueKind, uint32_t NumValueSites); 629c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 630c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Add ValueData for ValueKind at value Site. 631c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot void addValueData(uint32_t ValueKind, uint32_t Site, 632c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot InstrProfValueData *VData, uint32_t N, 633c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot ValueMapType *ValueMap); 634c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 635c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Merge the counts in \p Other into this one. 636c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Optionally scale merged counts by \p Weight. 637c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot void merge(InstrProfRecord &Other, uint64_t Weight = 1); 638c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 639c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Scale up profile counts (including value profile data) by 640c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// \p Weight. 641c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot void scale(uint64_t Weight); 642c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 643c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Sort value profile data (per site) by count. 644c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot void sortValueData() { 645c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind) { 646c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot std::vector<InstrProfValueSiteRecord> &SiteRecords = 647c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot getValueSitesForKind(Kind); 648c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot for (auto &SR : SiteRecords) 649c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot SR.sortByCount(); 650c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 651c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 652c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 653c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Clear value data entries and edge counters. 654c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot void Clear() { 655c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Counts.clear(); 656c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot clearValueData(); 657c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 658c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 659c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Clear value data entries 660c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot void clearValueData() { 661c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind) 662c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot getValueSitesForKind(Kind).clear(); 663c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 664c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 665c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Get the error contained within the record's soft error counter. 666c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Error takeError() { return SIPE.takeError(); } 667c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 668c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprivate: 669c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot std::vector<InstrProfValueSiteRecord> IndirectCallSites; 670c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot std::vector<InstrProfValueSiteRecord> MemOPSizes; 671c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const std::vector<InstrProfValueSiteRecord> & 672c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 673c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot getValueSitesForKind(uint32_t ValueKind) const { 674c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot switch (ValueKind) { 675c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot case IPVK_IndirectCallTarget: 676c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return IndirectCallSites; 677c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot case IPVK_MemOPSize: 678c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return MemOPSizes; 679c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot default: 680c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot llvm_unreachable("Unknown value kind!"); 681c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 682c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return IndirectCallSites; 683c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 684c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 685c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot std::vector<InstrProfValueSiteRecord> & 686c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot getValueSitesForKind(uint32_t ValueKind) { 687c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return const_cast<std::vector<InstrProfValueSiteRecord> &>( 688c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const_cast<const InstrProfRecord *>(this) 689c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot ->getValueSitesForKind(ValueKind)); 690c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 691c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 692c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // Map indirect call target name hash to name string. 693c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t remapValue(uint64_t Value, uint32_t ValueKind, 694c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot ValueMapType *HashKeys); 695c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 696c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // Merge Value Profile data from Src record to this record for ValueKind. 697c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // Scale merged value counts by \p Weight. 698c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot void mergeValueProfData(uint32_t ValueKind, InstrProfRecord &Src, 699c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t Weight); 700c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 701c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // Scale up value profile data count. 702c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot void scaleValueProfData(uint32_t ValueKind, uint64_t Weight); 703c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}; 704c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 705c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotuint32_t InstrProfRecord::getNumValueKinds() const { 706c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint32_t NumValueKinds = 0; 707c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind) 708c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot NumValueKinds += !(getValueSitesForKind(Kind).empty()); 709c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return NumValueKinds; 710c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 711c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 712c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotuint32_t InstrProfRecord::getNumValueData(uint32_t ValueKind) const { 713c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint32_t N = 0; 714c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const std::vector<InstrProfValueSiteRecord> &SiteRecords = 715c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot getValueSitesForKind(ValueKind); 716c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot for (auto &SR : SiteRecords) { 717c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot N += SR.ValueData.size(); 718c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 719c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return N; 720c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 721c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 722c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotuint32_t InstrProfRecord::getNumValueSites(uint32_t ValueKind) const { 723c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return getValueSitesForKind(ValueKind).size(); 724c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 725c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 726c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotuint32_t InstrProfRecord::getNumValueDataForSite(uint32_t ValueKind, 727c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint32_t Site) const { 728c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return getValueSitesForKind(ValueKind)[Site].ValueData.size(); 729c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 730c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 731c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotstd::unique_ptr<InstrProfValueData[]> 732c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team RobotInstrProfRecord::getValueForSite(uint32_t ValueKind, uint32_t Site, 733c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t *TotalC) const { 734c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t Dummy; 735c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t &TotalCount = (TotalC == nullptr ? Dummy : *TotalC); 736c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint32_t N = getNumValueDataForSite(ValueKind, Site); 737c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot if (N == 0) { 738c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot TotalCount = 0; 739c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return std::unique_ptr<InstrProfValueData[]>(nullptr); 740c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 741c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 742c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot auto VD = llvm::make_unique<InstrProfValueData[]>(N); 743c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot TotalCount = getValueForSite(VD.get(), ValueKind, Site); 744c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 745c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return VD; 746c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 747c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 748c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotuint64_t InstrProfRecord::getValueForSite(InstrProfValueData Dest[], 749c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint32_t ValueKind, 750c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint32_t Site) const { 751c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint32_t I = 0; 752c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t TotalCount = 0; 753c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot for (auto V : getValueSitesForKind(ValueKind)[Site].ValueData) { 754c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Dest[I].Value = V.Value; 755c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Dest[I].Count = V.Count; 756c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot TotalCount = SaturatingAdd(TotalCount, V.Count); 757c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot I++; 758c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 759c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return TotalCount; 760c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 761c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 762c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotvoid InstrProfRecord::reserveSites(uint32_t ValueKind, uint32_t NumValueSites) { 763c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot std::vector<InstrProfValueSiteRecord> &ValueSites = 764c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot getValueSitesForKind(ValueKind); 765c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot ValueSites.reserve(NumValueSites); 766c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 767c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 768c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline support::endianness getHostEndianness() { 769c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return sys::IsLittleEndianHost ? support::little : support::big; 770c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 771c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 772c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// Include definitions for value profile data 773c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#define INSTR_PROF_VALUE_PROF_DATA 774c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ProfileData/InstrProfData.inc" 775c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 776c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotvoid InstrProfValueSiteRecord::sortByCount() { 777c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot ValueData.sort( 778c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot [](const InstrProfValueData &left, const InstrProfValueData &right) { 779c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return left.Count > right.Count; 780c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot }); 781c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // Now truncate 782c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot size_t max_s = INSTR_PROF_MAX_NUM_VAL_PER_SITE; 783c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot if (ValueData.size() > max_s) 784c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot ValueData.resize(max_s); 785c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 786c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 787c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotnamespace IndexedInstrProf { 788c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 789c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotenum class HashT : uint32_t { 790c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot MD5, 791c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Last = MD5 792c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}; 793c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 794c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline uint64_t ComputeHash(HashT Type, StringRef K) { 795c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot switch (Type) { 796c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot case HashT::MD5: 797c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return MD5Hash(K); 798c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 799c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot llvm_unreachable("Unhandled hash type"); 800c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 801c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 802c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotconst uint64_t Magic = 0x8169666f72706cff; // "\xfflprofi\x81" 803c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 804c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotenum ProfVersion { 805c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // Version 1 is the first version. In this version, the value of 806c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // a key/value pair can only include profile data of a single function. 807c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // Due to this restriction, the number of block counters for a given 808c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // function is not recorded but derived from the length of the value. 809c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Version1 = 1, 810c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // The version 2 format supports recording profile data of multiple 811c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // functions which share the same key in one value field. To support this, 812c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // the number block counters is recorded as an uint64_t field right after the 813c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // function structural hash. 814c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Version2 = 2, 815c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // Version 3 supports value profile data. The value profile data is expected 816c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // to follow the block counter profile data. 817c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Version3 = 3, 818c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // In this version, profile summary data \c IndexedInstrProf::Summary is 819c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // stored after the profile header. 820c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Version4 = 4, 821c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // The current version is 4. 822c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot CurrentVersion = INSTR_PROF_INDEX_VERSION 823c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}; 824c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotconst uint64_t Version = ProfVersion::CurrentVersion; 825c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 826c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotconst HashT HashType = HashT::MD5; 827c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 828c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline uint64_t ComputeHash(StringRef K) { return ComputeHash(HashType, K); } 829c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 830c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// This structure defines the file header of the LLVM profile 831c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// data file in indexed-format. 832c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotstruct Header { 833c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t Magic; 834c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t Version; 835c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t Unused; // Becomes unused since version 4 836c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t HashType; 837c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t HashOffset; 838c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}; 839c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 840c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// Profile summary data recorded in the profile data file in indexed 841c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// format. It is introduced in version 4. The summary data follows 842c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// right after the profile file header. 843c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotstruct Summary { 844c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot struct Entry { 845c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t Cutoff; ///< The required percentile of total execution count. 846c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t 847c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot MinBlockCount; ///< The minimum execution count for this percentile. 848c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t NumBlocks; ///< Number of blocks >= the minumum execution count. 849c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot }; 850c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // The field kind enumerator to assigned value mapping should remain 851c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // unchanged when a new kind is added or an old kind gets deleted in 852c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // the future. 853c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot enum SummaryFieldKind { 854c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// The total number of functions instrumented. 855c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot TotalNumFunctions = 0, 856c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Total number of instrumented blocks/edges. 857c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot TotalNumBlocks = 1, 858c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// The maximal execution count among all functions. 859c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// This field does not exist for profile data from IR based 860c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// instrumentation. 861c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot MaxFunctionCount = 2, 862c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Max block count of the program. 863c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot MaxBlockCount = 3, 864c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// Max internal block count of the program (excluding entry blocks). 865c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot MaxInternalBlockCount = 4, 866c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// The sum of all instrumented block counts. 867c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot TotalBlockCount = 5, 868c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot NumKinds = TotalBlockCount + 1 869c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot }; 870c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 871c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // The number of summmary fields following the summary header. 872c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t NumSummaryFields; 873c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot // The number of Cutoff Entries (Summary::Entry) following summary fields. 874c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t NumCutoffEntries; 875c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 876c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot static uint32_t getSize(uint32_t NumSumFields, uint32_t NumCutoffEntries) { 877c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return sizeof(Summary) + NumCutoffEntries * sizeof(Entry) + 878c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot NumSumFields * sizeof(uint64_t); 879c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 880c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 881c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const uint64_t *getSummaryDataBase() const { 882c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return reinterpret_cast<const uint64_t *>(this + 1); 883c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 884c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 885c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t *getSummaryDataBase() { 886c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return reinterpret_cast<uint64_t *>(this + 1); 887c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 888c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 889c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const Entry *getCutoffEntryBase() const { 890c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return reinterpret_cast<const Entry *>( 891c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot &getSummaryDataBase()[NumSummaryFields]); 892c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 893c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 894c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Entry *getCutoffEntryBase() { 895c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return reinterpret_cast<Entry *>(&getSummaryDataBase()[NumSummaryFields]); 896c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 897c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 898c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot uint64_t get(SummaryFieldKind K) const { 899c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return getSummaryDataBase()[K]; 900c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 901c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 902c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot void set(SummaryFieldKind K, uint64_t V) { 903c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot getSummaryDataBase()[K] = V; 904c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 905c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 906c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot const Entry &getEntry(uint32_t I) const { return getCutoffEntryBase()[I]; } 907c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 908c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot void setEntry(uint32_t I, const ProfileSummaryEntry &E) { 909c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Entry &ER = getCutoffEntryBase()[I]; 910c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot ER.Cutoff = E.Cutoff; 911c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot ER.MinBlockCount = E.MinCount; 912c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot ER.NumBlocks = E.NumCounts; 913c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 914c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 915c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Summary(uint32_t Size) { memset(this, 0, Size); } 916c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot void operator delete(void *ptr) { ::operator delete(ptr); } 917c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 918c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Summary() = delete; 919c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}; 920c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 921c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline std::unique_ptr<Summary> allocSummary(uint32_t TotalSize) { 922c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return std::unique_ptr<Summary>(new (::operator new(TotalSize)) 923c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot Summary(TotalSize)); 924c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 925c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 926c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} // end namespace IndexedInstrProf 927c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 928c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotnamespace RawInstrProf { 929c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 930c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// Version 1: First version 931c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// Version 2: Added value profile data section. Per-function control data 932c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// struct has more fields to describe value profile information. 933c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// Version 3: Compressed name section support. Function PGO name reference 934c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// from control data struct is changed from raw pointer to Name's MD5 value. 935c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// Version 4: ValueDataBegin and ValueDataSizes fields are removed from the 936c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// raw header. 937c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotconst uint64_t Version = INSTR_PROF_RAW_VERSION; 938c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 939c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robottemplate <class IntPtrT> inline uint64_t getMagic(); 940c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robottemplate <> inline uint64_t getMagic<uint64_t>() { 941c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return INSTR_PROF_RAW_MAGIC_64; 942c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 943c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 944c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robottemplate <> inline uint64_t getMagic<uint32_t>() { 945c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return INSTR_PROF_RAW_MAGIC_32; 946c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} 947c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 948c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// Per-function profile data header/control structure. 949c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// The definition should match the structure defined in 950c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// compiler-rt/lib/profile/InstrProfiling.h. 951c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// It should also match the synthesized type in 952c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// Transforms/Instrumentation/InstrProfiling.cpp:getOrCreateRegionCounters. 953c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robottemplate <class IntPtrT> struct LLVM_ALIGNAS(8) ProfileData { 954c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot #define INSTR_PROF_DATA(Type, LLVMType, Name, Init) Type Name; 955c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot #include "llvm/ProfileData/InstrProfData.inc" 956c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}; 957c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 958c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// File header structure of the LLVM profile data in raw format. 959c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// The definition should match the header referenced in 960c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// compiler-rt/lib/profile/InstrProfilingFile.c and 961c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// InstrProfilingBuffer.c. 962c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotstruct Header { 963c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#define INSTR_PROF_RAW_HEADER(Type, Name, Init) const Type Name; 964c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ProfileData/InstrProfData.inc" 965c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}; 966c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 967c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} // end namespace RawInstrProf 968c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 969c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// Parse MemOP Size range option. 970c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotvoid getMemOPSizeRangeFromOption(StringRef Str, int64_t &RangeStart, 971c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot int64_t &RangeLast); 972c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 973c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} // end namespace llvm 974c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 975c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#endif // LLVM_PROFILEDATA_INSTRPROF_H 976