aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Pass.h14
-rw-r--r--include/llvm/PassAnalysisSupport.h24
2 files changed, 27 insertions, 11 deletions
diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h
index 0ff286a50d..edd7e738c8 100644
--- a/include/llvm/Pass.h
+++ b/include/llvm/Pass.h
@@ -114,9 +114,15 @@ protected:
// getAnalysisUsage function.
//
template<typename AnalysisType>
- AnalysisType &getAnalysis(AnalysisID AID = AnalysisType::ID) {
+ AnalysisType &getAnalysis() {
assert(Resolver && "Pass not resident in a PassManager object!");
- return *(AnalysisType*)Resolver->getAnalysis(AID);
+ return *(AnalysisType*)Resolver->getAnalysis(AnalysisType::ID);
+ }
+
+ template<typename AnalysisType>
+ AnalysisType &getAnalysisID(const PassInfo *PI) {
+ assert(Resolver && "Pass not resident in a PassManager object!");
+ return *(AnalysisType*)Resolver->getAnalysis(PI);
}
// getAnalysisToUpdate<AnalysisType>() - This function is used by subclasses
@@ -126,9 +132,9 @@ protected:
// provide the capability to update an analysis that exists.
//
template<typename AnalysisType>
- AnalysisType *getAnalysisToUpdate(AnalysisID AID = AnalysisType::ID) {
+ AnalysisType *getAnalysisToUpdate() {
assert(Resolver && "Pass not resident in a PassManager object!");
- return (AnalysisType*)Resolver->getAnalysisToUpdate(AID);
+ return (AnalysisType*)Resolver->getAnalysisToUpdate(AnalysisType::ID);
}
diff --git a/include/llvm/PassAnalysisSupport.h b/include/llvm/PassAnalysisSupport.h
index c08b883024..f04b4a6b46 100644
--- a/include/llvm/PassAnalysisSupport.h
+++ b/include/llvm/PassAnalysisSupport.h
@@ -30,28 +30,38 @@ class AnalysisUsage {
public:
AnalysisUsage() : PreservesAll(false) {}
- // addRequires - Add the specified ID to the required set of the usage info
+ // addRequired - Add the specified ID to the required set of the usage info
// for a pass.
//
- AnalysisUsage &addRequired(AnalysisID ID) {
+ AnalysisUsage &addRequiredID(AnalysisID ID) {
Required.push_back(ID);
return *this;
}
+ template<class PassClass>
+ AnalysisUsage &addRequired() {
+ Required.push_back(PassClass::ID);
+ return *this;
+ }
- // addPreserves - Add the specified ID to the set of analyses preserved by
+ // addPreserved - Add the specified ID to the set of analyses preserved by
// this pass
//
- AnalysisUsage &addPreserved(AnalysisID ID) {
+ AnalysisUsage &addPreservedID(AnalysisID ID) {
Preserved.push_back(ID);
return *this;
}
- // PreservesAll - Set by analyses that do not transform their input at all
+ template<class PassClass>
+ AnalysisUsage &addPreserved() {
+ Preserved.push_back(PassClass::ID);
+ return *this;
+ }
+
+ // setPreservesAll - Set by analyses that do not transform their input at all
void setPreservesAll() { PreservesAll = true; }
bool preservesAll() const { return PreservesAll; }
- // preservesCFG - This function should be called to by the pass, iff they do
- // not:
+ // preservesCFG - This function should be called by the pass, iff they do not:
//
// 1. Add or remove basic blocks from the function
// 2. Modify terminator instructions in any way.