LLVM  mainline
Defines | Functions | Variables
BasicAliasAnalysis.cpp File Reference
#include "llvm/Analysis/BasicAliasAnalysis.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/CFG.h"
#include "llvm/Analysis/CaptureTracking.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/MemoryBuiltins.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Operator.h"
#include "llvm/Pass.h"
#include "llvm/Support/ErrorHandling.h"
#include <algorithm>
Include dependency graph for BasicAliasAnalysis.cpp:

Go to the source code of this file.

Defines

#define DEBUG_TYPE   "basicaa"
 SearchLimitReached / SearchTimes shows how often the limit of to decompose GEPs is reached.

Functions

 STATISTIC (SearchLimitReached,"Number of times the limit to ""decompose GEPs is reached")
 STATISTIC (SearchTimes,"Number of times a GEP is decomposed")
static bool isNonEscapingLocalObject (const Value *V)
 Returns true if the pointer is to a function-local object that never escapes from the function.
static bool isEscapeSource (const Value *V)
 Returns true if the pointer is one which would have been considered an escape by isNonEscapingLocalObject.
static uint64_t getObjectSize (const Value *V, const DataLayout &DL, const TargetLibraryInfo &TLI, bool RoundToAlign=false)
 Returns the size of the object specified by V or UnknownSize if unknown.
static bool isObjectSmallerThan (const Value *V, uint64_t Size, const DataLayout &DL, const TargetLibraryInfo &TLI)
 Returns true if we can prove that the object specified by V is smaller than Size.
static bool isObjectSize (const Value *V, uint64_t Size, const DataLayout &DL, const TargetLibraryInfo &TLI)
 Returns true if we can prove that the object specified by V has size Size.
static bool isMemsetPattern16 (const Function *MS, const TargetLibraryInfo &TLI)
static bool isWriteOnlyParam (ImmutableCallSite CS, unsigned ArgIdx, const TargetLibraryInfo &TLI)
 Returns true if this is a writeonly (i.e Mod only) parameter.
static bool isAssumeIntrinsic (ImmutableCallSite CS)
static const FunctiongetParent (const Value *V)
static bool notDifferentParent (const Value *O1, const Value *O2)
static AliasResult aliasSameBasePointerGEPs (const GEPOperator *GEP1, uint64_t V1Size, const GEPOperator *GEP2, uint64_t V2Size, const DataLayout &DL)
 Provide ad-hoc rules to disambiguate accesses through two GEP operators, both having the exact same pointer operand.
static AliasResult MergeAliasResults (AliasResult A, AliasResult B)
 INITIALIZE_PASS_BEGIN (BasicAAWrapperPass,"basicaa","Basic Alias Analysis (stateless AA impl)", true, true) INITIALIZE_PASS_END(BasicAAWrapperPass
Basic Alias Analysis (stateless AA impl)"

Variables

static cl::opt< boolEnableRecPhiAnalysis ("basicaa-recphi", cl::Hidden, cl::init(false))
 Enable analysis of recursive PHI nodes.
const unsigned MaxNumPhiBBsValueReachabilityCheck = 20
 Cutoff after which to stop analysing a set of phi nodes potentially involved in a cycle.
static const unsigned MaxLookupSearchDepth = 6
 basicaa
Basic Alias true

Define Documentation

#define DEBUG_TYPE   "basicaa"

SearchLimitReached / SearchTimes shows how often the limit of to decompose GEPs is reached.

It will affect the precision of basic alias analysis.

Definition at line 49 of file BasicAliasAnalysis.cpp.


Function Documentation

static AliasResult aliasSameBasePointerGEPs ( const GEPOperator GEP1,
uint64_t  V1Size,
const GEPOperator GEP2,
uint64_t  V2Size,
const DataLayout DL 
) [static]
Basic Alias Analysis ( stateless AA  impl)
static uint64_t getObjectSize ( const Value V,
const DataLayout DL,
const TargetLibraryInfo TLI,
bool  RoundToAlign = false 
) [static]

Returns the size of the object specified by V or UnknownSize if unknown.

Definition at line 110 of file BasicAliasAnalysis.cpp.

References llvm::getObjectSize(), and llvm::MemoryLocation::UnknownSize.

static const Function* getParent ( const Value V) [static]
INITIALIZE_PASS_BEGIN ( BasicAAWrapperPass  ,
"basicaa"  ,
"Basic Alias Analysis (stateless AA impl)"  ,
true  ,
true   
)
static bool isAssumeIntrinsic ( ImmutableCallSite  CS) [static]
static bool isEscapeSource ( const Value V) [static]

Returns true if the pointer is one which would have been considered an escape by isNonEscapingLocalObject.

Definition at line 96 of file BasicAliasAnalysis.cpp.

static bool isMemsetPattern16 ( const Function MS,
const TargetLibraryInfo TLI 
) [static]
static bool isNonEscapingLocalObject ( const Value V) [static]

Returns true if the pointer is to a function-local object that never escapes from the function.

Definition at line 71 of file BasicAliasAnalysis.cpp.

References A, llvm::isNoAliasCall(), and llvm::PointerMayBeCaptured().

Referenced by llvm::BasicAAResult::getModRefInfo().

static bool isObjectSize ( const Value V,
uint64_t  Size,
const DataLayout DL,
const TargetLibraryInfo TLI 
) [static]

Returns true if we can prove that the object specified by V has size Size.

Definition at line 161 of file BasicAliasAnalysis.cpp.

References llvm::getObjectSize(), and llvm::MemoryLocation::UnknownSize.

static bool isObjectSmallerThan ( const Value V,
uint64_t  Size,
const DataLayout DL,
const TargetLibraryInfo TLI 
) [static]

Returns true if we can prove that the object specified by V is smaller than Size.

Definition at line 121 of file BasicAliasAnalysis.cpp.

References llvm::getObjectSize(), llvm::isIdentifiedObject(), and llvm::MemoryLocation::UnknownSize.

static bool isWriteOnlyParam ( ImmutableCallSite  CS,
unsigned  ArgIdx,
const TargetLibraryInfo TLI 
) [static]

Returns true if this is a writeonly (i.e Mod only) parameter.

Currently, we don't have a writeonly attribute, so this only knows about builtin intrinsics and target library functions. We could consider adding a writeonly attribute in the future and moving all of these facts to either Intrinsics.td or InferFunctionAttr.cpp

Definition at line 594 of file BasicAliasAnalysis.cpp.

References llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getCalledFunction(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getInstruction(), isMemsetPattern16(), and llvm::AAResultBase< BasicAAResult >::TLI.

Referenced by llvm::BasicAAResult::getArgModRefInfo().

static AliasResult MergeAliasResults ( AliasResult  A,
AliasResult  B 
) [static]

Definition at line 1145 of file BasicAliasAnalysis.cpp.

References A, llvm::MayAlias, llvm::MustAlias, and llvm::PartialAlias.

static bool notDifferentParent ( const Value O1,
const Value O2 
) [static]
STATISTIC ( SearchLimitReached  ,
"Number of times the limit to ""decompose GEPs is reached"   
)
STATISTIC ( SearchTimes  ,
"Number of times a GEP is decomposed"   
)

Variable Documentation

Definition at line 1598 of file BasicAliasAnalysis.cpp.

cl::opt<bool> EnableRecPhiAnalysis("basicaa-recphi", cl::Hidden, cl::init(false)) [static]

Enable analysis of recursive PHI nodes.

Definition at line 63 of file BasicAliasAnalysis.cpp.

Cutoff after which to stop analysing a set of phi nodes potentially involved in a cycle.

Because we are analysing 'through' phi nodes, we need to be careful with value equivalence. We use reachability to make sure a value cannot be involved in a cycle.

Definition at line 58 of file BasicAliasAnalysis.cpp.

Basic Alias true

Definition at line 1599 of file BasicAliasAnalysis.cpp.