LLVM  14.0.0git
Classes | Namespaces | Macros | Functions | Variables
Attributor.cpp File Reference
#include "llvm/Transforms/IPO/Attributor.h"
#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/TinyPtrVector.h"
#include "llvm/Analysis/InlineCost.h"
#include "llvm/Analysis/LazyValueInfo.h"
#include "llvm/Analysis/MemorySSAUpdater.h"
#include "llvm/Analysis/MustExecute.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/NoFolder.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/IR/Verifier.h"
#include "llvm/InitializePasses.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/raw_ostream.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/Local.h"
#include <cassert>
#include <string>
Include dependency graph for Attributor.cpp:

Go to the source code of this file.

Classes

struct  llvm::GraphTraits< AADepGraphNode * >
 
struct  llvm::GraphTraits< AADepGraph * >
 
struct  llvm::DOTGraphTraits< AADepGraph * >
 

Namespaces

 llvm
 This file implements support for optimizing divisions by a constant.
 

Macros

#define DEBUG_TYPE   "attributor"
 

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")
 
static bool isEqualOrWorse (const Attribute &New, const Attribute &Old)
 Return true if New is equal or worse than Old. More...
 
static bool addIfNotExistent (LLVMContext &Ctx, const Attribute &Attr, AttributeList &Attrs, int AttrIdx, bool ForceReplace=false)
 Return true if the information provided by Attr was added to the attribute list Attrs. More...
 
static bool checkForAllInstructionsImpl (Attributor *A, InformationCache::OpcodeInstMapTy &OpcodeInstMap, function_ref< bool(Instruction &)> Pred, const AbstractAttribute *QueryingAA, const AAIsDead *LivenessAA, const 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)
 } More...
 
 INITIALIZE_PASS_BEGIN (AttributorLegacyPass, "attributor", "Deduce and propagate attributes", false, false) INITIALIZE_PASS_END(AttributorLegacyPass
 
Deduce and propagate false INITIALIZE_PASS_BEGIN (AttributorCGSCCLegacyPass, "attributor-cgscc", "Deduce and propagate attributes (CGSCC pass)", false, false) INITIALIZE_PASS_END(AttributorCGSCCLegacyPass
 
Deduce and propagate false attributor Deduce and propagate attributes (CGSCC pass)"
 

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, trueMaxInitializationChainLengthX ("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 > VerifyMaxFixpointIterations ("attributor-max-iterations-verify", cl::Hidden, cl::desc("Verify that max-iterations is a tight bound for a fixpoint"), cl::init(false))
 
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 seperated list of attribute names that are " "allowed to be seeded."), cl::ZeroOrMore, cl::CommaSeparated)
 
static cl::list< std::string > FunctionSeedAllowList ("attributor-function-seed-allow-list", cl::Hidden, cl::desc("Comma seperated list of function names that are " "allowed to be seeded."), cl::ZeroOrMore, 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))
 
 attributor
 
Deduce and propagate attributes
 
Deduce and propagate false
 
Deduce and propagate false attributor cgscc
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "attributor"

Definition at line 57 of file Attributor.cpp.

Function Documentation

◆ addIfNotExistent()

static bool addIfNotExistent ( LLVMContext Ctx,
const Attribute Attr,
AttributeList Attrs,
int  AttrIdx,
bool  ForceReplace = false 
)
static

Return true if the information provided by Attr was added to the attribute list Attrs.

This is only the case if it was not already present in Attrs at the position describe by PK and AttrIdx.

Definition at line 379 of file Attributor.cpp.

References llvm::Function::addAttributeAtIndex(), Attrs, llvm::Function::getAttributeAtIndex(), llvm::Attribute::getKindAsEnum(), llvm::Attribute::getKindAsString(), llvm::Attribute::isEnumAttribute(), isEqualOrWorse(), llvm::Attribute::isIntAttribute(), llvm::Attribute::isStringAttribute(), llvm_unreachable, and llvm::Function::removeAttributeAtIndex().

Referenced by llvm::IRAttributeManifest::manifestAttrs().

◆ attributes()

Deduce and propagate false attributor Deduce and propagate attributes ( CGSCC  pass)

◆ checkForAllInstructionsImpl()

static bool checkForAllInstructionsImpl ( Attributor A,
InformationCache::OpcodeInstMapTy OpcodeInstMap,
function_ref< bool(Instruction &)>  Pred,
const AbstractAttribute QueryingAA,
const AAIsDead LivenessAA,
const ArrayRef< unsigned > &  Opcodes,
bool &  UsedAssumedInformation,
bool  CheckBBLivenessOnly = false,
bool  CheckPotentiallyDead = false 
)
static

◆ DEBUG_COUNTER()

DEBUG_COUNTER ( ManifestDBGCounter  ,
"attributor-manifest"  ,
"Determine what attributes are manifested in the IR  
)

◆ INITIALIZE_PASS_BEGIN() [1/2]

Deduce and propagate false INITIALIZE_PASS_BEGIN ( AttributorCGSCCLegacyPass  ,
"attributor-cgscc ,
"Deduce and propagate attributes (CGSCC pass)"  ,
false  ,
false   
)

◆ INITIALIZE_PASS_BEGIN() [2/2]

INITIALIZE_PASS_BEGIN ( AttributorLegacyPass  ,
"attributor"  ,
"Deduce and propagate attributes ,
false  ,
false   
)

◆ isEqualOrWorse()

static bool isEqualOrWorse ( const Attribute New,
const Attribute Old 
)
static

Return true if New is equal or worse than Old.

Definition at line 369 of file Attributor.cpp.

References llvm::Attribute::getValueAsInt(), and llvm::Attribute::isIntAttribute().

Referenced by addIfNotExistent().

◆ runAttributorOnFunctions()

static bool runAttributorOnFunctions ( InformationCache InfoCache,
SetVector< Function * > &  Functions,
AnalysisGetter AG,
CallGraphUpdater CGUpdater,
bool  DeleteFns 
)
static

◆ STATISTIC() [1/7]

STATISTIC ( NumAttributesManifested  ,
"Number of abstract attributes manifested in IR  
)

◆ STATISTIC() [2/7]

STATISTIC ( NumAttributesTimedOut  ,
"Number of abstract attributes timed out before fixpoint"   
)

◆ STATISTIC() [3/7]

STATISTIC ( NumAttributesValidFixpoint  ,
"Number of abstract attributes in a valid fixpoint state"   
)

◆ STATISTIC() [4/7]

STATISTIC ( NumFnDeleted  ,
"Number of function deleted"   
)

◆ STATISTIC() [5/7]

STATISTIC ( NumFnShallowWrappersCreated  ,
"Number of shallow wrappers created"   
)

◆ STATISTIC() [6/7]

STATISTIC ( NumFnWithExactDefinition  ,
"Number of functions with exact definitions"   
)

◆ STATISTIC() [7/7]

STATISTIC ( NumFnWithoutExactDefinition  ,
"Number of functions without exact definitions"   
)

Variable Documentation

◆ AllowDeepWrapper

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

◆ AllowShallowWrappers

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

◆ AnnotateDeclarationCallSites

cl::opt<bool> AnnotateDeclarationCallSites("attributor-annotate-decl-cs", cl::Hidden, cl::desc("Annotate call sites of function declarations."), cl::init(false))
static

◆ attributes

Deduce and propagate attributes

◆ attributor

attributor

Definition at line 3083 of file Attributor.cpp.

◆ cgscc

Deduce and propagate false attributor cgscc

Definition at line 3090 of file Attributor.cpp.

◆ DepGraphDotFileNamePrefix

cl::opt<std::string> DepGraphDotFileNamePrefix("attributor-depgraph-dot-filename-prefix", cl::Hidden, cl::desc("The prefix used for the CallGraph dot file names."))
static

◆ DumpDepGraph

cl::opt<bool> DumpDepGraph("attributor-dump-dep-graph", cl::Hidden, cl::desc("Dump the dependency graph to dot files."), cl::init(false))
static

Referenced by llvm::Attributor::run().

◆ EnableCallSiteSpecific

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

◆ EnableHeapToStack

cl::opt<bool> EnableHeapToStack("enable-heap-to-stack-conversion", cl::init(true), cl::Hidden)
static

◆ false

Deduce and propagate false attributor Deduce and propagate false

Definition at line 3084 of file Attributor.cpp.

◆ FunctionSeedAllowList

cl::list<std::string> FunctionSeedAllowList("attributor-function-seed-allow-list", cl::Hidden, cl::desc("Comma seperated list of function names that are " "allowed to be seeded."), cl::ZeroOrMore, cl::CommaSeparated)
static

◆ MaxInitializationChainLengthX

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

◆ PrintCallGraph

cl::opt<bool> PrintCallGraph("attributor-print-call-graph", cl::Hidden, cl::desc("Print Attributor's internal call graph"), cl::init(false))
static

Referenced by llvm::Attributor::run().

◆ PrintDependencies

cl::opt<bool> PrintDependencies("attributor-print-dep", cl::Hidden, cl::desc("Print attribute dependencies"), cl::init(false))
static

Referenced by llvm::Attributor::run().

◆ SeedAllowList

cl::list<std::string> SeedAllowList("attributor-seed-allow-list", cl::Hidden, cl::desc("Comma seperated list of attribute names that are " "allowed to be seeded."), cl::ZeroOrMore, cl::CommaSeparated)
static

◆ SetFixpointIterations

cl::opt<unsigned> SetFixpointIterations("attributor-max-iterations", cl::Hidden, cl::desc("Maximal number of fixpoint iterations."), cl::init(32))
static

◆ SimplifyAllLoads

cl::opt<bool> SimplifyAllLoads("attributor-simplify-all-loads", cl::Hidden, cl::desc("Try to simplify all loads."), cl::init(true))
static

◆ VerifyMaxFixpointIterations

cl::opt<bool> VerifyMaxFixpointIterations("attributor-max-iterations-verify", cl::Hidden, cl::desc("Verify that max-iterations is a tight bound for a fixpoint"), cl::init(false))
static

◆ ViewDepGraph

cl::opt<bool> ViewDepGraph("attributor-view-dep-graph", cl::Hidden, cl::desc("View the dependency graph."), cl::init(false))
static

Referenced by llvm::Attributor::run().