#ifndef LLVM_PASS_ANALYSIS_SUPPORT_H
#define LLVM_PASS_ANALYSIS_SUPPORT_H
#ifndef LLVM_PASS_ANALYSIS_SUPPORT_H
#define LLVM_PASS_ANALYSIS_SUPPORT_H
#include "llvm/Pass.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Pass.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
//===----------------------------------------------------------------------===//
// AnalysisUsage - Represent the analysis usage information of a pass. This
// tracks analyses that the pass REQUIRES (must be available when the pass
//===----------------------------------------------------------------------===//
// AnalysisUsage - Represent the analysis usage information of a pass. This
// tracks analyses that the pass REQUIRES (must be available when the pass
const PassInfo *PI = getClassPassInfo<AnalysisType>();
if (PI == 0) return 0;
const PassInfo *PI = getClassPassInfo<AnalysisType>();
if (PI == 0) return 0;
- return dynamic_cast<AnalysisType*>
- (Resolver->getAnalysisIfAvailable(PI, true));
+
+ Pass *ResultPass = Resolver->getAnalysisIfAvailable(PI, true);
+ if (ResultPass == 0) return 0;
+
+ // Because the AnalysisType may not be a subclass of pass (for
+ // AnalysisGroups), we use getAdjustedAnalysisPointer here to potentially
+ // adjust the return pointer (because the class may multiply inherit, once
+ // from pass, once from AnalysisType).
+ return (AnalysisType*)ResultPass->getAdjustedAnalysisPointer(PI);
}
/// getAnalysis<AnalysisType>() - This function is used by subclasses to get
}
/// getAnalysis<AnalysisType>() - This function is used by subclasses to get
///
template<typename AnalysisType>
AnalysisType &Pass::getAnalysis() const {
///
template<typename AnalysisType>
AnalysisType &Pass::getAnalysis() const {
- assert(Resolver &&"Pass has not been inserted into a PassManager object!");
-
+ assert(Resolver && "Pass has not been inserted into a PassManager object!");
return getAnalysisID<AnalysisType>(getClassPassInfo<AnalysisType>());
}
return getAnalysisID<AnalysisType>(getClassPassInfo<AnalysisType>());
}
"'required' by pass!");
// Because the AnalysisType may not be a subclass of pass (for
"'required' by pass!");
// Because the AnalysisType may not be a subclass of pass (for
- // AnalysisGroups), we must use dynamic_cast here to potentially adjust the
- // return pointer (because the class may multiply inherit, once from pass,
- // once from AnalysisType).
- //
- AnalysisType *Result = dynamic_cast<AnalysisType*>(ResultPass);
- assert(Result && "Pass does not implement interface required!");
- return *Result;
+ // AnalysisGroups), we use getAdjustedAnalysisPointer here to potentially
+ // adjust the return pointer (because the class may multiply inherit, once
+ // from pass, once from AnalysisType).
+ return *(AnalysisType*)ResultPass->getAdjustedAnalysisPointer(PI);
}
/// getAnalysis<AnalysisType>() - This function is used by subclasses to get
}
/// getAnalysis<AnalysisType>() - This function is used by subclasses to get
// should be a small number, we just do a linear search over a (dense)
// vector.
Pass *ResultPass = Resolver->findImplPass(this, PI, F);
// should be a small number, we just do a linear search over a (dense)
// vector.
Pass *ResultPass = Resolver->findImplPass(this, PI, F);
- assert (ResultPass && "Unable to find requested analysis info");
+ assert(ResultPass && "Unable to find requested analysis info");
// Because the AnalysisType may not be a subclass of pass (for
// Because the AnalysisType may not be a subclass of pass (for
- // AnalysisGroups), we must use dynamic_cast here to potentially adjust the
- // return pointer (because the class may multiply inherit, once from pass,
- // once from AnalysisType).
- //
- AnalysisType *Result = dynamic_cast<AnalysisType*>(ResultPass);
- assert(Result && "Pass does not implement interface required!");
- return *Result;
+ // AnalysisGroups), we use getAdjustedAnalysisPointer here to potentially
+ // adjust the return pointer (because the class may multiply inherit, once
+ // from pass, once from AnalysisType).
+ return *(AnalysisType*)ResultPass->getAdjustedAnalysisPointer(PI);
}
} // End llvm namespace
}
} // End llvm namespace