|
LLVM 24.0.0git
|
#include "llvm/Analysis/ModuleSummaryAnalysis.h"#include "AnalysisOptions.h"#include "llvm/ADT/ArrayRef.h"#include "llvm/ADT/DenseSet.h"#include "llvm/ADT/MapVector.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/SetVector.h"#include "llvm/ADT/SmallPtrSet.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/StringRef.h"#include "llvm/Analysis/BlockFrequencyInfo.h"#include "llvm/Analysis/BranchProbabilityInfo.h"#include "llvm/Analysis/ConstantFolding.h"#include "llvm/Analysis/IndirectCallPromotionAnalysis.h"#include "llvm/Analysis/LoopInfo.h"#include "llvm/Analysis/MemoryProfileInfo.h"#include "llvm/Analysis/ProfileSummaryInfo.h"#include "llvm/Analysis/StackSafetyAnalysis.h"#include "llvm/Analysis/TypeMetadataUtils.h"#include "llvm/IR/Attributes.h"#include "llvm/IR/BasicBlock.h"#include "llvm/IR/Constant.h"#include "llvm/IR/Constants.h"#include "llvm/IR/CycleInfo.h"#include "llvm/IR/Dominators.h"#include "llvm/IR/Function.h"#include "llvm/IR/GlobalAlias.h"#include "llvm/IR/GlobalValue.h"#include "llvm/IR/GlobalVariable.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/LLVMContext.h"#include "llvm/IR/Metadata.h"#include "llvm/IR/Module.h"#include "llvm/IR/ModuleSummaryIndex.h"#include "llvm/IR/Use.h"#include "llvm/IR/User.h"#include "llvm/InitializePasses.h"#include "llvm/Object/ModuleSymbolTable.h"#include "llvm/Object/SymbolicFile.h"#include "llvm/Pass.h"#include "llvm/Support/Casting.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/Compiler.h"#include "llvm/Support/FileSystem.h"#include <cassert>#include <cstdint>#include <vector>Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "module-summary-analysis" |
Functions | |
| static bool | findRefEdges (ModuleSummaryIndex &Index, const User *CurUser, SetVector< ValueInfo, SmallVector< ValueInfo, 0 > > &RefEdges, SmallPtrSet< const User *, 8 > &Visited, bool &RefLocalLinkageIFunc) |
| static void | findImplicitRefEdges (ModuleSummaryIndex &Index, const Function &F, SetVector< ValueInfo, SmallVector< ValueInfo, 0 > > &RefEdges) |
| Collect globals referenced via !implicit.ref metadata on a function and add them as reference edges in the module summary. | |
| static CalleeInfo::HotnessType | getHotness (uint64_t ProfileCount, ProfileSummaryInfo *PSI) |
| static bool | isNonRenamableLocal (const GlobalValue &GV) |
| static void | addVCallToSet (DevirtCallSite Call, GlobalValue::GUID Guid, SetVector< FunctionSummary::VFuncId, std::vector< FunctionSummary::VFuncId > > &VCalls, SetVector< FunctionSummary::ConstVCall, std::vector< FunctionSummary::ConstVCall > > &ConstVCalls) |
| Determine whether this call has all constant integer arguments (excluding "this") and summarize it to VCalls or ConstVCalls as appropriate. | |
| static void | addIntrinsicToSummary (const CallInst *CI, SetVector< GlobalValue::GUID, std::vector< GlobalValue::GUID > > &TypeTests, SetVector< FunctionSummary::VFuncId, std::vector< FunctionSummary::VFuncId > > &TypeTestAssumeVCalls, SetVector< FunctionSummary::VFuncId, std::vector< FunctionSummary::VFuncId > > &TypeCheckedLoadVCalls, SetVector< FunctionSummary::ConstVCall, std::vector< FunctionSummary::ConstVCall > > &TypeTestAssumeConstVCalls, SetVector< FunctionSummary::ConstVCall, std::vector< FunctionSummary::ConstVCall > > &TypeCheckedLoadConstVCalls, DominatorTree &DT) |
| If this intrinsic call requires that we add information to the function summary, do so via the non-constant reference arguments. | |
| static bool | isNonVolatileLoad (const Instruction *I) |
| static bool | isNonVolatileStore (const Instruction *I) |
| static bool | mustBeUnreachableFunction (const Function &F) |
| static void | computeFunctionSummary (const AnalysisOptions &Opts, ModuleSummaryIndex &Index, const Module &M, const Function &F, BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI, DominatorTree &DT, bool HasLocalsInUsedOrAsm, DenseSet< GlobalValue::GUID > &CantBePromoted, bool IsThinLTO, std::function< const StackSafetyInfo *(const Function &F)> GetSSICallback) |
| static void | findFuncPointers (const Constant *I, uint64_t StartingOffset, const Module &M, ModuleSummaryIndex &Index, VTableFuncList &VTableFuncs, const GlobalVariable &OrigGV) |
Find function pointers referenced within the given vtable initializer (or subset of an initializer) I. | |
| static void | computeVTableFuncs (ModuleSummaryIndex &Index, const GlobalVariable &V, const Module &M, VTableFuncList &VTableFuncs) |
| static void | recordTypeIdCompatibleVtableReferences (ModuleSummaryIndex &Index, const GlobalVariable &V, SmallVectorImpl< MDNode * > &Types) |
Record vtable definition V for each type metadata it references. | |
| static void | computeVariableSummary (ModuleSummaryIndex &Index, const GlobalVariable &V, DenseSet< GlobalValue::GUID > &CantBePromoted, const Module &M, SmallVectorImpl< MDNode * > &Types) |
| static void | computeAliasSummary (ModuleSummaryIndex &Index, const GlobalAlias &A, DenseSet< GlobalValue::GUID > &CantBePromoted) |
| static void | setLiveRoot (ModuleSummaryIndex &Index, StringRef Name) |
| INITIALIZE_PASS_BEGIN (ModuleSummaryIndexWrapperPass, "module-summary-analysis", "Module Summary Analysis", false, true) INITIALIZE_PASS_END(ModuleSummaryIndexWrapperPass | |
| INITIALIZE_PASS (ImmutableModuleSummaryIndexWrapperPass, "module-summary-info", "Module summary info", false, true) bool llvm | |
Variables | |
| module summary | analysis |
| module summary Module Summary | Analysis |
| module summary Module Summary | false |
| #define DEBUG_TYPE "module-summary-analysis" |
Definition at line 66 of file ModuleSummaryAnalysis.cpp.
|
static |
If this intrinsic call requires that we add information to the function summary, do so via the non-constant reference arguments.
Definition at line 204 of file ModuleSummaryAnalysis.cpp.
References addVCallToSet(), llvm::any_of(), Call, llvm::cast(), llvm::dyn_cast(), llvm::findDevirtualizableCallsForTypeCheckedLoad(), llvm::findDevirtualizableCallsForTypeTest(), llvm::CallBase::getArgOperand(), llvm::CallBase::getCalledFunction(), llvm::GlobalValue::getGUIDAssumingExternalLinkage(), llvm::Function::getIntrinsicID(), llvm::Guid, and llvm::Value::uses().
Referenced by computeFunctionSummary().
|
static |
Determine whether this call has all constant integer arguments (excluding "this") and summarize it to VCalls or ConstVCalls as appropriate.
Definition at line 183 of file ModuleSummaryAnalysis.cpp.
References Call, llvm::drop_begin(), llvm::dyn_cast(), and llvm::Guid.
Referenced by addIntrinsicToSummary().
|
static |
Definition at line 910 of file ModuleSummaryAnalysis.cpp.
References A(), assert(), llvm::GlobalValueSummary::Definition, llvm::GlobalValue::getGUID(), llvm::detail::DenseSetImpl< ValueT, MapTy >::insert(), llvm::isa(), and isNonRenamableLocal().
Referenced by llvm::buildModuleSummaryIndex().
|
static |
Definition at line 304 of file ModuleSummaryAnalysis.cpp.
References addIntrinsicToSummary(), llvm::All, assert(), llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::memprof::CallStack< NodeT, IteratorT >::beginAfterSharedPrefix(), llvm::cast(), llvm::CalleeInfo::Cold, llvm::detail::DenseSetImpl< ValueT, MapTy >::count(), llvm::CalleeInfo::Critical, llvm::GlobalValueSummary::Definition, llvm::dyn_cast(), llvm::dyn_cast_if_present(), llvm::mdconst::dyn_extract(), llvm::memprof::CallStack< NodeT, IteratorT >::empty(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::memprof::CallStack< NodeT, IteratorT >::end(), llvm::mdconst::extract_or_null(), F, findImplicitRefEdges(), findRefEdges(), llvm::BlockAddress::get(), getHotness(), llvm::memprof::getMIBAllocType(), llvm::memprof::getMIBStackNode(), llvm::MDNode::getNumOperands(), llvm::MDNode::getOperand(), llvm::ProfileSummaryInfo::getProfileCount(), llvm::ICallPromotionAnalysis::getPromotionCandidatesForInstruction(), llvm::ProfileSummaryInfo::hasPartialSampleProfile(), I, llvm::detail::DenseSetImpl< ValueT, MapTy >::insert(), llvm::SetVector< T, Vector, Set, N >::insert(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::SetVector< T, Vector, Set, N >::insert_range(), llvm::isa(), isNonRenamableLocal(), isNonVolatileLoad(), isNonVolatileStore(), llvm::mayHaveMemprofSummary(), llvm::memprof::metadataIncludesAllContextSizeInfo(), mustBeUnreachableFunction(), llvm::None, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SetVector< T, Vector, Set, N >::remove(), llvm::SetVector< T, Vector, Set, N >::size(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::takeVector(), llvm::SetVector< T, Vector, Set, N >::takeVector(), uint64_t, llvm::CalleeInfo::Unknown, and users.
Referenced by llvm::buildModuleSummaryIndex().
|
static |
Definition at line 859 of file ModuleSummaryAnalysis.cpp.
References computeVTableFuncs(), llvm::GlobalValueSummary::Definition, findRefEdges(), llvm::detail::DenseSetImpl< ValueT, MapTy >::insert(), isNonRenamableLocal(), recordTypeIdCompatibleVtableReferences(), and llvm::SetVector< T, Vector, Set, N >::takeVector().
Referenced by llvm::buildModuleSummaryIndex().
|
static |
Definition at line 818 of file ModuleSummaryAnalysis.cpp.
References assert(), findFuncPointers(), P, and uint64_t.
Referenced by computeVariableSummary().
|
static |
Find function pointers referenced within the given vtable initializer (or subset of an initializer) I.
The starting offset of I within the vtable initializer is StartingOffset. Any discovered function pointers are added to VTableFuncs along with their cumulative offset within the initializer.
Definition at line 746 of file ModuleSummaryAnalysis.cpp.
References A(), assert(), C(), llvm::cast(), DL, llvm::dyn_cast(), llvm::StructType::elements(), llvm::enumerate(), findFuncPointers(), llvm::StructLayout::getElementContainingOffset(), llvm::StructLayout::getElementOffset(), llvm::GlobalVariable::getInitializer(), llvm::Value::getType(), I, llvm::isa(), llvm::IsConstantOffsetFromGlobal(), LHS, llvm::Offset, RHS, and uint64_t.
Referenced by computeVTableFuncs(), and findFuncPointers().
|
static |
Collect globals referenced via !implicit.ref metadata on a function and add them as reference edges in the module summary.
This ensures ThinLTO liveness analysis treats them as live when the function is live, and imports them alongside the function during cross-module importing.
Definition at line 150 of file ModuleSummaryAnalysis.cpp.
References llvm::dyn_cast(), llvm::dyn_cast_or_null(), and F.
Referenced by computeFunctionSummary().
|
static |
Definition at line 85 of file ModuleSummaryAnalysis.cpp.
References llvm::dyn_cast(), llvm::dyn_cast_if_present(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::getMaxNumVTableAnnotations(), llvm::getValueProfDataFromInst(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::isa(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and uint64_t.
Referenced by computeFunctionSummary(), and computeVariableSummary().
|
static |
Definition at line 166 of file ModuleSummaryAnalysis.cpp.
References llvm::CalleeInfo::Cold, llvm::CalleeInfo::Hot, llvm::ProfileSummaryInfo::isColdCount(), llvm::ProfileSummaryInfo::isHotCount(), llvm::CalleeInfo::None, uint64_t, and llvm::CalleeInfo::Unknown.
Referenced by computeFunctionSummary().
| INITIALIZE_PASS | ( | ImmutableModuleSummaryIndexWrapperPass | , |
| "module-summary-info" | , | ||
| "Module summary info" | , | ||
| false | , | ||
| true | ) |
Definition at line 1246 of file ModuleSummaryAnalysis.cpp.
References assert(), const, llvm::dyn_cast(), llvm::getAnalysisOptions(), llvm::isa(), and llvm::mayHaveMemprofSummary().
| INITIALIZE_PASS_BEGIN | ( | ModuleSummaryIndexWrapperPass | , |
| "module-summary-analysis" | , | ||
| "Module Summary Analysis" | , | ||
| false | , | ||
| true | ) |
References INITIALIZE_PASS_DEPENDENCY.
|
static |
Definition at line 177 of file ModuleSummaryAnalysis.cpp.
References llvm::GlobalValue::hasLocalLinkage(), and llvm::GlobalValue::hasSection().
Referenced by computeAliasSummary(), computeFunctionSummary(), and computeVariableSummary().
|
static |
Definition at line 278 of file ModuleSummaryAnalysis.cpp.
References llvm::dyn_cast(), and I.
Referenced by computeFunctionSummary().
|
static |
Definition at line 285 of file ModuleSummaryAnalysis.cpp.
References llvm::dyn_cast(), and I.
Referenced by computeFunctionSummary().
Definition at line 297 of file ModuleSummaryAnalysis.cpp.
References assert(), F, and llvm::isa().
Referenced by computeFunctionSummary().
|
static |
Record vtable definition V for each type metadata it references.
Definition at line 842 of file ModuleSummaryAnalysis.cpp.
References llvm::cast(), llvm::dyn_cast(), llvm::Offset, and uint64_t.
Referenced by computeVariableSummary().
|
static |
Definition at line 934 of file ModuleSummaryAnalysis.cpp.
References llvm::GlobalValue::getGUIDAssumingExternalLinkage().
Referenced by llvm::buildModuleSummaryIndex().
| module summary Module Summary Analysis |
Definition at line 1189 of file ModuleSummaryAnalysis.cpp.
| module summary analysis |
Definition at line 1188 of file ModuleSummaryAnalysis.cpp.
| module summary Module Summary false |
Definition at line 1189 of file ModuleSummaryAnalysis.cpp.