|
LLVM
10.0.0
|
#include "llvm/Transforms/IPO/Attributor.h"#include "llvm/ADT/DepthFirstIterator.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/SmallPtrSet.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/Statistic.h"#include "llvm/Analysis/CaptureTracking.h"#include "llvm/Analysis/EHPersonalities.h"#include "llvm/Analysis/GlobalsModRef.h"#include "llvm/Analysis/LazyValueInfo.h"#include "llvm/Analysis/Loads.h"#include "llvm/Analysis/MemoryBuiltins.h"#include "llvm/Analysis/ScalarEvolution.h"#include "llvm/Analysis/ValueTracking.h"#include "llvm/IR/Argument.h"#include "llvm/IR/Attributes.h"#include "llvm/IR/CFG.h"#include "llvm/IR/InstIterator.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/Verifier.h"#include "llvm/InitializePasses.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/Debug.h"#include "llvm/Support/raw_ostream.h"#include "llvm/Transforms/Utils/BasicBlockUtils.h"#include "llvm/Transforms/Utils/Local.h"#include <cassert>Go to the source code of this file.
Classes | |
| struct | AAValueConstantRangeImpl |
| ---------------— Value Constant Range Attribute ----------------------— More... | |
| struct | AAValueConstantRangeArgument |
| struct | AAValueConstantRangeReturned |
| struct | AAValueConstantRangeFloating |
| struct | AAValueConstantRangeFunction |
| struct | AAValueConstantRangeCallSite |
| struct | AAValueConstantRangeCallSiteReturned |
| struct | AAValueConstantRangeCallSiteArgument |
Namespaces | |
| llvm | |
| This class represents lattice values for constants. | |
Functions | |
| STATISTIC (NumFnWithExactDefinition, "Number of function with exact definitions") | |
| STATISTIC (NumFnWithoutExactDefinition, "Number of function without exact definitions") | |
| 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") | |
| STATISTIC (NumAttributesFixedDueToRequiredDependences, "Number of abstract attributes fixed due to required dependences") | |
| static void | replaceAllInstructionUsesWith (Value &Old, Value &New) |
| For calls (and invokes) we will only replace instruction uses to not disturb the old style call graph. More... | |
| template<typename AAType , typename StateTy > | |
| static bool | genericValueTraversal (Attributor &A, IRPosition IRP, const AAType &QueryingAA, StateTy &State, const function_ref< bool(Value &, StateTy &, bool)> &VisitValueCB, int MaxValues=8) |
Recursively visit all values that might become IRP at some point. More... | |
| 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) |
Return true if the information provided by Attr was added to the attribute list Attrs. More... | |
| static const Value * | getBasePointerOfAccessPointerOperand (const Instruction *I, int64_t &BytesOffset, const DataLayout &DL, bool AllowNonInbounds=false) |
| static bool | checkForAllInstructionsImpl (InformationCache::OpcodeInstMapTy &OpcodeInstMap, const function_ref< bool(Instruction &)> &Pred, const AAIsDead *LivenessAA, bool &AnyDead, const ArrayRef< unsigned > &Opcodes) |
| static bool | runAttributorOnModule (Module &M, AnalysisGetter &AG) |
| } More... | |
| INITIALIZE_PASS_BEGIN (AttributorLegacyPass, "attributor", "Deduce and propagate attributes", false, false) INITIALIZE_PASS_END(AttributorLegacyPass | |
Variables | |
| static cl::opt< unsigned > | MaxFixpointIterations ("attributor-max-iterations", cl::Hidden, cl::desc("Maximal number of fixpoint iterations."), cl::init(32)) |
| 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 > | DisableAttributor ("attributor-disable", cl::Hidden, cl::desc("Disable the attributor inter-procedural deduction pass."), cl::init(true)) |
| 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 > | ManifestInternal ("attributor-manifest-internal", cl::Hidden, cl::desc("Manifest Attributor internal string attributes."), cl::init(false)) |
| static cl::opt< unsigned > | DepRecInterval ("attributor-dependence-recompute-interval", cl::Hidden, cl::desc("Number of iterations until dependences are recomputed."), cl::init(4)) |
| static cl::opt< bool > | EnableHeapToStack ("enable-heap-to-stack-conversion", cl::init(true), cl::Hidden) |
| static cl::opt< int > | MaxHeapToStackSize ("max-heap-to-stack-size", cl::init(128), cl::Hidden) |
| attributor | |
| Deduce and propagate | attributes |
| Deduce and propagate | false |
| #define BUILD_STAT_MSG_IR_ATTR | ( | TYPE, | |
| NAME | |||
| ) | ("Number of " #TYPE " marked '" #NAME "'") |
Definition at line 76 of file Attributor.cpp.
| #define BUILD_STAT_NAME | ( | NAME, | |
| TYPE | |||
| ) | NumIR##TYPE##_##NAME |
Definition at line 78 of file Attributor.cpp.
Referenced by llvm::IRPosition::getAttrs(), and llvm::Attributor::run().
| #define CREATE_ALL_ABSTRACT_ATTRIBUTE_FOR_POSITION | ( | CLASS | ) |
Definition at line 6886 of file Attributor.cpp.
| #define CREATE_FUNCTION_ABSTRACT_ATTRIBUTE_FOR_POSITION | ( | CLASS | ) |
Definition at line 6854 of file Attributor.cpp.
| #define CREATE_FUNCTION_ONLY_ABSTRACT_ATTRIBUTE_FOR_POSITION | ( | CLASS | ) |
Definition at line 6902 of file Attributor.cpp.
| #define CREATE_NON_RET_ABSTRACT_ATTRIBUTE_FOR_POSITION | ( | CLASS | ) |
Definition at line 6918 of file Attributor.cpp.
| #define CREATE_VALUE_ABSTRACT_ATTRIBUTE_FOR_POSITION | ( | CLASS | ) |
Definition at line 6870 of file Attributor.cpp.
| #define DEBUG_TYPE "attributor" |
Definition at line 48 of file Attributor.cpp.
| #define PIPE_OPERATOR | ( | CLASS | ) |
Definition at line 110 of file Attributor.cpp.
| #define STATS_DECL | ( | NAME, | |
| TYPE, | |||
| MSG | |||
| ) | STATS_DECL_(BUILD_STAT_NAME(NAME, TYPE), MSG); |
Definition at line 80 of file Attributor.cpp.
Referenced by llvm::IRPosition::getAttrs(), and llvm::Attributor::run().
| #define STATS_DECL_ | ( | NAME, | |
| MSG | |||
| ) | STATISTIC(NAME, MSG); |
Definition at line 79 of file Attributor.cpp.
| #define STATS_DECLTRACK | ( | NAME, | |
| TYPE, | |||
| MSG | |||
| ) |
Definition at line 83 of file Attributor.cpp.
Referenced by llvm::IRPosition::getAttrs().
| #define STATS_DECLTRACK_ARG_ATTR | ( | NAME | ) | STATS_DECLTRACK(NAME, Arguments, BUILD_STAT_MSG_IR_ATTR(arguments, NAME)) |
Definition at line 88 of file Attributor.cpp.
Referenced by llvm::IRPosition::getAttrs(), and AAValueConstantRangeArgument::trackStatistics().
| #define STATS_DECLTRACK_CS_ATTR | ( | NAME | ) | STATS_DECLTRACK(NAME, CS, BUILD_STAT_MSG_IR_ATTR(call site, NAME)) |
Definition at line 95 of file Attributor.cpp.
Referenced by llvm::IRPosition::getAttrs(), and AAValueConstantRangeCallSite::trackStatistics().
| #define STATS_DECLTRACK_CSARG_ATTR | ( | NAME | ) |
Definition at line 90 of file Attributor.cpp.
Referenced by llvm::IRPosition::getAttrs(), and AAValueConstantRangeCallSiteArgument::trackStatistics().
| #define STATS_DECLTRACK_CSRET_ATTR | ( | NAME | ) |
Definition at line 100 of file Attributor.cpp.
Referenced by llvm::IRPosition::getAttrs(), and AAValueConstantRangeCallSiteReturned::trackStatistics().
| #define STATS_DECLTRACK_FLOATING_ATTR | ( | NAME | ) |
Definition at line 103 of file Attributor.cpp.
Referenced by llvm::IRPosition::getAttrs(), and AAValueConstantRangeFloating::trackStatistics().
| #define STATS_DECLTRACK_FN_ATTR | ( | NAME | ) | STATS_DECLTRACK(NAME, Function, BUILD_STAT_MSG_IR_ATTR(functions, NAME)) |
Definition at line 93 of file Attributor.cpp.
Referenced by llvm::IRPosition::getAttrs(), and AAValueConstantRangeFunction::trackStatistics().
| #define STATS_DECLTRACK_FNRET_ATTR | ( | NAME | ) |
Definition at line 97 of file Attributor.cpp.
Referenced by llvm::IRPosition::getAttrs(), and AAValueConstantRangeReturned::trackStatistics().
| #define STATS_TRACK | ( | NAME, | |
| TYPE | |||
| ) | ++(BUILD_STAT_NAME(NAME, TYPE)); |
Definition at line 82 of file Attributor.cpp.
| #define SWITCH_PK_CREATE | ( | CLASS, | |
| IRP, | |||
| PK, | |||
| SUFFIX | |||
| ) |
Definition at line 6849 of file Attributor.cpp.
| #define SWITCH_PK_INV | ( | CLASS, | |
| PK, | |||
| POS_NAME | |||
| ) |
Definition at line 6845 of file Attributor.cpp.
|
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 362 of file Attributor.cpp.
References llvm::AttributeList::addAttribute(), llvm::AttributeList::getAttribute(), llvm::Attribute::getKindAsEnum(), llvm::Attribute::getKindAsString(), llvm::AttributeList::hasAttribute(), llvm::Attribute::isEnumAttribute(), isEqualOrWorse(), llvm::Attribute::isIntAttribute(), llvm::Attribute::isStringAttribute(), llvm_unreachable, and llvm::AttributeList::removeAttribute().
Referenced by llvm::IRAttributeManifest::manifestAttrs().
|
static |
Definition at line 5765 of file Attributor.cpp.
References I, and llvm::AAIsDead::isAssumedDead().
Referenced by llvm::Attributor::checkForAllInstructions(), llvm::Attributor::identifyDefaultAbstractAttributes(), and llvm::Attributor::registerFunctionSignatureRewrite().
|
static |
Recursively visit all values that might become IRP at some point.
This will be done by looking through cast instructions, selects, phis, and calls with the "returned" attribute. Once we cannot look through the value any further, the callback VisitValueCB is invoked and passed the current value, the State, and a flag to indicate if we stripped anything. To limit how much effort is invested, we will never visit more values than specified by MaxValues.
Definition at line 266 of file Attributor.cpp.
References Arg, llvm::Function::args(), assert(), llvm::numbers::e, llvm::SmallVectorBase::empty(), llvm::IRPosition::function(), llvm::Attributor::getAAFor(), llvm::IRPosition::getAnchorScope(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getArgOperand(), llvm::IRPosition::getAssociatedValue(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getCalledFunction(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::AAIsDead::isAssumedDead(), llvm::Type::isPointerTy(), llvm::OPTIONAL, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::Attributor::recordDependence(), SI, and llvm::Value::stripPointerCasts().
|
static |
Definition at line 395 of file Attributor.cpp.
References llvm::GetPointerBaseWithConstantOffset(), and llvm::Attributor::getPointerOperand().
Referenced by llvm::IRPosition::getAttrs().
| INITIALIZE_PASS_BEGIN | ( | AttributorLegacyPass | , |
| "attributor" | , | ||
| "Deduce and propagate attributes" | , | ||
| false | , | ||
| false | |||
| ) |
Return true if New is equal or worse than Old.
Definition at line 352 of file Attributor.cpp.
References llvm::Attribute::getValueAsInt(), and llvm::Attribute::isIntAttribute().
Referenced by addIfNotExistent().
For calls (and invokes) we will only replace instruction uses to not disturb the old style call graph.
TODO: Remove this once we get rid of the old PM.
Definition at line 247 of file Attributor.cpp.
References llvm::SmallVectorTemplateBase< T >::push_back(), llvm::Value::replaceAllUsesWith(), and llvm::Value::uses().
Referenced by llvm::IRPosition::getAttrs().
|
static |
}
Definition at line 6743 of file Attributor.cpp.
References llvm::all_of(), assert(), llvm::CHANGED, llvm::dbgs(), DepRecInterval, DisableAttributor, llvm::errs(), F(), llvm::Use::getUser(), llvm::Attributor::identifyDefaultAbstractAttributes(), llvm::Attributor::initializeInformationCache(), LLVM_DEBUG, llvm::Attributor::run(), llvm::Module::size(), and llvm::verifyModule().
Referenced by llvm::AttributorPass::run().
| STATISTIC | ( | NumFnWithExactDefinition | , |
| "Number of function with exact definitions" | |||
| ) |
| STATISTIC | ( | NumFnWithoutExactDefinition | , |
| "Number of function without exact definitions" | |||
| ) |
| 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" | |||
| ) |
| STATISTIC | ( | NumAttributesFixedDueToRequiredDependences | , |
| "Number of abstract attributes fixed due to required dependences" | |||
| ) |
|
static |
Referenced by llvm::Attributor::identifyDefaultAbstractAttributes().
| Deduce and propagate attributes |
Definition at line 6969 of file Attributor.cpp.
Referenced by FunctionNumber(), and llvm::LTOModule::getSymbolAttributes().
| attributor |
Definition at line 6969 of file Attributor.cpp.
|
static |
Referenced by runAttributorOnModule().
|
static |
Referenced by runAttributorOnModule().
|
static |
Referenced by llvm::Attributor::identifyDefaultAbstractAttributes().
| Deduce and propagate false |
Definition at line 6969 of file Attributor.cpp.
|
static |
Referenced by llvm::IRPosition::getAttrs().
|
static |
Referenced by llvm::Attributor::run().
|
static |
Referenced by llvm::IRPosition::getAttrs().
1.8.13