3f4da25310d70a21ce5857f42dad5786b21cc73d
[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 <set>
19
20 namespace llvm {
21
22 class Instruction;
23 class Value;
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
45   //===---------------------------------------------------------------------
46   // Client API
47
48   /// escapes - returns true if the value, which must have a pointer type,
49   /// can escape.
50   bool escapes(Value* A);
51 };
52
53 } // end llvm namespace
54
55 #endif