LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

llvm::AliasAnalysis Class Reference

#include <AliasAnalysis.h>

Inheritance diagram for llvm::AliasAnalysis:

Inheritance graph
[legend]
Collaboration diagram for llvm::AliasAnalysis:

Collaboration graph
[legend]
List of all members.

Public Types

enum  AliasResult { NoAlias = 0, MayAlias = 1, MustAlias = 2 }
enum  ModRefResult { NoModRef = 0, Ref = 1, Mod = 2, ModRef = 3 }
enum  ModRefBehavior {
  DoesNotAccessMemory, AccessesArguments, AccessesArgumentsAndGlobals, OnlyReadsMemory,
  UnknownModRefBehavior
}

Public Member Functions

 AliasAnalysis ()
virtual ~AliasAnalysis ()
const TargetDatagetTargetData () const
virtual AliasResult alias (const Value *V1, unsigned V1Size, const Value *V2, unsigned V2Size)
virtual void getMustAliases (Value *P, std::vector< Value * > &RetVals)
virtual bool pointsToConstantMemory (const Value *P)
ModRefBehavior getModRefBehavior (CallSite CS, std::vector< PointerAccessInfo > *Info=0)
 getModRefBehavior - Return the behavior when calling the given call site.
ModRefBehavior getModRefBehavior (Function *F, std::vector< PointerAccessInfo > *Info=0)
bool doesNotAccessMemory (CallSite CS)
bool doesNotAccessMemory (Function *F)
bool onlyReadsMemory (CallSite CS)
bool onlyReadsMemory (Function *F)
virtual ModRefResult getModRefInfo (CallSite CS, Value *P, unsigned Size)
virtual ModRefResult getModRefInfo (CallSite CS1, CallSite CS2)
virtual bool hasNoModRefInfoForCalls () const
ModRefResult getModRefInfo (LoadInst *L, Value *P, unsigned Size)
 Convenience functions...
ModRefResult getModRefInfo (StoreInst *S, Value *P, unsigned Size)
ModRefResult getModRefInfo (CallInst *C, Value *P, unsigned Size)
ModRefResult getModRefInfo (InvokeInst *I, Value *P, unsigned Size)
ModRefResult getModRefInfo (VAArgInst *I, Value *P, unsigned Size)
ModRefResult getModRefInfo (Instruction *I, Value *P, unsigned Size)
bool canBasicBlockModify (const BasicBlock &BB, const Value *P, unsigned Size)
bool canInstructionRangeModify (const Instruction &I1, const Instruction &I2, const Value *Ptr, unsigned Size)
virtual void deleteValue (Value *V)
virtual void copyValue (Value *From, Value *To)
void replaceWithNewValue (Value *Old, Value *New)

Static Public Attributes

char ID = 0

Protected Member Functions

void InitializeAliasAnalysis (Pass *P)
virtual void getAnalysisUsage (AnalysisUsage &AU) const
virtual ModRefBehavior getModRefBehavior (Function *F, CallSite CS, std::vector< PointerAccessInfo > *Info=0)

Protected Attributes

const TargetDataTD
AliasAnalysisAA

Member Enumeration Documentation

enum llvm::AliasAnalysis::AliasResult
 

Alias analysis result - Either we know for sure that it does not alias, we know for sure it must alias, or we don't know anything: The two pointers _might_ alias. This enum is designed so you can do things like: if (AA.alias(P1, P2)) { ... } to check to see if two pointers might alias.

Enumeration values:
NoAlias 
MayAlias 
MustAlias 

Definition at line 84 of file AliasAnalysis.h.

enum llvm::AliasAnalysis::ModRefBehavior
 

ModRefBehavior - Summary of how a function affects memory in the program. Loads from constant globals are not considered memory accesses for this interface. Also, functions may freely modify stack space local to their invocation without having to report it through these interfaces.

Enumeration values:
DoesNotAccessMemory 
AccessesArguments 
AccessesArgumentsAndGlobals 
OnlyReadsMemory 
UnknownModRefBehavior 

Definition at line 122 of file AliasAnalysis.h.

Referenced by getModRefBehavior(), and getModRefInfo().

enum llvm::AliasAnalysis::ModRefResult
 

ModRefResult - Represent the result of a mod/ref query. Mod and Ref are bits which may be or'd together.

Enumeration values:
NoModRef 
Ref 
Mod 
ModRef 

Definition at line 115 of file AliasAnalysis.h.

Referenced by llvm::LibCallAliasAnalysis::getModRefInfo(), GlobalsModRef::getModRefInfo(), and getModRefInfo().


Constructor & Destructor Documentation

llvm::AliasAnalysis::AliasAnalysis  )  [inline]
 

Definition at line 65 of file AliasAnalysis.h.

AliasAnalysis::~AliasAnalysis  )  [virtual]
 

Definition at line 164 of file AliasAnalysis.cpp.


Member Function Documentation

AliasAnalysis::AliasResult AliasAnalysis::alias const Value V1,
unsigned  V1Size,
const Value V2,
unsigned  V2Size
[virtual]
 

alias - The main low level interface to the alias analysis implementation. Returns a Result indicating whether the two pointers are aliased to each other. This is the interface that must be implemented by specific alias analysis implementations.

Reimplemented in AliasAnalysisCounter, AliasDebugger, NoAA, BasicAliasAnalysis, Andersens, and GlobalsModRef.

Definition at line 45 of file AliasAnalysis.cpp.

References AA.

Referenced by llvm::MemoryDependenceAnalysis::getDependency(), getModRefInfo(), DSE::handleFreeWithNonTrivialDependency(), llvm::AliasSet::mergeSetIn(), DSE::RemoveUndeadPointers(), AAEval::runOnFunction(), and llvm::SelectionDAGLowering::visitIntrinsicCall().

bool AliasAnalysis::canBasicBlockModify const BasicBlock BB,
const Value P,
unsigned  Size
 

canBasicBlockModify - Return true if it is possible for execution of the specified basic block to modify the value pointed to by Ptr.

Definition at line 185 of file AliasAnalysis.cpp.

References llvm::BasicBlock::back(), canInstructionRangeModify(), and llvm::BasicBlock::front().

bool AliasAnalysis::canInstructionRangeModify const Instruction I1,
const Instruction I2,
const Value Ptr,
unsigned  Size
 

canInstructionRangeModify - Return true if it is possible for the execution of the specified instructions to modify the value pointed to by Ptr. The instructions to consider are all of the instructions in the range of [I1,I2] INCLUSIVE. I1 and I2 must be in the same basic block.

Definition at line 195 of file AliasAnalysis.cpp.

References getModRefInfo(), and llvm::Instruction::getParent().

Referenced by canBasicBlockModify().

void AliasAnalysis::copyValue Value From,
Value To
[virtual]
 

copyValue - This method should be used whenever a preexisting value in the program is copied or cloned, introducing a new value. Note that analysis implementations should tolerate clients that use this method to introduce the same value multiple times: if the analysis already knows about a value, it should ignore the request.

Reimplemented in AliasDebugger, NoAA, Andersens, and GlobalsModRef.

Definition at line 78 of file AliasAnalysis.cpp.

References AA.

Referenced by llvm::AliasSetTracker::copyValue(), and llvm::SplitBlockPredecessors().

void AliasAnalysis::deleteValue Value V  )  [virtual]
 

deleteValue - This method should be called whenever an LLVM Value is deleted from the program, for example when an instruction is found to be redundant and is eliminated.

Reimplemented in AliasDebugger, NoAA, Andersens, and GlobalsModRef.

Definition at line 73 of file AliasAnalysis.cpp.

References AA.

Referenced by llvm::AliasSetTracker::deleteValue(), FindPHIToPartitionLoops(), LoopSimplify::runOnFunction(), and llvm::SplitBlockPredecessors().

bool llvm::AliasAnalysis::doesNotAccessMemory Function F  )  [inline]
 

doesNotAccessMemory - If the specified function is known to never read or write memory, return true. For use when the call site is not known.

Reimplemented in AliasAnalysisCounter.

Definition at line 216 of file AliasAnalysis.h.

bool llvm::AliasAnalysis::doesNotAccessMemory CallSite  CS  )  [inline]
 

doesNotAccessMemory - If the specified call is known to never read or write memory, return true. If the call only reads from known-constant memory, it is also legal to return true. Calls that unwind the stack are legal for this predicate.

Many optimizations (such as CSE and LICM) can be performed on such calls without worrying about aliasing properties, and many calls have this property (e.g. calls to 'sin' and 'cos').

This property corresponds to the GCC 'const' attribute.

Reimplemented in AliasAnalysisCounter.

Definition at line 209 of file AliasAnalysis.h.

Referenced by llvm::AliasSetTracker::add(), llvm::AliasSetTracker::deleteValue(), DSE::handleEndBlock(), ValueTable::lookup_or_add(), and llvm::AliasSetTracker::remove().

void AliasAnalysis::getAnalysisUsage AnalysisUsage AU  )  const [protected, virtual]
 

getAnalysisUsage - All alias analysis implementations should invoke this directly (using AliasAnalysis::getAnalysisUsage(AU)) to make sure that TargetData is required by the pass.

Reimplemented in llvm::LibCallAliasAnalysis, AliasAnalysisCounter, AliasDebugger, NoAA, Andersens, and GlobalsModRef.

Definition at line 177 of file AliasAnalysis.cpp.

References llvm::AnalysisUsage::addRequired().

Referenced by llvm::LibCallAliasAnalysis::getAnalysisUsage().

AliasAnalysis::ModRefBehavior AliasAnalysis::getModRefBehavior Function F,
CallSite  CS,
std::vector< PointerAccessInfo > *  Info = 0
[protected, virtual]
 

getModRefBehavior - Return the behavior of the specified function if called from the specified call site. The call site may be null in which case the most generic behavior of this function should be returned.

Reimplemented in AliasDebugger, NoAA, and GlobalsModRef.

Definition at line 62 of file AliasAnalysis.cpp.

References AA, and getModRefBehavior().

AliasAnalysis::ModRefBehavior AliasAnalysis::getModRefBehavior Function F,
std::vector< PointerAccessInfo > *  Info = 0
 

getModRefBehavior - Return the behavior when calling the given function. For use when the call site is not known.

Definition at line 129 of file AliasAnalysis.cpp.

References DoesNotAccessMemory, llvm::Function::doesNotAccessMemory(), getModRefBehavior(), ModRefBehavior, and llvm::Function::onlyReadsMemory().

AliasAnalysis::ModRefBehavior AliasAnalysis::getModRefBehavior CallSite  CS,
std::vector< PointerAccessInfo > *  Info = 0
 

getModRefBehavior - Return the behavior when calling the given call site.

Definition at line 115 of file AliasAnalysis.cpp.

References DoesNotAccessMemory, llvm::CallSite::doesNotAccessMemory(), llvm::CallSite::getCalledFunction(), ModRefBehavior, and llvm::CallSite::onlyReadsMemory().

Referenced by getModRefBehavior(), and getModRefInfo().

ModRefResult llvm::AliasAnalysis::getModRefInfo Instruction I,
Value P,
unsigned  Size
[inline]
 

Definition at line 290 of file AliasAnalysis.h.

References llvm::Instruction::getOpcode().

ModRefResult llvm::AliasAnalysis::getModRefInfo VAArgInst I,
Value P,
unsigned  Size
[inline]
 

Definition at line 287 of file AliasAnalysis.h.

ModRefResult llvm::AliasAnalysis::getModRefInfo InvokeInst I,
Value P,
unsigned  Size
[inline]
 

Definition at line 284 of file AliasAnalysis.h.

ModRefResult llvm::AliasAnalysis::getModRefInfo CallInst C,
Value P,
unsigned  Size
[inline]
 

Definition at line 281 of file AliasAnalysis.h.

AliasAnalysis::ModRefResult AliasAnalysis::getModRefInfo StoreInst S,
Value P,
unsigned  Size
 

Definition at line 102 of file AliasAnalysis.cpp.

References alias(), llvm::User::getOperand(), llvm::Value::getType(), llvm::TargetData::getTypeStoreSize(), NoModRef, pointsToConstantMemory(), and TD.

AliasAnalysis::ModRefResult AliasAnalysis::getModRefInfo LoadInst L,
Value P,
unsigned  Size
 

Convenience functions...

Definition at line 96 of file AliasAnalysis.cpp.

References alias(), llvm::User::getOperand(), llvm::Value::getType(), llvm::TargetData::getTypeStoreSize(), Ref, and TD.

AliasAnalysis::ModRefResult AliasAnalysis::getModRefInfo CallSite  CS1,
CallSite  CS2
[virtual]
 

getModRefInfo - Return information about whether two call sites may refer to the same set of memory locations. This function returns NoModRef if the two calls refer to disjoint memory locations, Ref if CS1 reads memory written by CS2, Mod if CS1 writes to memory read or written by CS2, or ModRef if CS1 might read or write memory accessed by CS2.

Reimplemented in llvm::LibCallAliasAnalysis, AliasAnalysisCounter, AliasDebugger, NoAA, BasicAliasAnalysis, Andersens, and GlobalsModRef.

Definition at line 84 of file AliasAnalysis.cpp.

References AA, and getModRefInfo().

AliasAnalysis::ModRefResult AliasAnalysis::getModRefInfo CallSite  CS,
Value P,
unsigned  Size
[virtual]
 

getModRefInfo (for call sites) - Return whether information about whether a particular call site modifies or reads the memory specified by the pointer.

Reimplemented in llvm::LibCallAliasAnalysis, AliasAnalysisCounter, AliasDebugger, NoAA, BasicAliasAnalysis, Andersens, and GlobalsModRef.

Definition at line 141 of file AliasAnalysis.cpp.

References AA, getModRefBehavior(), Mod, ModRefBehavior, ModRefResult, and pointsToConstantMemory().

Referenced by canInstructionRangeModify(), llvm::MemoryDependenceAnalysis::getDependency(), llvm::LibCallAliasAnalysis::getModRefInfo(), getModRefInfo(), DSE::handleEndBlock(), and AAEval::runOnFunction().

void AliasAnalysis::getMustAliases Value P,
std::vector< Value * > &  RetVals
[virtual]
 

getMustAliases - If there are any pointers known that must alias this pointer, return them now. This allows alias-set based alias analyses to perform a form a value numbering (which is exposed by load-vn). If an alias analysis supports this, it should ADD any must aliased pointers to the specified vector.

Reimplemented in AliasDebugger, NoAA, and Andersens.

Definition at line 51 of file AliasAnalysis.cpp.

References AA.

const TargetData& llvm::AliasAnalysis::getTargetData  )  const [inline]
 

getTargetData - Every alias analysis implementation depends on the size of data items in the current Target. This provides a uniform way to handle it.

Definition at line 72 of file AliasAnalysis.h.

Referenced by llvm::AliasSetTracker::add(), BasicAliasAnalysis::alias(), llvm::AliasSetTracker::remove(), and AAEval::runOnFunction().

bool AliasAnalysis::hasNoModRefInfoForCalls  )  const [virtual]
 

hasNoModRefInfoForCalls - Return true if the analysis has no mod/ref information for pairs of function calls (other than "pure" and "const" functions). This can be used by clients to avoid many pointless queries. Remember that if you override this and chain to another analysis, you must make sure that it doesn't have mod/ref info either.

Reimplemented in llvm::LibCallAliasAnalysis, NoAA, BasicAliasAnalysis, and GlobalsModRef.

Definition at line 68 of file AliasAnalysis.cpp.

References AA.

void AliasAnalysis::InitializeAliasAnalysis Pass P  )  [protected]
 

InitializeAliasAnalysis - Subclasses must call this method to initialize the AliasAnalysis interface before any other methods are called. This is typically called by the run* methods of these subclasses. This may be called multiple times.

Definition at line 169 of file AliasAnalysis.cpp.

References AA, llvm::Pass::getAnalysis(), and TD.

bool llvm::AliasAnalysis::onlyReadsMemory Function F  )  [inline]
 

onlyReadsMemory - If the specified function is known to only read from non-volatile memory (or not access memory at all), return true. For use when the call site is not known.

Reimplemented in AliasAnalysisCounter.

Definition at line 238 of file AliasAnalysis.h.

bool llvm::AliasAnalysis::onlyReadsMemory CallSite  CS  )  [inline]
 

onlyReadsMemory - If the specified call is known to only read from non-volatile memory (or not access memory at all), return true. Calls that unwind the stack are legal for this predicate.

This property allows many common optimizations to be performed in the absence of interfering store instructions, such as CSE of strlen calls.

This property corresponds to the GCC 'pure' attribute.

Reimplemented in AliasAnalysisCounter.

Definition at line 229 of file AliasAnalysis.h.

Referenced by ValueTable::lookup_or_add().

bool AliasAnalysis::pointsToConstantMemory const Value P  )  [virtual]
 

pointsToConstantMemory - If the specified pointer is known to point into constant global memory, return true. This allows disambiguation of store instructions from constant pointers.

Reimplemented in AliasAnalysisCounter, AliasDebugger, NoAA, BasicAliasAnalysis, and Andersens.

Definition at line 56 of file AliasAnalysis.cpp.

References AA.

Referenced by getModRefInfo(), and llvm::SelectionDAGLowering::visitLoad().

void llvm::AliasAnalysis::replaceWithNewValue Value Old,
Value New
[inline]
 

replaceWithNewValue - This method is the obvious combination of the two above, and it provided as a helper to simplify client code.

Definition at line 342 of file AliasAnalysis.h.


Member Data Documentation

AliasAnalysis* llvm::AliasAnalysis::AA [protected]
 

Definition at line 49 of file AliasAnalysis.h.

Referenced by alias(), copyValue(), deleteValue(), getModRefBehavior(), getModRefInfo(), getMustAliases(), hasNoModRefInfoForCalls(), InitializeAliasAnalysis(), and pointsToConstantMemory().

char AliasAnalysis::ID = 0 [static]
 

Reimplemented in llvm::LibCallAliasAnalysis, AliasAnalysisCounter, AliasDebugger, NoAA, BasicAliasAnalysis, Andersens, and GlobalsModRef.

Definition at line 38 of file AliasAnalysis.cpp.

const TargetData* llvm::AliasAnalysis::TD [protected]
 

Definition at line 48 of file AliasAnalysis.h.

Referenced by getModRefInfo(), and InitializeAliasAnalysis().


The documentation for this class was generated from the following files:


This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.