LLVM 20.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/CallGraphSCCPass.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 66 of file Attributor.cpp.
#define VERBOSE_DEBUG_TYPE DEBUG_TYPE "-verbose" |
Definition at line 67 of file Attributor.cpp.
|
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 956 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::isEnumAttribute(), isEqualOrWorse(), llvm::Attribute::isIntAttribute(), llvm::Attribute::isStringAttribute(), and llvm_unreachable.
Referenced by llvm::Attributor::manifestAttrs().
Definition at line 1752 of file Attributor.cpp.
Referenced by llvm::Attributor::checkForAllUses().
|
static |
Definition at line 2026 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 365 of file Attributor.cpp.
References A, assert(), llvm::SetVector< T, Vector, Set, N >::begin(), llvm::SetVector< T, Vector, Set, N >::count(), llvm::dbgs(), DL, llvm::SetVector< T, Vector, Set, N >::end(), 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::AA::Interprocedural, llvm::isAllocationFn(), llvm::isNoAliasCall(), llvm::AAPointerInfo::Access::isRead(), llvm::AAPointerInfo::Access::isWriteOrAssumption(), llvm::AAPointerInfo::Access::isWrittenValueUnknown(), llvm::AAPointerInfo::Access::isWrittenValueYetUndetermined(), LLVM_DEBUG, llvm::NullPointerIsDefined(), 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 609 of file Attributor.cpp.
References A, llvm::IRPosition::getPositionKind(), llvm::IRPosition::IRP_CALL_SITE, and llvm::IRPosition::IRP_FUNCTION.
Referenced by llvm::AA::isAssumedReadNone(), and llvm::AA::isAssumedReadOnly().
Return true if New
is equal or worse than Old
.
Definition at line 946 of file Attributor.cpp.
References llvm::Attribute::getValueAsInt(), and llvm::Attribute::isIntAttribute().
Referenced by addIfNotExistent().
|
static |
Definition at line 661 of file Attributor.cpp.
References A, llvm::dbgs(), DEBUG_WITH_TYPE, llvm::SmallVectorBase< Size_T >::empty(), llvm::BasicBlock::front(), llvm::IRPosition::function(), llvm::Function::getEntryBlock(), llvm::Instruction::getFunction(), llvm::Value::getName(), llvm::Instruction::getNextNonDebugInstruction(), llvm::Function::hasFnAttribute(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::GlobalValue::isDeclaration(), LLVM_DEBUG, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallPtrSetImplBase::size(), llvm::SmallVectorBase< Size_T >::size(), and VERBOSE_DEBUG_TYPE.
|
static |
Definition at line 3915 of file Attributor.cpp.
References A, llvm::all_of(), llvm::CHANGED, llvm::dbgs(), llvm::SetVector< T, Vector, Set, N >::empty(), F, FAM, llvm::Value::getName(), llvm::AANoUnwind::ID, llvm::AANoSync::ID, llvm::AAMustProgress::ID, llvm::AANonNull::ID, llvm::AANoRecurse::ID, llvm::AAWillReturn::ID, llvm::AAIntraFnReachability::ID, llvm::AANoFree::ID, llvm::AANoReturn::ID, llvm::AANoCapture::ID, llvm::AAMemoryBehavior::ID, llvm::AAMemoryLocation::ID, llvm::AANoFPClass::ID, llvm::AACallEdges::ID, llvm::AAInterFnReachability::ID, llvm::AAUnderlyingObjects::ID, llvm::AnalysisManager< IRUnitT, ExtraArgTs >::invalidate(), LLVM_DEBUG, llvm::PreservedAnalyses::preserveSet(), and llvm::SetVector< T, Vector, Set, N >::size().
Referenced by llvm::AttributorLightCGSCCPass::run(), and llvm::AttributorLightPass::run().
|
static |
}
Tracking callback for specialization of indirect calls.
Definition at line 3812 of file Attributor.cpp.
References A, llvm::all_of(), AllowDeepWrapper, AllowShallowWrappers, assert(), llvm::CHANGED, llvm::Attributor::createShallowWrapper(), llvm::dbgs(), llvm::SetVector< T, Vector, Set, N >::empty(), F, llvm::Value::getName(), llvm::SetVector< T, Vector, Set, N >::insert(), llvm::Attributor::internalizeFunction(), llvm::GlobalValue::isInterposableLinkage(), LLVM_DEBUG, MaxSpecializationPerCB, llvm::CallGraphUpdater::reanalyzeFunction(), llvm::CallGraphUpdater::replaceFunctionWith(), llvm::SetVector< T, Vector, Set, N >::size(), 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().