Trim #includes.
[oota-llvm.git] / include / llvm / Analysis / EscapeAnalysis.h
1 //===------------- EscapeAnalysis.h - Pointer escape analysis -------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the interface for the pointer escape analysis.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_ANALYSIS_ESCAPEANALYSIS_H
15 #define LLVM_ANALYSIS_ESCAPEANALYSIS_H
16
17 #include "llvm/Pass.h"
18 #include "llvm/Instructions.h"
19 #include "llvm/Analysis/AliasAnalysis.h"
20 #include "llvm/Target/TargetData.h"
21 #include <set>
22
23 namespace llvm {
24
25 /// EscapeAnalysis - This class determines whether an allocation (a MallocInst 
26 /// or an AllocaInst) can escape from the current function.  It performs some
27 /// precomputation, with the rest of the work happening on-demand.
28 class EscapeAnalysis : public FunctionPass {
29 private:
30   std::set<Instruction*> EscapePoints;
31
32 public:
33   static char ID; // Class identification, replacement for typeinfo
34
35   EscapeAnalysis() : FunctionPass(intptr_t(&ID)) {}
36
37   bool runOnFunction(Function &F);
38   
39   void releaseMemory() {
40     EscapePoints.clear();
41   }
42
43   void getAnalysisUsage(AnalysisUsage &AU) const {
44     AU.addRequiredTransitive<TargetData>();
45     AU.addRequiredTransitive<AliasAnalysis>();
46     AU.setPreservesAll();
47   }
48
49   //===---------------------------------------------------------------------
50   // Client API
51
52   /// escapes - returns true if the value, which must have a pointer type,
53   /// can escape.
54   bool escapes(Value* A);
55 };
56
57 } // end llvm namespace
58
59 #endif