diff options
Diffstat (limited to 'include/llvm/Analysis/EscapeAnalysis.h')
-rw-r--r-- | include/llvm/Analysis/EscapeAnalysis.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/include/llvm/Analysis/EscapeAnalysis.h b/include/llvm/Analysis/EscapeAnalysis.h new file mode 100644 index 0000000..085028d --- /dev/null +++ b/include/llvm/Analysis/EscapeAnalysis.h @@ -0,0 +1,59 @@ +//===------------- EscapeAnalysis.h - Pointer escape analysis -------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the interface for the pointer escape analysis. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ANALYSIS_LOOPVR_H +#define LLVM_ANALYSIS_LOOPVR_H + +#include "llvm/Pass.h" +#include "llvm/Instructions.h" +#include "llvm/Analysis/AliasAnalysis.h" +#include "llvm/Target/TargetData.h" +#include <set> +#include <vector> + +namespace llvm { + +/// EscapeAnalysis - This class determines whether an allocation (a MallocInst +/// or an AllocaInst) can escape from the current function. It performs some +/// precomputation, with the rest of the work happening on-demand. +class EscapeAnalysis : public FunctionPass { +private: + std::set<Instruction*> EscapePoints; + +public: + static char ID; // Class identification, replacement for typeinfo + + EscapeAnalysis() : FunctionPass(intptr_t(&ID)) {} + + bool runOnFunction(Function &F); + + void releaseMemory() { + EscapePoints.clear(); + } + + void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequiredTransitive<TargetData>(); + AU.addRequiredTransitive<AliasAnalysis>(); + AU.setPreservesAll(); + } + + //===--------------------------------------------------------------------- + // Client API + + /// escapes - returns true if the AllocationInst can escape. + bool escapes(AllocationInst* A); +}; + +} // end llvm namespace + +#endif |