LLVM
10.0.0svn
|
#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/Loads.h"
#include "llvm/Analysis/MemoryBuiltins.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/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.
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") | |
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) |
} 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 * | getPointerOperand (const Instruction *I) |
static const Value * | getBasePointerOfAccessPointerOperand (const Instruction *I, int64_t &BytesOffset, const DataLayout &DL) |
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 > | 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 70 of file Attributor.cpp.
#define BUILD_STAT_NAME | ( | NAME, | |
TYPE | |||
) | NumIR##TYPE##_##NAME |
Definition at line 72 of file Attributor.cpp.
Referenced by llvm::IRPosition::getAttrs().
#define CREATE_ALL_ABSTRACT_ATTRIBUTE_FOR_POSITION | ( | CLASS | ) |
Definition at line 5068 of file Attributor.cpp.
#define CREATE_FUNCTION_ABSTRACT_ATTRIBUTE_FOR_POSITION | ( | CLASS | ) |
Definition at line 5036 of file Attributor.cpp.
#define CREATE_FUNCTION_ONLY_ABSTRACT_ATTRIBUTE_FOR_POSITION | ( | CLASS | ) |
Definition at line 5084 of file Attributor.cpp.
#define CREATE_NON_RET_ABSTRACT_ATTRIBUTE_FOR_POSITION | ( | CLASS | ) |
Definition at line 5100 of file Attributor.cpp.
#define CREATE_VALUE_ABSTRACT_ATTRIBUTE_FOR_POSITION | ( | CLASS | ) |
Definition at line 5052 of file Attributor.cpp.
#define DEBUG_TYPE "attributor" |
Definition at line 44 of file Attributor.cpp.
#define STATS_DECL | ( | NAME, | |
TYPE, | |||
MSG | |||
) | STATS_DECL_(BUILD_STAT_NAME(NAME, TYPE), MSG); |
Definition at line 74 of file Attributor.cpp.
Referenced by llvm::IRPosition::getAttrs(), and llvm::Attributor::run().
#define STATS_DECL_ | ( | NAME, | |
MSG | |||
) | STATISTIC(NAME, MSG); |
Definition at line 73 of file Attributor.cpp.
#define STATS_DECLTRACK | ( | NAME, | |
TYPE, | |||
MSG | |||
) |
Definition at line 77 of file Attributor.cpp.
Referenced by llvm::IRPosition::getAttrs(), and llvm::Attributor::run().
#define STATS_DECLTRACK_ARG_ATTR | ( | NAME | ) | STATS_DECLTRACK(NAME, Arguments, BUILD_STAT_MSG_IR_ATTR(arguments, NAME)) |
Definition at line 82 of file Attributor.cpp.
Referenced by llvm::IRPosition::getAttrs().
#define STATS_DECLTRACK_CS_ATTR | ( | NAME | ) | STATS_DECLTRACK(NAME, CS, BUILD_STAT_MSG_IR_ATTR(call site, NAME)) |
Definition at line 89 of file Attributor.cpp.
Referenced by llvm::IRPosition::getAttrs().
#define STATS_DECLTRACK_CSARG_ATTR | ( | NAME | ) |
Definition at line 84 of file Attributor.cpp.
Referenced by llvm::IRPosition::getAttrs().
#define STATS_DECLTRACK_CSRET_ATTR | ( | NAME | ) |
Definition at line 94 of file Attributor.cpp.
Referenced by llvm::IRPosition::getAttrs().
#define STATS_DECLTRACK_FLOATING_ATTR | ( | NAME | ) |
Definition at line 97 of file Attributor.cpp.
Referenced by llvm::IRPosition::getAttrs().
#define STATS_DECLTRACK_FN_ATTR | ( | NAME | ) | STATS_DECLTRACK(NAME, Function, BUILD_STAT_MSG_IR_ATTR(functions, NAME)) |
Definition at line 87 of file Attributor.cpp.
Referenced by llvm::IRPosition::getAttrs().
#define STATS_DECLTRACK_FNRET_ATTR | ( | NAME | ) |
Definition at line 91 of file Attributor.cpp.
Referenced by llvm::IRPosition::getAttrs().
#define STATS_TRACK | ( | NAME, | |
TYPE | |||
) | ++(BUILD_STAT_NAME(NAME, TYPE)); |
Definition at line 76 of file Attributor.cpp.
Referenced by llvm::Attributor::run().
#define SWITCH_PK_CREATE | ( | CLASS, | |
IRP, | |||
PK, | |||
SUFFIX | |||
) |
Definition at line 5031 of file Attributor.cpp.
#define SWITCH_PK_INV | ( | CLASS, | |
PK, | |||
POS_NAME | |||
) |
Definition at line 5027 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 254 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 4377 of file Attributor.cpp.
References I, and llvm::AAIsDead::isAssumedDead().
Referenced by llvm::Attributor::checkForAllInstructions(), and llvm::Attributor::identifyDefaultAbstractAttributes().
|
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 158 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::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::Attributor::recordDependence(), SI, and llvm::Value::stripPointerCasts().
|
static |
Definition at line 304 of file Attributor.cpp.
References llvm::GetPointerBaseWithConstantOffset(), and llvm::getPointerOperand().
Referenced by llvm::IRPosition::getAttrs().
|
static |
Definition at line 285 of file Attributor.cpp.
References SI.
INITIALIZE_PASS_BEGIN | ( | AttributorLegacyPass | , |
"attributor" | , | ||
"Deduce and propagate attributes" | , | ||
false | , | ||
false | |||
) |
Return true if New
is equal or worse than Old
.
Definition at line 244 of file Attributor.cpp.
References llvm::Attribute::getValueAsInt(), and llvm::Attribute::isIntAttribute().
Referenced by addIfNotExistent().
|
static |
}
Definition at line 4930 of file Attributor.cpp.
References llvm::all_of(), llvm::CHANGED, llvm::dbgs(), DepRecInterval, DisableAttributor, F(), llvm::Use::getUser(), llvm::Attributor::identifyDefaultAbstractAttributes(), llvm::Attributor::initializeInformationCache(), LLVM_DEBUG, llvm::Attributor::run(), and llvm::Module::size().
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" | |||
) |
Deduce and propagate attributes |
Definition at line 5148 of file Attributor.cpp.
Referenced by FunctionNumber(), and llvm::LTOModule::getSymbolAttributes().
attributor |
Definition at line 5148 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 5148 of file Attributor.cpp.
|
static |
Referenced by llvm::IRPosition::getAttrs().
|
static |
Referenced by llvm::Attributor::run().
|
static |
Referenced by llvm::IRPosition::getAttrs().