|
LLVM 22.0.0git
|
#include "llvm/Transforms/IPO/Attributor.h"#include "llvm/ADT/ArrayRef.h"#include "llvm/ADT/PointerIntPair.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/SmallPtrSet.h"#include "llvm/ADT/Statistic.h"#include "llvm/Analysis/AliasAnalysis.h"#include "llvm/Analysis/CallGraph.h"#include "llvm/Analysis/InlineCost.h"#include "llvm/Analysis/MemoryBuiltins.h"#include "llvm/Analysis/MustExecute.h"#include "llvm/IR/AttributeMask.h"#include "llvm/IR/Attributes.h"#include "llvm/IR/Constant.h"#include "llvm/IR/ConstantFold.h"#include "llvm/IR/Constants.h"#include "llvm/IR/DataLayout.h"#include "llvm/IR/GlobalValue.h"#include "llvm/IR/GlobalVariable.h"#include "llvm/IR/Instruction.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/LLVMContext.h"#include "llvm/IR/ValueHandle.h"#include "llvm/Support/Casting.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/Debug.h"#include "llvm/Support/DebugCounter.h"#include "llvm/Support/FileSystem.h"#include "llvm/Support/GraphWriter.h"#include "llvm/Support/ModRef.h"#include "llvm/Support/raw_ostream.h"#include "llvm/Transforms/Utils/BasicBlockUtils.h"#include "llvm/Transforms/Utils/Cloning.h"#include "llvm/Transforms/Utils/Local.h"#include <cstdint>#include <memory>#include <cassert>#include <optional>#include <string>Go to the source code of this file.
Classes | |
| struct | llvm::GraphTraits< AADepGraphNode * > |
| struct | llvm::GraphTraits< AADepGraph * > |
| struct | llvm::DOTGraphTraits< AADepGraph * > |
Namespaces | |
| namespace | llvm |
| This is an optimization pass for GlobalISel generic memory operations. | |
Macros | |
| #define | DEBUG_TYPE "attributor" |
| #define | VERBOSE_DEBUG_TYPE DEBUG_TYPE "-verbose" |
Functions | |
| DEBUG_COUNTER (ManifestDBGCounter, "attributor-manifest", "Determine what attributes are manifested in the IR") | |
| STATISTIC (NumFnDeleted, "Number of function deleted") | |
| STATISTIC (NumFnWithExactDefinition, "Number of functions with exact definitions") | |
| STATISTIC (NumFnWithoutExactDefinition, "Number of functions without exact definitions") | |
| STATISTIC (NumFnShallowWrappersCreated, "Number of shallow wrappers created") | |
| STATISTIC (NumAttributesTimedOut, "Number of abstract attributes timed out before fixpoint") | |
| STATISTIC (NumAttributesValidFixpoint, "Number of abstract attributes in a valid fixpoint state") | |
| STATISTIC (NumAttributesManifested, "Number of abstract attributes manifested in IR") | |
| template<bool IsLoad, typename Ty> | |
| static bool | getPotentialCopiesOfMemoryValue (Attributor &A, Ty &I, SmallSetVector< Value *, 4 > &PotentialCopies, SmallSetVector< Instruction *, 4 > *PotentialValueOrigins, const AbstractAttribute &QueryingAA, bool &UsedAssumedInformation, bool OnlyExact) |
| static bool | isAssumedReadOnlyOrReadNone (Attributor &A, const IRPosition &IRP, const AbstractAttribute &QueryingAA, bool RequireReadNone, bool &IsKnown) |
| static bool | isPotentiallyReachable (Attributor &A, const Instruction &FromI, const Instruction *ToI, const Function &ToFn, const AbstractAttribute &QueryingAA, const AA::InstExclusionSetTy *ExclusionSet, std::function< bool(const Function &F)> GoBackwardsCB) |
| static bool | isEqualOrWorse (const Attribute &New, const Attribute &Old) |
Return true if New is equal or worse than Old. | |
| static bool | addIfNotExistent (LLVMContext &Ctx, const Attribute &Attr, AttributeSet AttrSet, bool ForceReplace, AttrBuilder &AB) |
Return true if the information provided by Attr was added to the attribute set AttrSet. | |
| bool | canMarkAsVisited (const User *Usr) |
| static bool | checkForAllInstructionsImpl (Attributor *A, InformationCache::OpcodeInstMapTy &OpcodeInstMap, function_ref< bool(Instruction &)> Pred, const AbstractAttribute *QueryingAA, const AAIsDead *LivenessAA, ArrayRef< unsigned > Opcodes, bool &UsedAssumedInformation, bool CheckBBLivenessOnly=false, bool CheckPotentiallyDead=false) |
| static bool | runAttributorOnFunctions (InformationCache &InfoCache, SetVector< Function * > &Functions, AnalysisGetter &AG, CallGraphUpdater &CGUpdater, bool DeleteFns, bool IsModulePass) |
| } | |
| static bool | runAttributorLightOnFunctions (InformationCache &InfoCache, SetVector< Function * > &Functions, AnalysisGetter &AG, CallGraphUpdater &CGUpdater, FunctionAnalysisManager &FAM, bool IsModulePass) |
Variables | |
| static cl::opt< unsigned > | SetFixpointIterations ("attributor-max-iterations", cl::Hidden, cl::desc("Maximal number of fixpoint iterations."), cl::init(32)) |
| static cl::opt< unsigned > | MaxSpecializationPerCB ("attributor-max-specializations-per-call-base", cl::Hidden, cl::desc("Maximal number of callees specialized for " "a call base"), cl::init(UINT32_MAX)) |
| static cl::opt< unsigned, true > | MaxInitializationChainLengthX ("attributor-max-initialization-chain-length", cl::Hidden, cl::desc("Maximal number of chained initializations (to avoid stack overflows)"), cl::location(MaxInitializationChainLength), cl::init(1024)) |
| static cl::opt< bool > | AnnotateDeclarationCallSites ("attributor-annotate-decl-cs", cl::Hidden, cl::desc("Annotate call sites of function declarations."), cl::init(false)) |
| static cl::opt< bool > | EnableHeapToStack ("enable-heap-to-stack-conversion", cl::init(true), cl::Hidden) |
| static cl::opt< bool > | AllowShallowWrappers ("attributor-allow-shallow-wrappers", cl::Hidden, cl::desc("Allow the Attributor to create shallow " "wrappers for non-exact definitions."), cl::init(false)) |
| static cl::opt< bool > | AllowDeepWrapper ("attributor-allow-deep-wrappers", cl::Hidden, cl::desc("Allow the Attributor to use IP information " "derived from non-exact functions via cloning"), cl::init(false)) |
| static cl::list< std::string > | SeedAllowList ("attributor-seed-allow-list", cl::Hidden, cl::desc("Comma separated list of attribute names that are " "allowed to be seeded."), cl::CommaSeparated) |
| static cl::list< std::string > | FunctionSeedAllowList ("attributor-function-seed-allow-list", cl::Hidden, cl::desc("Comma separated list of function names that are " "allowed to be seeded."), cl::CommaSeparated) |
| static cl::opt< bool > | DumpDepGraph ("attributor-dump-dep-graph", cl::Hidden, cl::desc("Dump the dependency graph to dot files."), cl::init(false)) |
| static cl::opt< std::string > | DepGraphDotFileNamePrefix ("attributor-depgraph-dot-filename-prefix", cl::Hidden, cl::desc("The prefix used for the CallGraph dot file names.")) |
| static cl::opt< bool > | ViewDepGraph ("attributor-view-dep-graph", cl::Hidden, cl::desc("View the dependency graph."), cl::init(false)) |
| static cl::opt< bool > | PrintDependencies ("attributor-print-dep", cl::Hidden, cl::desc("Print attribute dependencies"), cl::init(false)) |
| static cl::opt< bool > | EnableCallSiteSpecific ("attributor-enable-call-site-specific-deduction", cl::Hidden, cl::desc("Allow the Attributor to do call site specific analysis"), cl::init(false)) |
| static cl::opt< bool > | PrintCallGraph ("attributor-print-call-graph", cl::Hidden, cl::desc("Print Attributor's internal call graph"), cl::init(false)) |
| static cl::opt< bool > | SimplifyAllLoads ("attributor-simplify-all-loads", cl::Hidden, cl::desc("Try to simplify all loads."), cl::init(true)) |
| static cl::opt< bool > | CloseWorldAssumption ("attributor-assume-closed-world", cl::Hidden, cl::desc("Should a closed world be assumed, or not. Default if not set.")) |
| #define DEBUG_TYPE "attributor" |
Definition at line 65 of file Attributor.cpp.
| #define VERBOSE_DEBUG_TYPE DEBUG_TYPE "-verbose" |
Definition at line 66 of file Attributor.cpp.
Referenced by llvm::Attributor::checkForAllCallSites(), checkForAllInstructionsImpl(), llvm::Attributor::checkForAllUses(), and isPotentiallyReachable().
|
static |
Return true if the information provided by Attr was added to the attribute set AttrSet.
This is only the case if it was not already present in AttrSet.
Definition at line 957 of file Attributor.cpp.
References llvm::AttributeSet::getAttribute(), llvm::Attribute::getKindAsEnum(), llvm::Attribute::getKindAsString(), llvm::Attribute::getMemoryEffects(), llvm::AttributeSet::getMemoryEffects(), llvm::Attribute::getValueAsString(), llvm::AttributeSet::hasAttribute(), llvm::Attribute::isConstantRangeAttribute(), llvm::Attribute::isEnumAttribute(), isEqualOrWorse(), llvm::Attribute::isIntAttribute(), llvm::Attribute::isStringAttribute(), and llvm_unreachable.
Referenced by llvm::Attributor::manifestAttrs().
Definition at line 1761 of file Attributor.cpp.
References llvm::isa().
Referenced by llvm::Attributor::checkForAllUses().
|
static |
Definition at line 2019 of file Attributor.cpp.
References A(), llvm::dbgs(), DEBUG_WITH_TYPE, I, llvm::IRPosition::inst(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::lookup(), and VERBOSE_DEBUG_TYPE.
Referenced by llvm::Attributor::checkForAllInstructions(), llvm::Attributor::identifyDefaultAbstractAttributes(), and llvm::Attributor::isValidFunctionSignatureRewrite().
| DEBUG_COUNTER | ( | ManifestDBGCounter | , |
| "attributor-manifest" | , | ||
| "Determine what attributes are manifested in the IR" | ) |
|
static |
Definition at line 366 of file Attributor.cpp.
References A(), assert(), llvm::cast(), llvm::SetVector< T, Vector, Set, N >::count(), llvm::dbgs(), DL, llvm::dyn_cast(), llvm::AAPointerInfo::Access::getContent(), llvm::AA::getInitialValueForObj(), llvm::AAPointerInfo::Access::getRemoteInst(), llvm::AA::getWithType(), llvm::AAPointerInfo::Access::getWrittenValue(), I, llvm::SetVector< T, Vector, Set, N >::insert(), llvm::SetVector< T, Vector, Set, N >::insert_range(), llvm::AA::Interprocedural, llvm::isa(), llvm::isa_and_nonnull(), llvm::isAllocationFn(), llvm::isNoAliasCall(), llvm::AAPointerInfo::Access::isRead(), llvm::AAPointerInfo::Access::isWriteOrAssumption(), llvm::AAPointerInfo::Access::isWrittenValueUnknown(), llvm::AAPointerInfo::Access::isWrittenValueYetUndetermined(), LLVM_DEBUG, llvm::NONE, llvm::NullPointerIsDefined(), llvm::OPTIONAL, Ptr, llvm::SmallVectorTemplateBase< T, bool >::push_back(), Range, and llvm::IRPosition::value().
Referenced by llvm::AA::getPotentialCopiesOfStoredValue(), and llvm::AA::getPotentiallyLoadedValues().
|
static |
Definition at line 610 of file Attributor.cpp.
References A(), llvm::IRPosition::getPositionKind(), llvm::AA::hasAssumedIRAttr(), llvm::IRPosition::IRP_CALL_SITE, llvm::IRPosition::IRP_FUNCTION, llvm::NONE, and llvm::OPTIONAL.
Referenced by llvm::AA::isAssumedReadNone(), and llvm::AA::isAssumedReadOnly().
Return true if New is equal or worse than Old.
Definition at line 947 of file Attributor.cpp.
References llvm::Attribute::getValueAsInt(), and llvm::Attribute::isIntAttribute().
Referenced by addIfNotExistent().
|
static |
Definition at line 662 of file Attributor.cpp.
References A(), llvm::dbgs(), DEBUG_WITH_TYPE, llvm::SmallVectorTemplateCommon< T, typename >::empty(), F, llvm::BasicBlock::front(), llvm::IRPosition::function(), llvm::Function::getEntryBlock(), llvm::Instruction::getFunction(), llvm::Value::getName(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getNextNode(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::isa(), llvm::GlobalValue::isDeclaration(), LLVM_DEBUG, llvm::OPTIONAL, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallPtrSetImplBase::size(), llvm::SmallVectorTemplateCommon< T, typename >::size(), and VERBOSE_DEBUG_TYPE.
|
static |
Definition at line 3905 of file Attributor.cpp.
References A(), llvm::all_of(), Call, llvm::CHANGED, Changed, llvm::dbgs(), llvm::dyn_cast(), F, FAM, llvm::Value::getName(), llvm::AACallEdges::ID, llvm::AAInterFnReachability::ID, llvm::AAIntraFnReachability::ID, llvm::AAMemoryBehavior::ID, llvm::AAMemoryLocation::ID, llvm::AAMustProgress::ID, llvm::AANoCapture::ID, llvm::AANoFPClass::ID, llvm::AANoFree::ID, llvm::AANonNull::ID, llvm::AANoRecurse::ID, llvm::AANoReturn::ID, llvm::AANoSync::ID, llvm::AANoUnwind::ID, llvm::AAUnderlyingObjects::ID, llvm::AAWillReturn::ID, LLVM_DEBUG, and llvm::PreservedAnalyses::preserveSet().
Referenced by llvm::AttributorLightCGSCCPass::run(), and llvm::AttributorLightPass::run().
|
static |
}
Tracking callback for specialization of indirect calls.
Definition at line 3802 of file Attributor.cpp.
References A(), llvm::all_of(), AllowDeepWrapper, AllowShallowWrappers, assert(), llvm::CHANGED, Changed, llvm::Attributor::createShallowWrapper(), llvm::dbgs(), llvm::dyn_cast(), F, llvm::Value::getName(), llvm::Attributor::internalizeFunction(), llvm::GlobalValue::isInterposableLinkage(), LLVM_DEBUG, MaxSpecializationPerCB, llvm::CallGraphUpdater::reanalyzeFunction(), llvm::CallGraphUpdater::replaceFunctionWith(), and llvm::Value::uses().
Referenced by llvm::AttributorCGSCCPass::run(), and llvm::AttributorPass::run().
| STATISTIC | ( | NumAttributesManifested | , |
| "Number of abstract attributes manifested in IR" | ) |
| STATISTIC | ( | NumAttributesTimedOut | , |
| "Number of abstract attributes timed out before fixpoint" | ) |
| STATISTIC | ( | NumAttributesValidFixpoint | , |
| "Number of abstract attributes in a valid fixpoint state" | ) |
| STATISTIC | ( | NumFnDeleted | , |
| "Number of function deleted" | ) |
| STATISTIC | ( | NumFnShallowWrappersCreated | , |
| "Number of shallow wrappers created" | ) |
| STATISTIC | ( | NumFnWithExactDefinition | , |
| "Number of functions with exact definitions" | ) |
| STATISTIC | ( | NumFnWithoutExactDefinition | , |
| "Number of functions without exact definitions" | ) |
|
static |
Referenced by llvm::Attributor::internalizeFunction(), and runAttributorOnFunctions().
|
static |
Referenced by runAttributorOnFunctions().
|
static |
Referenced by llvm::Attributor::identifyDefaultAbstractAttributes().
|
static |
Referenced by llvm::Attributor::isClosedWorldModule().
|
static |
Referenced by llvm::AADepGraph::dumpGraph().
|
static |
Referenced by llvm::Attributor::run().
|
static |
|
static |
Referenced by llvm::Attributor::identifyDefaultAbstractAttributes().
|
static |
|
static |
|
static |
Referenced by runAttributorOnFunctions().
|
static |
Referenced by llvm::Attributor::run().
|
static |
Referenced by llvm::Attributor::run().
|
static |
|
static |
Referenced by llvm::OpenMPOptCGSCCPass::run(), and llvm::OpenMPOptPass::run().
|
static |
Referenced by llvm::Attributor::identifyDefaultAbstractAttributes().
|
static |
Referenced by llvm::Attributor::run().