Implement methods needed to print out call graph
[oota-llvm.git] / include / llvm / Analysis / AliasAnalysis.h
1 //===- llvm/Analysis/AliasAnalysis.h - Alias Analysis Interface -*- C++ -*-===//
2 //
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.
6 //
7 // Implementations of this interface must implement the various virtual methods,
8 // which automatically provides functionality for the entire suite of client
9 // APIs.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #ifndef LLVM_ANALYSIS_ALIAS_ANALYSIS_H
14 #define LLVM_ANALYSIS_ALIAS_ANALYSIS_H
15
16 class Value;
17 class CallInst;
18 class InvokeInst;
19 class BasicBlock;
20 class Instruction;
21
22 struct AliasAnalysis {
23
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.
29   ///
30   enum Result { NoAlias = 0, MayAlias = 1, MustAlias = 2 };
31
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.
36   ///
37   virtual Result alias(const Value *V1, const Value *V2) const = 0;
38
39   /// canCallModify - Return a Result that indicates whether the specified
40   /// function call can modify the memory location pointed to by Ptr.
41   ///
42   virtual Result canCallModify(const CallInst &CI, const Value *Ptr) const = 0;
43
44   /// canInvokeModify - Return a Result that indicates whether the specified
45   /// function invoke can modify the memory location pointed to by Ptr.
46   ///
47   virtual Result canInvokeModify(const InvokeInst &I, const Value *Ptr) const=0;
48
49   /// canBasicBlockModify - Return true if it is possible for execution of the
50   /// specified basic block to modify the value pointed to by Ptr.
51   ///
52   bool canBasicBlockModify(const BasicBlock &BB, const Value *Ptr) const;
53
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.
58   ///
59   bool canInstructionRangeModify(const Instruction &I1, const Instruction &I2,
60                                  const Value *Ptr) const;
61
62   virtual ~AliasAnalysis();  // We want to be subclassed
63 };
64
65 #endif