1 //===------------- EscapeAnalysis.h - Pointer escape analysis -------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the interface for the pointer escape analysis.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_ANALYSIS_ESCAPEANALYSIS_H
15 #define LLVM_ANALYSIS_ESCAPEANALYSIS_H
17 #include "llvm/Pass.h"
18 #include "llvm/Instructions.h"
19 #include "llvm/Analysis/AliasAnalysis.h"
20 #include "llvm/Target/TargetData.h"
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 {
30 std::set<Instruction*> EscapePoints;
33 static char ID; // Class identification, replacement for typeinfo
35 EscapeAnalysis() : FunctionPass(intptr_t(&ID)) {}
37 bool runOnFunction(Function &F);
39 void releaseMemory() {
43 void getAnalysisUsage(AnalysisUsage &AU) const {
44 AU.addRequiredTransitive<TargetData>();
45 AU.addRequiredTransitive<AliasAnalysis>();
49 //===---------------------------------------------------------------------
52 /// escapes - returns true if the value, which must have a pointer type,
54 bool escapes(Value* A);
57 } // end llvm namespace