LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Enumerations | Functions | Variables
BasicAliasAnalysis.cpp File Reference
#include "llvm/Analysis/Passes.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/CaptureTracking.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/MemoryBuiltins.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.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 "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Target/TargetLibraryInfo.h"
#include <algorithm>
#include "llvm/IR/Intrinsics.gen"
Include dependency graph for BasicAliasAnalysis.cpp:

Go to the source code of this file.

Macros

#define GET_INTRINSIC_MODREF_BEHAVIOR
 

Enumerations

enum  ExtensionKind
 

Functions

static bool isNonEscapingLocalObject (const Value *V)
 
static bool isEscapeSource (const Value *V)
 
static uint64_t getObjectSize (const Value *V, const DataLayout &TD, const TargetLibraryInfo &TLI, bool RoundToAlign=false)
 
static bool isObjectSmallerThan (const Value *V, uint64_t Size, const DataLayout &TD, const TargetLibraryInfo &TLI)
 
static bool isObjectSize (const Value *V, uint64_t Size, const DataLayout &TD, const TargetLibraryInfo &TLI)
 
static bool isIdentifiedFunctionLocal (const Value *V)
 
static ValueGetLinearExpression (Value *V, APInt &Scale, APInt &Offset, ExtensionKind &Extension, const DataLayout &TD, unsigned Depth)
 
static const ValueDecomposeGEPExpression (const Value *V, int64_t &BaseOffs, SmallVectorImpl< VariableGEPIndex > &VarIndices, const DataLayout *TD)
 
static void GetIndexDifference (SmallVectorImpl< VariableGEPIndex > &Dest, const SmallVectorImpl< VariableGEPIndex > &Src)
 
static const FunctiongetParent (const Value *V)
 
static bool notDifferentParent (const Value *O1, const Value *O2)
 
 INITIALIZE_AG_PASS_BEGIN (BasicAliasAnalysis, AliasAnalysis,"basicaa","Basic Alias Analysis (stateless AA impl)", false, true, false) INITIALIZE_AG_PASS_END(BasicAliasAnalysis
 
Basic Alias Analysis (stateless AA impl)"
 
static bool areVarIndicesEqual (SmallVectorImpl< VariableGEPIndex > &Indices1, SmallVectorImpl< VariableGEPIndex > &Indices2)
 
static AliasAnalysis::AliasResult MergeAliasResults (AliasAnalysis::AliasResult A, AliasAnalysis::AliasResult B)
 

Variables

 AliasAnalysis
 
 basicaa
 
Basic Alias false
 
Basic Alias true
 

Macro Definition Documentation

#define GET_INTRINSIC_MODREF_BEHAVIOR

Enumeration Type Documentation

Definition at line 161 of file BasicAliasAnalysis.cpp.

Function Documentation

Basic Alias Analysis ( stateless AA  impl)
static bool areVarIndicesEqual ( SmallVectorImpl< VariableGEPIndex > &  Indices1,
SmallVectorImpl< VariableGEPIndex > &  Indices2 
)
static

Definition at line 859 of file BasicAliasAnalysis.cpp.

References I, and llvm::SmallVectorTemplateCommon< T >::size().

static const Value* DecomposeGEPExpression ( const Value V,
int64_t &  BaseOffs,
SmallVectorImpl< VariableGEPIndex > &  VarIndices,
const DataLayout TD 
)
static

DecomposeGEPExpression - If V is a symbolic pointer expression, decompose it into a base pointer with a constant offset and a number of scaled symbolic offsets.

The scaled symbolic offsets (represented by pairs of a Value* and a scale in the VarIndices vector) are Value*'s that are known to be scaled by the specified amount, but which may have other unrepresented high bits. As such, the gep cannot necessarily be reconstructed from its decomposed form.

When DataLayout is around, this function is capable of analyzing everything that GetUnderlyingObject can look through. When not, it just looks through pointer casts.

Definition at line 274 of file BasicAliasAnalysis.cpp.

References llvm::SmallVectorTemplateCommon< T >::begin(), llvm::dyn_cast(), llvm::SmallVectorImpl< T >::erase(), llvm::gep_type_begin(), llvm::StructLayout::getElementOffset(), llvm::Type::getIntegerBitWidth(), GetLinearExpression(), llvm::Operator::getOpcode(), llvm::User::getOperand(), llvm::GEPOperator::getPointerAddressSpace(), llvm::Type::getPointerElementType(), llvm::DataLayout::getPointerSizeInBits(), llvm::APInt::getSExtValue(), llvm::DataLayout::getStructLayout(), llvm::Value::getType(), llvm::DataLayout::getTypeAllocSize(), llvm::GEPOperator::hasAllZeroIndices(), I, llvm::Type::isSized(), llvm::User::op_begin(), llvm::User::op_end(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::SimplifyInstruction(), and llvm::SmallVectorTemplateCommon< T >::size().

static void GetIndexDifference ( SmallVectorImpl< VariableGEPIndex > &  Dest,
const SmallVectorImpl< VariableGEPIndex > &  Src 
)
static

GetIndexDifference - Dest and Src are the variable indices from two decomposed GetElementPtr instructions GEP1 and GEP2 which have common base pointers. Subtract the GEP2 indices from GEP1 to find the symbolic difference between the two pointers.

Definition at line 410 of file BasicAliasAnalysis.cpp.

References llvm::SmallVectorTemplateCommon< T >::begin(), llvm::SmallVectorBase::empty(), llvm::SmallVectorImpl< T >::erase(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), and llvm::SmallVectorTemplateCommon< T >::size().

static Value* GetLinearExpression ( Value V,
APInt Scale,
APInt Offset,
ExtensionKind Extension,
const DataLayout TD,
unsigned  Depth 
)
static

GetLinearExpression - Analyze the specified value as a linear expression: "A*V + B", where A and B are constant integers. Return the scale and offset values as APInts and return V as a Value*, and return whether we looked through any sign or zero extends. The incoming Value is known to have IntegerType and it may already be sign or zero extended.

Note that this looks through extends, so the high bits may not be represented in the result.

Definition at line 192 of file BasicAliasAnalysis.cpp.

References llvm::APInt::getBitWidth(), llvm::APInt::getLimitedValue(), llvm::Type::getPrimitiveSizeInBits(), llvm::Value::getType(), llvm::Type::isIntegerTy(), llvm::MaskedValueIsZero(), llvm::APIntOps::Or(), TD, llvm::APInt::trunc(), and llvm::APInt::zext().

Referenced by DecomposeGEPExpression().

static uint64_t getObjectSize ( const Value V,
const DataLayout TD,
const TargetLibraryInfo TLI,
bool  RoundToAlign = false 
)
static

getObjectSize - Return the size of the object specified by V, or UnknownSize if unknown.

Definition at line 87 of file BasicAliasAnalysis.cpp.

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

static const Function* getParent ( const Value V)
static
INITIALIZE_AG_PASS_BEGIN ( BasicAliasAnalysis  ,
AliasAnalysis  ,
"basicaa"  ,
"Basic Alias Analysis (stateless AA impl)"  ,
false  ,
true  ,
false   
)
static bool isEscapeSource ( const Value V)
static

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

Definition at line 72 of file BasicAliasAnalysis.cpp.

static bool isIdentifiedFunctionLocal ( const Value V)
static

isIdentifiedFunctionLocal - Return true if V is umabigously identified at the function-level. Different IdentifiedFunctionLocals can't alias. Further, an IdentifiedFunctionLocal can not alias with any function arguments other than itself, which is not neccessarily true for IdentifiedObjects.

Definition at line 150 of file BasicAliasAnalysis.cpp.

References llvm::isNoAliasArgument(), and llvm::isNoAliasCall().

static bool isNonEscapingLocalObject ( const Value V)
static

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

Definition at line 47 of file BasicAliasAnalysis.cpp.

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

static bool isObjectSize ( const Value V,
uint64_t  Size,
const DataLayout TD,
const TargetLibraryInfo TLI 
)
static

isObjectSize - Return true if we can prove that the object specified by V has size Size.

Definition at line 139 of file BasicAliasAnalysis.cpp.

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

static bool isObjectSmallerThan ( const Value V,
uint64_t  Size,
const DataLayout TD,
const TargetLibraryInfo TLI 
)
static

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

Definition at line 98 of file BasicAliasAnalysis.cpp.

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

static bool notDifferentParent ( const Value O1,
const Value O2 
)
static

Definition at line 457 of file BasicAliasAnalysis.cpp.

References getParent().

Variable Documentation

Definition at line 572 of file BasicAliasAnalysis.cpp.

basicaa

Definition at line 572 of file BasicAliasAnalysis.cpp.

Basic Alias false

Definition at line 574 of file BasicAliasAnalysis.cpp.

Basic Alias true

Definition at line 574 of file BasicAliasAnalysis.cpp.