|
LLVM
7.0.0
|
#include "llvm/Analysis/BasicAliasAnalysis.h"#include "llvm/ADT/APInt.h"#include "llvm/ADT/SmallPtrSet.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/Statistic.h"#include "llvm/Analysis/AliasAnalysis.h"#include "llvm/Analysis/AssumptionCache.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/MemoryLocation.h"#include "llvm/Analysis/TargetLibraryInfo.h"#include "llvm/Analysis/ValueTracking.h"#include "llvm/Analysis/PhiValues.h"#include "llvm/IR/Argument.h"#include "llvm/IR/Attributes.h"#include "llvm/IR/CallSite.h"#include "llvm/IR/Constant.h"#include "llvm/IR/Constants.h"#include "llvm/IR/DataLayout.h"#include "llvm/IR/DerivedTypes.h"#include "llvm/IR/Dominators.h"#include "llvm/IR/Function.h"#include "llvm/IR/GetElementPtrTypeIterator.h"#include "llvm/IR/GlobalAlias.h"#include "llvm/IR/GlobalVariable.h"#include "llvm/IR/InstrTypes.h"#include "llvm/IR/Instruction.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/Intrinsics.h"#include "llvm/IR/Metadata.h"#include "llvm/IR/Operator.h"#include "llvm/IR/Type.h"#include "llvm/IR/User.h"#include "llvm/IR/Value.h"#include "llvm/Pass.h"#include "llvm/Support/Casting.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/Compiler.h"#include "llvm/Support/KnownBits.h"#include <cassert>#include <cstdint>#include <cstdlib>#include <utility>Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "basicaa" |
Functions | |
| STATISTIC (SearchLimitReached, "Number of times the limit to " "decompose GEPs is reached") | |
| SearchLimitReached / SearchTimes shows how often the limit of to decompose GEPs is reached. More... | |
| 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. More... | |
| static bool | isEscapeSource (const Value *V) |
| Returns true if the pointer is one which would have been considered an escape by isNonEscapingLocalObject. More... | |
| static uint64_t | getObjectSize (const Value *V, const DataLayout &DL, const TargetLibraryInfo &TLI, bool NullIsValidLoc, bool RoundToAlign=false) |
| Returns the size of the object specified by V or UnknownSize if unknown. More... | |
| static bool | isObjectSmallerThan (const Value *V, uint64_t Size, const DataLayout &DL, const TargetLibraryInfo &TLI, bool NullIsValidLoc) |
| Returns true if we can prove that the object specified by V is smaller than Size. More... | |
| static bool | isObjectSize (const Value *V, uint64_t Size, const DataLayout &DL, const TargetLibraryInfo &TLI, bool NullIsValidLoc) |
| Returns true if we can prove that the object specified by V has size Size. More... | |
| static int64_t | adjustToPointerSize (int64_t Offset, unsigned PointerSize) |
| To ensure a pointer offset fits in an integer of size PointerSize (in bits) when that size is smaller than 64. More... | |
| static bool | isWriteOnlyParam (ImmutableCallSite CS, unsigned ArgIdx, const TargetLibraryInfo &TLI) |
| Returns true if this is a writeonly (i.e Mod only) parameter. More... | |
| static bool | isIntrinsicCall (ImmutableCallSite CS, Intrinsic::ID IID) |
| static const Function * | getParent (const Value *V) |
| static bool | notDifferentParent (const Value *O1, const Value *O2) |
| static AliasResult | aliasSameBasePointerGEPs (const GEPOperator *GEP1, LocationSize V1Size, const GEPOperator *GEP2, LocationSize V2Size, const DataLayout &DL) |
| Provide ad-hoc rules to disambiguate accesses through two GEP operators, both having the exact same pointer operand. More... | |
| static AliasResult | MergeAliasResults (AliasResult A, AliasResult B) |
| INITIALIZE_PASS_BEGIN (BasicAAWrapperPass, "basicaa", "Basic Alias Analysis (stateless AA impl)", false, true) INITIALIZE_PASS_END(BasicAAWrapperPass | |
| Basic Alias | Analysis (stateless AA impl)" |
Variables | |
| static cl::opt< bool > | EnableRecPhiAnalysis ("basicaa-recphi", cl::Hidden, cl::init(false)) |
| Enable analysis of recursive PHI nodes. More... | |
| const unsigned | MaxNumPhiBBsValueReachabilityCheck = 20 |
| Cutoff after which to stop analysing a set of phi nodes potentially involved in a cycle. More... | |
| static const unsigned | MaxLookupSearchDepth = 6 |
| basicaa | |
| Basic Alias | false |
| #define DEBUG_TYPE "basicaa" |
Definition at line 64 of file BasicAliasAnalysis.cpp.
|
static |
To ensure a pointer offset fits in an integer of size PointerSize (in bits) when that size is smaller than 64.
This is an issue in particular for 32b programs with negative indices that rely on two's complement wrap-arounds for precise alias information.
Definition at line 387 of file BasicAliasAnalysis.cpp.
References AS, assert(), llvm::dyn_cast(), E, llvm::gep_type_begin(), llvm::getArgumentAliasingToReturnedPointer(), llvm::StructLayout::getElementOffset(), llvm::generic_gep_type_iterator< ItTy >::getIndexedType(), llvm::Type::getIntegerBitWidth(), llvm::Operator::getOpcode(), llvm::User::getOperand(), llvm::GEPOperator::getPointerAddressSpace(), llvm::DataLayout::getPointerSizeInBits(), llvm::APInt::getSExtValue(), llvm::GEPOperator::getSourceElementType(), llvm::DataLayout::getStructLayout(), llvm::generic_gep_type_iterator< ItTy >::getStructTypeOrNull(), llvm::Value::getType(), llvm::DataLayout::getTypeAllocSize(), I, llvm::Type::isSized(), MaxLookupSearchDepth, llvm::User::op_begin(), llvm::User::op_end(), llvm::NVPTX::PTXCvtMode::RP, llvm::JumpTable::Simplified, and llvm::SimplifyInstruction().
|
static |
Provide ad-hoc rules to disambiguate accesses through two GEP operators, both having the exact same pointer operand.
Definition at line 1003 of file BasicAliasAnalysis.cpp.
References assert(), llvm::computeKnownBits(), llvm::dyn_cast(), llvm::StructLayout::getElementOffset(), llvm::GetElementPtrInst::getIndexedType(), llvm::GEPOperator::getNumIndices(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::GEPOperator::getPointerOperand(), llvm::GEPOperator::getPointerOperandType(), llvm::ConstantInt::getSExtValue(), llvm::StructLayout::getSizeInBytes(), llvm::GEPOperator::getSourceElementType(), llvm::DataLayout::getStructLayout(), llvm::Value::getType(), llvm::DataLayout::getTypeStoreSize(), llvm::ConstantInt::getZExtValue(), if(), llvm::APInt::intersects(), llvm::GEPOperator::isInBounds(), llvm::isKnownNonEqual(), llvm::KnownBits::isNegative(), llvm::KnownBits::isNonNegative(), llvm::MayAlias, llvm::MustAlias, llvm::NoAlias, llvm::KnownBits::One, llvm::PartialAlias, llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::Value::stripPointerCastsAndInvariantGroups(), llvm::MemoryLocation::UnknownSize, llvm::NVPTX::PTXLdStInstCode::V2, and llvm::KnownBits::Zero.
| Basic Alias Analysis | ( | stateless AA | impl | ) |
|
static |
Returns the size of the object specified by V or UnknownSize if unknown.
Definition at line 153 of file BasicAliasAnalysis.cpp.
References llvm::getObjectSize(), llvm::ObjectSizeOpts::NullIsUnknownSize, llvm::ObjectSizeOpts::RoundToAlign, llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Size, and llvm::MemoryLocation::UnknownSize.
Definition at line 746 of file BasicAliasAnalysis.cpp.
References llvm::GlobalValue::getParent().
Referenced by llvm::FastISel::canFoldAddIntoGEP(), llvm::DIE::children(), llvm::colorEHFunclets(), computeBranchTargetAndInversion(), llvm::JumpThreadingPass::ComputeValueKnownInPredecessors(), createBBSelectReg(), llvm::createX86OptimizeLEAs(), llvm::DWARFDie::dump(), ensureValueAvailableInSuccessor(), llvm::NamedMDNode::eraseFromParent(), llvm::CodeExtractor::findAllocas(), findBasePointers(), llvm::CodeExtractor::findInputsOutputs(), llvm::LiveVariables::VarInfo::findKill(), llvm::RegionBase< RegionTraits< Function > >::getDepth(), llvm::DWARFUnit::getDIEAtIndex(), getLocalFunctionMetadata(), getPHIDestReg(), GetPointerOperand(), llvm::LazyValueInfo::getPredicateAt(), getReductionValue(), llvm::GCProjectionInst::getStatepoint(), llvm::SelectionDAGBuilder::getValueImpl(), hasSameExtUse(), llvm::FastISel::hasTrivialKill(), insertSpills(), is_empty(), isBlockValidForExtraction(), llvm::CodeExtractor::isLegalToShrinkwrapLifetimeMarkers(), isTargetConstant(), LLVMGetBasicBlockParent(), LLVMGetGlobalParent(), LLVMGetInstructionParent(), LLVMGetParamParent(), llvm::NVPTXTargetLowering::LowerFormalArguments(), MarkBlocksLiveIn(), llvm::MergeBlockIntoPredecessor(), llvm::PHITransAddr::NeedsPHITranslationFromBlock(), notDifferentParent(), operator<<(), PlaceMarkers(), preheader(), llvm::MachineFunction::print(), llvm::Function::print(), llvm::NamedMDNode::print(), processSwitch(), propagateMetadata(), redirectValuesFromPredecessorsToPhi(), llvm::AssumptionCache::registerAssumption(), removeExternalCFGEdges(), llvm::replaceDominatedUsesWith(), llvm::VLIWMachineScheduler::schedule(), llvm::ScheduleDAGMI::schedule(), llvm::SIScheduleDAGMI::schedule(), llvm::ScheduleDAGMILive::schedule(), shouldRotateLoopExitingLatch(), sinkAndCmp0Expression(), splitCallSite(), StackMallocSizeClass(), tryUnmergingGEPsAcrossIndirectBr(), llvm::slpvectorizer::BoUpSLP::vectorizeTree(), and llvm::LoopBase< BasicBlock, Loop >::verifyLoop().
| INITIALIZE_PASS_BEGIN | ( | BasicAAWrapperPass | , |
| "basicaa" | , | ||
| "Basic Alias Analysis (stateless AA impl)" | , | ||
| false | , | ||
| true | |||
| ) |
Referenced by llvm::BasicAAWrapperPass::BasicAAWrapperPass().
Returns true if the pointer is one which would have been considered an escape by isNonEscapingLocalObject.
Definition at line 136 of file BasicAliasAnalysis.cpp.
Referenced by MergeAliasResults().
|
static |
Definition at line 740 of file BasicAliasAnalysis.cpp.
References llvm::dyn_cast(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getInstruction(), and llvm::IntrinsicInst::getIntrinsicID().
Referenced by llvm::BasicAAResult::getModRefInfo().
Returns true if the pointer is to a function-local object that never escapes from the function.
Definition at line 111 of file BasicAliasAnalysis.cpp.
References llvm::isNoAliasCall(), and llvm::PointerMayBeCaptured().
Referenced by llvm::BasicAAResult::getModRefInfo(), and MergeAliasResults().
|
static |
Returns true if we can prove that the object specified by V has size Size.
Definition at line 210 of file BasicAliasAnalysis.cpp.
References llvm::MCID::Add, assert(), llvm::Depth, llvm::APInt::getBitWidth(), llvm::APInt::getLimitedValue(), llvm::getObjectSize(), llvm::Type::getPrimitiveSizeInBits(), llvm::Value::getType(), llvm::Type::isIntegerTy(), LLVM_FALLTHROUGH, llvm::MaskedValueIsZero(), Result, llvm::APInt::sext(), llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Size, llvm::APInt::trunc(), llvm::MemoryLocation::UnknownSize, and llvm::APInt::zextOrSelf().
Referenced by MergeAliasResults().
|
static |
Returns true if we can prove that the object specified by V is smaller than Size.
Definition at line 168 of file BasicAliasAnalysis.cpp.
References llvm::getObjectSize(), llvm::isIdentifiedObject(), llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Size, and llvm::MemoryLocation::UnknownSize.
Referenced by MergeAliasResults().
|
static |
Returns true if this is a writeonly (i.e Mod only) parameter.
Definition at line 701 of file BasicAliasAnalysis.cpp.
References llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getCalledFunction(), llvm::TargetLibraryInfo::getLibFunc(), llvm::TargetLibraryInfo::has(), and llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::paramHasAttr().
Referenced by llvm::BasicAAResult::getArgModRefInfo().
|
static |
Definition at line 1435 of file BasicAliasAnalysis.cpp.
References llvm::abs(), llvm::AAResultBase< DerivedT >::AAResultsProxy::alias(), assert(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::count(), llvm::dyn_cast(), llvm::SmallVectorBase::empty(), llvm::SmallPtrSetImplBase::empty(), EnableRecPhiAnalysis, llvm::SmallVectorImpl< T >::erase(), llvm::PointerType::getAddressSpace(), llvm::AAResultBase< DerivedT >::getBestAAResults(), llvm::SelectInst::getCondition(), llvm::SelectInst::getFalseValue(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::PHINode::getNumIncomingValues(), llvm::Instruction::getParent(), llvm::SelectInst::getTrueValue(), llvm::Value::getType(), llvm::GlobalValue::getType(), llvm::GetUnderlyingObject(), llvm::PhiValues::getValuesForPhi(), llvm::APInt::getZExtValue(), llvm::PHINode::incoming_values(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), llvm::SmallPtrSetImpl< PtrType >::insert(), isEscapeSource(), llvm::isIdentifiedFunctionLocal(), llvm::isIdentifiedObject(), isNonEscapingLocalObject(), isObjectSize(), isObjectSmallerThan(), llvm::Type::isPointerTy(), llvm::isPotentiallyReachable(), MaxLookupSearchDepth, MaxNumPhiBBsValueReachabilityCheck, llvm::MayAlias, llvm::MustAlias, llvm::NoAlias, llvm::NullPointerIsDefined(), P, llvm::PartialAlias, llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), Result, SI, llvm::SmallVectorBase::size(), llvm::SmallPtrSetImplBase::size(), llvm::Value::stripPointerCastsAndInvariantGroups(), std::swap(), llvm::APIntOps::umin(), and llvm::MemoryLocation::UnknownSize.
Definition at line 759 of file BasicAliasAnalysis.cpp.
References getParent().
Referenced by llvm::BasicAAResult::alias(), and llvm::BasicAAResult::getModRefInfo().
| STATISTIC | ( | SearchLimitReached | , |
| "Number of times the limit to " "decompose GEPs is reached" | |||
| ) |
SearchLimitReached / SearchTimes shows how often the limit of to decompose GEPs is reached.
It will affect the precision of basic alias analysis.
| STATISTIC | ( | SearchTimes | , |
| "Number of times a GEP is decomposed" | |||
| ) |
| basicaa |
Definition at line 1938 of file BasicAliasAnalysis.cpp.
Enable analysis of recursive PHI nodes.
Referenced by MergeAliasResults().
| Basic Alias false |
Definition at line 1939 of file BasicAliasAnalysis.cpp.
Definition at line 87 of file BasicAliasAnalysis.cpp.
Referenced by adjustToPointerSize(), and MergeAliasResults().
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 82 of file BasicAliasAnalysis.cpp.
Referenced by MergeAliasResults().
1.8.13