2002-08-22 18:25:20 +00:00
|
|
|
//===- llvm/Analysis/AliasAnalysis.h - Alias Analysis Interface -*- C++ -*-===//
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 19:59:42 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-08-22 18:25:20 +00:00
|
|
|
//
|
|
|
|
// This file defines the generic AliasAnalysis interface, which is used as the
|
|
|
|
// common interface used by all clients of alias analysis information, and
|
2003-02-26 19:24:47 +00:00
|
|
|
// implemented by all alias analysis implementations. Mod/Ref information is
|
|
|
|
// also captured by this interface.
|
2002-08-22 18:25:20 +00:00
|
|
|
//
|
|
|
|
// Implementations of this interface must implement the various virtual methods,
|
|
|
|
// which automatically provides functionality for the entire suite of client
|
|
|
|
// APIs.
|
|
|
|
//
|
2003-02-26 19:24:47 +00:00
|
|
|
// This API represents memory as a (Pointer, Size) pair. The Pointer component
|
|
|
|
// specifies the base memory address of the region, the Size specifies how large
|
2010-08-03 01:07:32 +00:00
|
|
|
// of an area is being queried, or UnknownSize if the size is not known.
|
|
|
|
// Pointers that point to two completely different objects in memory never
|
|
|
|
// alias, regardless of the value of the Size component.
|
2003-02-26 19:24:47 +00:00
|
|
|
//
|
2002-08-22 18:25:20 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_ANALYSIS_ALIAS_ANALYSIS_H
|
|
|
|
#define LLVM_ANALYSIS_ALIAS_ANALYSIS_H
|
|
|
|
|
2003-02-26 19:24:47 +00:00
|
|
|
#include "llvm/Support/CallSite.h"
|
2006-07-26 16:18:00 +00:00
|
|
|
#include "llvm/System/IncludeFile.h"
|
2007-02-12 05:00:35 +00:00
|
|
|
#include <vector>
|
2003-11-11 22:41:34 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2003-02-26 19:24:47 +00:00
|
|
|
class LoadInst;
|
|
|
|
class StoreInst;
|
2005-06-20 15:24:23 +00:00
|
|
|
class VAArgInst;
|
2003-02-26 19:24:47 +00:00
|
|
|
class TargetData;
|
2006-06-07 20:00:19 +00:00
|
|
|
class Pass;
|
|
|
|
class AnalysisUsage;
|
2003-02-26 19:24:47 +00:00
|
|
|
|
|
|
|
class AliasAnalysis {
|
|
|
|
protected:
|
2004-05-23 21:12:38 +00:00
|
|
|
const TargetData *TD;
|
2010-08-05 23:44:45 +00:00
|
|
|
|
|
|
|
private:
|
2004-05-23 21:12:38 +00:00
|
|
|
AliasAnalysis *AA; // Previous Alias Analysis to chain to.
|
|
|
|
|
2010-08-05 23:44:45 +00:00
|
|
|
protected:
|
2003-02-26 19:24:47 +00:00
|
|
|
/// 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.
|
|
|
|
///
|
|
|
|
void InitializeAliasAnalysis(Pass *P);
|
2005-04-21 20:19:05 +00:00
|
|
|
|
2008-05-30 00:01:36 +00:00
|
|
|
/// getAnalysisUsage - All alias analysis implementations should invoke this
|
2009-07-25 00:48:42 +00:00
|
|
|
/// directly (using AliasAnalysis::getAnalysisUsage(AU)).
|
2003-02-26 19:24:47 +00:00
|
|
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
|
|
|
|
|
|
|
|
public:
|
2007-05-03 01:11:54 +00:00
|
|
|
static char ID; // Class identification, replacement for typeinfo
|
2004-05-23 21:12:38 +00:00
|
|
|
AliasAnalysis() : TD(0), AA(0) {}
|
2003-02-26 19:24:47 +00:00
|
|
|
virtual ~AliasAnalysis(); // We want to be subclassed
|
|
|
|
|
2010-08-03 01:03:11 +00:00
|
|
|
/// UnknownSize - This is a special value which can be used with the
|
|
|
|
/// size arguments in alias queries to indicate that the caller does not
|
|
|
|
/// know the sizes of the potential memory references.
|
|
|
|
static unsigned const UnknownSize = ~0u;
|
|
|
|
|
2009-07-25 00:48:42 +00:00
|
|
|
/// getTargetData - Return a pointer to the current TargetData object, or
|
|
|
|
/// null if no TargetData object is available.
|
2004-03-11 23:08:20 +00:00
|
|
|
///
|
2009-07-25 00:48:42 +00:00
|
|
|
const TargetData *getTargetData() const { return TD; }
|
|
|
|
|
|
|
|
/// getTypeStoreSize - Return the TargetData store size for the given type,
|
|
|
|
/// if known, or a conservative value otherwise.
|
|
|
|
///
|
|
|
|
unsigned getTypeStoreSize(const Type *Ty);
|
2002-08-22 18:25:20 +00:00
|
|
|
|
2003-02-26 19:24:47 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
/// Alias Queries...
|
|
|
|
///
|
2002-08-22 18:25:20 +00:00
|
|
|
|
2010-09-14 21:25:10 +00:00
|
|
|
/// Location - A description of a memory location.
|
|
|
|
struct Location {
|
|
|
|
/// Ptr - The address of the start of the location.
|
|
|
|
const Value *Ptr;
|
|
|
|
/// Size - The size of the location.
|
|
|
|
unsigned Size;
|
|
|
|
/// TBAATag - The metadata node which describes the TBAA type of
|
|
|
|
/// the location, or null if there is no (unique) tag.
|
|
|
|
const MDNode *TBAATag;
|
|
|
|
|
|
|
|
explicit Location(const Value *P = 0,
|
|
|
|
unsigned S = UnknownSize,
|
|
|
|
const MDNode *N = 0)
|
|
|
|
: Ptr(P), Size(S), TBAATag(N) {}
|
|
|
|
};
|
|
|
|
|
2002-08-22 21:22:25 +00:00
|
|
|
/// 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.
|
|
|
|
///
|
2010-08-03 01:07:32 +00:00
|
|
|
/// See docs/AliasAnalysis.html for more information on the specific meanings
|
|
|
|
/// of these values.
|
|
|
|
///
|
2003-02-26 19:24:47 +00:00
|
|
|
enum AliasResult { NoAlias = 0, MayAlias = 1, MustAlias = 2 };
|
2002-08-22 18:25:20 +00:00
|
|
|
|
2002-08-22 21:22:25 +00:00
|
|
|
/// 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.
|
2010-09-14 21:25:10 +00:00
|
|
|
virtual AliasResult alias(const Location &LocA, const Location &LocB);
|
2002-08-22 18:25:20 +00:00
|
|
|
|
2010-09-14 21:25:10 +00:00
|
|
|
/// alias - A convenience wrapper.
|
|
|
|
AliasResult alias(const Value *V1, unsigned V1Size,
|
|
|
|
const Value *V2, unsigned V2Size) {
|
|
|
|
return alias(Location(V1, V1Size), Location(V2, V2Size));
|
|
|
|
}
|
|
|
|
|
|
|
|
/// alias - A convenience wrapper.
|
2010-08-03 00:56:30 +00:00
|
|
|
AliasResult alias(const Value *V1, const Value *V2) {
|
2010-08-03 01:03:11 +00:00
|
|
|
return alias(V1, UnknownSize, V2, UnknownSize);
|
2010-08-03 00:56:30 +00:00
|
|
|
}
|
|
|
|
|
2009-11-23 16:38:54 +00:00
|
|
|
/// isNoAlias - A trivial helper function to check to see if the specified
|
|
|
|
/// pointers are no-alias.
|
2010-09-14 21:25:10 +00:00
|
|
|
bool isNoAlias(const Location &LocA, const Location &LocB) {
|
|
|
|
return alias(LocA, LocB) == NoAlias;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// isNoAlias - A convenience wrapper.
|
2009-11-23 16:38:54 +00:00
|
|
|
bool isNoAlias(const Value *V1, unsigned V1Size,
|
|
|
|
const Value *V2, unsigned V2Size) {
|
2010-09-14 21:25:10 +00:00
|
|
|
return isNoAlias(Location(V1, V1Size), Location(V2, V2Size));
|
2009-11-23 16:38:54 +00:00
|
|
|
}
|
|
|
|
|
2010-09-14 21:25:10 +00:00
|
|
|
/// pointsToConstantMemory - If the specified memory location is known to be
|
|
|
|
/// constant, return true. This allows disambiguation of store
|
2004-01-30 22:15:41 +00:00
|
|
|
/// instructions from constant pointers.
|
|
|
|
///
|
2010-09-14 21:25:10 +00:00
|
|
|
virtual bool pointsToConstantMemory(const Location &Loc);
|
|
|
|
|
|
|
|
/// pointsToConstantMemory - A convenient wrapper.
|
|
|
|
bool pointsToConstantMemory(const Value *P) {
|
|
|
|
return pointsToConstantMemory(Location(P));
|
|
|
|
}
|
2003-06-29 00:23:11 +00:00
|
|
|
|
2004-12-15 07:21:39 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
/// Simple mod/ref information...
|
|
|
|
///
|
|
|
|
|
|
|
|
/// ModRefResult - Represent the result of a mod/ref query. Mod and Ref are
|
|
|
|
/// bits which may be or'd together.
|
|
|
|
///
|
|
|
|
enum ModRefResult { NoModRef = 0, Ref = 1, Mod = 2, ModRef = 3 };
|
2005-04-21 20:19:05 +00:00
|
|
|
|
|
|
|
|
2004-12-15 07:21:39 +00:00
|
|
|
/// 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.
|
|
|
|
enum ModRefBehavior {
|
|
|
|
// DoesNotAccessMemory - This function does not perform any non-local loads
|
|
|
|
// or stores to memory.
|
|
|
|
//
|
|
|
|
// This property corresponds to the GCC 'const' attribute.
|
|
|
|
DoesNotAccessMemory,
|
2005-04-21 20:19:05 +00:00
|
|
|
|
2009-02-13 17:36:13 +00:00
|
|
|
// AccessesArguments - This function accesses function arguments in well
|
|
|
|
// known (possibly volatile) ways, but does not access any other memory.
|
2004-12-15 07:21:39 +00:00
|
|
|
AccessesArguments,
|
2005-04-21 20:19:05 +00:00
|
|
|
|
2004-12-15 07:21:39 +00:00
|
|
|
// AccessesArgumentsAndGlobals - This function has accesses function
|
2009-02-13 17:36:13 +00:00
|
|
|
// arguments and global variables well known (possibly volatile) ways, but
|
2004-12-15 07:21:39 +00:00
|
|
|
// does not access any other memory.
|
|
|
|
AccessesArgumentsAndGlobals,
|
2005-04-21 20:19:05 +00:00
|
|
|
|
2004-12-15 07:21:39 +00:00
|
|
|
// OnlyReadsMemory - This function does not perform any non-local stores or
|
|
|
|
// volatile loads, but may read from any memory location.
|
|
|
|
//
|
|
|
|
// This property corresponds to the GCC 'pure' attribute.
|
|
|
|
OnlyReadsMemory,
|
2005-04-21 20:19:05 +00:00
|
|
|
|
2004-12-15 07:21:39 +00:00
|
|
|
// UnknownModRefBehavior - This indicates that the function could not be
|
|
|
|
// classified into one of the behaviors above.
|
|
|
|
UnknownModRefBehavior
|
|
|
|
};
|
2005-04-21 20:19:05 +00:00
|
|
|
|
2007-12-01 07:51:45 +00:00
|
|
|
/// getModRefBehavior - Return the behavior when calling the given call site.
|
2010-08-03 23:08:10 +00:00
|
|
|
virtual ModRefBehavior getModRefBehavior(ImmutableCallSite CS);
|
2007-12-01 07:51:45 +00:00
|
|
|
|
|
|
|
/// getModRefBehavior - Return the behavior when calling the given function.
|
|
|
|
/// For use when the call site is not known.
|
2010-08-03 23:08:10 +00:00
|
|
|
virtual ModRefBehavior getModRefBehavior(const Function *F);
|
2007-12-01 07:51:45 +00:00
|
|
|
|
2010-08-03 21:48:53 +00:00
|
|
|
/// getIntrinsicModRefBehavior - Return the modref behavior of the intrinsic
|
2010-08-06 02:04:07 +00:00
|
|
|
/// with the given id. Most clients won't need this, because the regular
|
|
|
|
/// getModRefBehavior incorporates this information.
|
2010-08-03 21:48:53 +00:00
|
|
|
static ModRefBehavior getIntrinsicModRefBehavior(unsigned iid);
|
2010-01-06 08:45:52 +00:00
|
|
|
|
2007-12-01 07:51:45 +00:00
|
|
|
/// 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.
|
2004-03-15 01:58:54 +00:00
|
|
|
///
|
2007-12-01 07:51:45 +00:00
|
|
|
/// 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').
|
2004-03-15 01:58:54 +00:00
|
|
|
///
|
|
|
|
/// This property corresponds to the GCC 'const' attribute.
|
|
|
|
///
|
2010-08-03 21:48:53 +00:00
|
|
|
bool doesNotAccessMemory(ImmutableCallSite CS) {
|
2008-05-30 22:47:19 +00:00
|
|
|
return getModRefBehavior(CS) == DoesNotAccessMemory;
|
2007-12-01 07:51:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// doesNotAccessMemory - If the specified function is known to never read or
|
|
|
|
/// write memory, return true. For use when the call site is not known.
|
|
|
|
///
|
2010-08-03 21:48:53 +00:00
|
|
|
bool doesNotAccessMemory(const Function *F) {
|
2007-12-01 07:51:45 +00:00
|
|
|
return getModRefBehavior(F) == DoesNotAccessMemory;
|
2004-12-15 07:21:39 +00:00
|
|
|
}
|
2004-03-15 01:58:54 +00:00
|
|
|
|
2007-12-01 07:51:45 +00:00
|
|
|
/// 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.
|
2004-03-15 01:58:54 +00:00
|
|
|
///
|
|
|
|
/// 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.
|
|
|
|
///
|
2010-08-03 21:48:53 +00:00
|
|
|
bool onlyReadsMemory(ImmutableCallSite CS) {
|
2008-05-30 22:47:19 +00:00
|
|
|
ModRefBehavior MRB = getModRefBehavior(CS);
|
2007-12-01 07:51:45 +00:00
|
|
|
return MRB == DoesNotAccessMemory || MRB == OnlyReadsMemory;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 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.
|
|
|
|
///
|
2010-08-03 21:48:53 +00:00
|
|
|
bool onlyReadsMemory(const Function *F) {
|
2007-12-01 07:51:45 +00:00
|
|
|
ModRefBehavior MRB = getModRefBehavior(F);
|
2005-03-23 23:27:34 +00:00
|
|
|
return MRB == DoesNotAccessMemory || MRB == OnlyReadsMemory;
|
2004-12-15 07:21:39 +00:00
|
|
|
}
|
2002-08-22 18:25:20 +00:00
|
|
|
|
2003-02-26 19:24:47 +00:00
|
|
|
|
|
|
|
/// getModRefInfo - Return information about whether or not an instruction may
|
2010-09-14 21:25:10 +00:00
|
|
|
/// read or write the specified memory location. An instruction
|
2003-02-26 19:24:47 +00:00
|
|
|
/// that doesn't read or write memory may be trivially LICM'd for example.
|
2010-09-07 20:37:47 +00:00
|
|
|
ModRefResult getModRefInfo(const Instruction *I,
|
2010-09-14 21:25:10 +00:00
|
|
|
const Location &Loc) {
|
2010-09-07 20:37:47 +00:00
|
|
|
switch (I->getOpcode()) {
|
2010-09-14 21:25:10 +00:00
|
|
|
case Instruction::VAArg: return getModRefInfo((const VAArgInst*)I, Loc);
|
|
|
|
case Instruction::Load: return getModRefInfo((const LoadInst*)I, Loc);
|
|
|
|
case Instruction::Store: return getModRefInfo((const StoreInst*)I, Loc);
|
|
|
|
case Instruction::Call: return getModRefInfo((const CallInst*)I, Loc);
|
|
|
|
case Instruction::Invoke: return getModRefInfo((const InvokeInst*)I,Loc);
|
2010-09-07 20:37:47 +00:00
|
|
|
default: return NoModRef;
|
|
|
|
}
|
|
|
|
}
|
2003-02-26 19:24:47 +00:00
|
|
|
|
2010-09-14 21:25:10 +00:00
|
|
|
/// getModRefInfo - A convenience wrapper.
|
|
|
|
ModRefResult getModRefInfo(const Instruction *I,
|
|
|
|
const Value *P, unsigned Size) {
|
|
|
|
return getModRefInfo(I, Location(P, Size));
|
|
|
|
}
|
|
|
|
|
2003-02-26 19:24:47 +00:00
|
|
|
/// getModRefInfo (for call sites) - Return whether information about whether
|
2010-09-14 21:25:10 +00:00
|
|
|
/// a particular call site modifies or reads the specified memory location.
|
2010-08-03 21:48:53 +00:00
|
|
|
virtual ModRefResult getModRefInfo(ImmutableCallSite CS,
|
2010-09-14 21:25:10 +00:00
|
|
|
const Location &Loc);
|
|
|
|
|
|
|
|
/// getModRefInfo (for call sites) - A convenience wrapper.
|
|
|
|
ModRefResult getModRefInfo(ImmutableCallSite CS,
|
|
|
|
const Value *P, unsigned Size) {
|
|
|
|
return getModRefInfo(CS, Location(P, Size));
|
|
|
|
}
|
2003-02-26 19:24:47 +00:00
|
|
|
|
2010-09-07 20:37:47 +00:00
|
|
|
/// getModRefInfo (for calls) - Return whether information about whether
|
2010-09-14 21:25:10 +00:00
|
|
|
/// a particular call modifies or reads the specified memory location.
|
|
|
|
ModRefResult getModRefInfo(const CallInst *C, const Location &Loc) {
|
|
|
|
return getModRefInfo(ImmutableCallSite(C), Loc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getModRefInfo (for calls) - A convenience wrapper.
|
2010-08-03 21:48:53 +00:00
|
|
|
ModRefResult getModRefInfo(const CallInst *C, const Value *P, unsigned Size) {
|
2010-09-14 21:25:10 +00:00
|
|
|
return getModRefInfo(C, Location(P, Size));
|
2003-02-26 19:24:47 +00:00
|
|
|
}
|
2010-09-07 20:37:47 +00:00
|
|
|
|
|
|
|
/// getModRefInfo (for invokes) - Return whether information about whether
|
2010-09-14 21:25:10 +00:00
|
|
|
/// a particular invoke modifies or reads the specified memory location.
|
|
|
|
ModRefResult getModRefInfo(const InvokeInst *I,
|
|
|
|
const Location &Loc) {
|
|
|
|
return getModRefInfo(ImmutableCallSite(I), Loc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getModRefInfo (for invokes) - A convenience wrapper.
|
2010-08-03 21:48:53 +00:00
|
|
|
ModRefResult getModRefInfo(const InvokeInst *I,
|
|
|
|
const Value *P, unsigned Size) {
|
2010-09-14 21:25:10 +00:00
|
|
|
return getModRefInfo(I, Location(P, Size));
|
2003-02-26 19:24:47 +00:00
|
|
|
}
|
2010-09-07 20:37:47 +00:00
|
|
|
|
|
|
|
/// getModRefInfo (for loads) - Return whether information about whether
|
2010-09-14 21:25:10 +00:00
|
|
|
/// a particular load modifies or reads the specified memory location.
|
|
|
|
ModRefResult getModRefInfo(const LoadInst *L, const Location &Loc);
|
|
|
|
|
|
|
|
/// getModRefInfo (for loads) - A convenience wrapper.
|
|
|
|
ModRefResult getModRefInfo(const LoadInst *L, const Value *P, unsigned Size) {
|
|
|
|
return getModRefInfo(L, Location(P, Size));
|
|
|
|
}
|
2010-09-07 20:37:47 +00:00
|
|
|
|
|
|
|
/// getModRefInfo (for stores) - Return whether information about whether
|
2010-09-14 21:25:10 +00:00
|
|
|
/// a particular store modifies or reads the specified memory location.
|
|
|
|
ModRefResult getModRefInfo(const StoreInst *S, const Location &Loc);
|
|
|
|
|
|
|
|
/// getModRefInfo (for stores) - A convenience wrapper.
|
|
|
|
ModRefResult getModRefInfo(const StoreInst *S, const Value *P, unsigned Size) {
|
|
|
|
return getModRefInfo(S, Location(P, Size));
|
|
|
|
}
|
2010-09-07 20:37:47 +00:00
|
|
|
|
|
|
|
/// getModRefInfo (for va_args) - Return whether information about whether
|
2010-09-14 21:25:10 +00:00
|
|
|
/// a particular va_arg modifies or reads the specified memory location.
|
|
|
|
ModRefResult getModRefInfo(const VAArgInst* I, const Location &Loc);
|
|
|
|
|
|
|
|
/// getModRefInfo (for va_args) - A convenience wrapper.
|
|
|
|
ModRefResult getModRefInfo(const VAArgInst* I, const Value* P, unsigned Size) {
|
|
|
|
return getModRefInfo(I, Location(P, Size));
|
|
|
|
}
|
2010-09-07 20:37:47 +00:00
|
|
|
|
|
|
|
/// getModRefInfo - Return information about whether two call sites may refer
|
|
|
|
/// to the same set of memory locations. See
|
|
|
|
/// http://llvm.org/docs/AliasAnalysis.html#ModRefInfo
|
|
|
|
/// for details.
|
|
|
|
virtual ModRefResult getModRefInfo(ImmutableCallSite CS1,
|
|
|
|
ImmutableCallSite CS2);
|
2002-08-22 18:25:20 +00:00
|
|
|
|
2004-05-23 21:12:38 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
/// Higher level methods for querying mod/ref information.
|
|
|
|
///
|
|
|
|
|
2002-08-22 21:22:25 +00:00
|
|
|
/// canBasicBlockModify - Return true if it is possible for execution of the
|
|
|
|
/// specified basic block to modify the value pointed to by Ptr.
|
2010-09-14 21:25:10 +00:00
|
|
|
bool canBasicBlockModify(const BasicBlock &BB, const Location &Loc);
|
|
|
|
|
|
|
|
/// canBasicBlockModify - A convenience wrapper.
|
|
|
|
bool canBasicBlockModify(const BasicBlock &BB, const Value *P, unsigned Size){
|
|
|
|
return canBasicBlockModify(BB, Location(P, Size));
|
|
|
|
}
|
2002-08-22 18:25:20 +00:00
|
|
|
|
2002-08-22 21:22:25 +00:00
|
|
|
/// 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.
|
2002-08-22 18:25:20 +00:00
|
|
|
bool canInstructionRangeModify(const Instruction &I1, const Instruction &I2,
|
2010-09-14 21:25:10 +00:00
|
|
|
const Location &Loc);
|
|
|
|
|
|
|
|
/// canInstructionRangeModify - A convenience wrapper.
|
|
|
|
bool canInstructionRangeModify(const Instruction &I1, const Instruction &I2,
|
|
|
|
const Value *Ptr, unsigned Size) {
|
|
|
|
return canInstructionRangeModify(I1, I2, Location(Ptr, Size));
|
|
|
|
}
|
2004-05-23 21:12:38 +00:00
|
|
|
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
/// Methods that clients should call when they transform the program to allow
|
|
|
|
/// alias analyses to update their internal data structures. Note that these
|
|
|
|
/// methods may be called on any instruction, regardless of whether or not
|
|
|
|
/// they have pointer-analysis implications.
|
|
|
|
///
|
|
|
|
|
|
|
|
/// 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.
|
|
|
|
///
|
|
|
|
virtual void deleteValue(Value *V);
|
|
|
|
|
|
|
|
/// 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.
|
|
|
|
///
|
|
|
|
virtual void copyValue(Value *From, Value *To);
|
|
|
|
|
|
|
|
/// replaceWithNewValue - This method is the obvious combination of the two
|
|
|
|
/// above, and it provided as a helper to simplify client code.
|
|
|
|
///
|
|
|
|
void replaceWithNewValue(Value *Old, Value *New) {
|
|
|
|
copyValue(Old, New);
|
|
|
|
deleteValue(Old);
|
|
|
|
}
|
2002-08-22 18:25:20 +00:00
|
|
|
};
|
|
|
|
|
2009-02-03 01:28:32 +00:00
|
|
|
/// isNoAliasCall - Return true if this pointer is returned by a noalias
|
|
|
|
/// function.
|
|
|
|
bool isNoAliasCall(const Value *V);
|
|
|
|
|
2009-01-30 02:49:14 +00:00
|
|
|
/// isIdentifiedObject - Return true if this pointer refers to a distinct and
|
2009-02-03 01:28:32 +00:00
|
|
|
/// identifiable object. This returns true for:
|
2009-08-27 17:52:56 +00:00
|
|
|
/// Global Variables and Functions (but not Global Aliases)
|
2009-02-03 01:28:32 +00:00
|
|
|
/// Allocas and Mallocs
|
2010-07-07 14:27:09 +00:00
|
|
|
/// ByVal and NoAlias Arguments
|
|
|
|
/// NoAlias returns
|
2009-01-30 02:49:14 +00:00
|
|
|
///
|
2010-07-07 14:27:09 +00:00
|
|
|
bool isIdentifiedObject(const Value *V);
|
2009-01-30 02:49:14 +00:00
|
|
|
|
2006-06-07 22:00:26 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2003-12-11 05:05:02 +00:00
|
|
|
// Because of the way .a files work, we must force the BasicAA implementation to
|
|
|
|
// be pulled in if the AliasAnalysis header is included. Otherwise we run
|
|
|
|
// the risk of AliasAnalysis being used, but the default implementation not
|
|
|
|
// being linked into the tool that uses it.
|
2006-06-07 22:00:26 +00:00
|
|
|
FORCE_DEFINING_FILE_TO_BE_LINKED(AliasAnalysis)
|
|
|
|
FORCE_DEFINING_FILE_TO_BE_LINKED(BasicAliasAnalysis)
|
2003-11-11 22:41:34 +00:00
|
|
|
|
2002-08-22 18:25:20 +00:00
|
|
|
#endif
|