2008-10-10 08:36:25 +00:00
|
|
|
//===------------- 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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2008-10-10 08:53:07 +00:00
|
|
|
#ifndef LLVM_ANALYSIS_ESCAPEANALYSIS_H
|
|
|
|
#define LLVM_ANALYSIS_ESCAPEANALYSIS_H
|
2008-10-10 08:36:25 +00:00
|
|
|
|
|
|
|
#include "llvm/Pass.h"
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2009-01-05 17:59:02 +00:00
|
|
|
class Instruction;
|
|
|
|
class Value;
|
|
|
|
|
2008-10-10 08:36:25 +00:00
|
|
|
/// 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();
|
|
|
|
}
|
|
|
|
|
2009-01-05 17:59:02 +00:00
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const;
|
2008-10-10 08:36:25 +00:00
|
|
|
|
|
|
|
//===---------------------------------------------------------------------
|
|
|
|
// Client API
|
|
|
|
|
2008-10-12 07:33:29 +00:00
|
|
|
/// escapes - returns true if the value, which must have a pointer type,
|
|
|
|
/// can escape.
|
|
|
|
bool escapes(Value* A);
|
2008-10-10 08:36:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end llvm namespace
|
|
|
|
|
|
|
|
#endif
|