1 //===- llvm/Analysis/AliasAnalysis.h - Alias Analysis Interface -*- C++ -*-===//
3 // This file defines the generic AliasAnalysis interface, which is used as the
4 // common interface used by all clients of alias analysis information, and
5 // implemented by all alias analysis implementations.
7 // Implementations of this interface must implement the various virtual methods,
8 // which automatically provides functionality for the entire suite of client
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_ANALYSIS_ALIAS_ANALYSIS_H
14 #define LLVM_ANALYSIS_ALIAS_ANALYSIS_H
22 struct AliasAnalysis {
24 /// Alias analysis result - Either we know for sure that it does not alias, we
25 /// know for sure it must alias, or we don't know anything: The two pointers
26 /// _might_ alias. This enum is designed so you can do things like:
27 /// if (AA.alias(P1, P2)) { ... }
28 /// to check to see if two pointers might alias.
30 enum Result { NoAlias = 0, MayAlias = 1, MustAlias = 2 };
32 /// alias - The main low level interface to the alias analysis implementation.
33 /// Returns a Result indicating whether the two pointers are aliased to each
34 /// other. This is the interface that must be implemented by specific alias
35 /// analysis implementations.
37 virtual Result alias(const Value *V1, const Value *V2) const = 0;
39 /// canCallModify - Return a Result that indicates whether the specified
40 /// function call can modify the memory location pointed to by Ptr.
42 virtual Result canCallModify(const CallInst &CI, const Value *Ptr) const = 0;
44 /// canInvokeModify - Return a Result that indicates whether the specified
45 /// function invoke can modify the memory location pointed to by Ptr.
47 virtual Result canInvokeModify(const InvokeInst &I, const Value *Ptr) const=0;
49 /// canBasicBlockModify - Return true if it is possible for execution of the
50 /// specified basic block to modify the value pointed to by Ptr.
52 bool canBasicBlockModify(const BasicBlock &BB, const Value *Ptr) const;
54 /// canInstructionRangeModify - Return true if it is possible for the
55 /// execution of the specified instructions to modify the value pointed to by
56 /// Ptr. The instructions to consider are all of the instructions in the
57 /// range of [I1,I2] INCLUSIVE. I1 and I2 must be in the same basic block.
59 bool canInstructionRangeModify(const Instruction &I1, const Instruction &I2,
60 const Value *Ptr) const;
62 virtual ~AliasAnalysis(); // We want to be subclassed