[llvm] r203775 - [PM] Stop playing fast and loose with rebinding of references. However
Chandler Carruth
chandlerc at gmail.com
Thu Mar 13 02:50:31 PDT 2014
Author: chandlerc
Date: Thu Mar 13 04:50:31 2014
New Revision: 203775
URL: http://llvm.org/viewvc/llvm-project?rev=203775&view=rev
Log:
[PM] Stop playing fast and loose with rebinding of references. However
convenient it is to imagine a world where this works, that is not C++ as
was pointed out in review. The standard even goes to some lengths to
preclude any attempt at this, for better or worse. Maybe better. =]
Modified:
llvm/trunk/include/llvm/IR/PassManager.h
llvm/trunk/lib/IR/PassManager.cpp
Modified: llvm/trunk/include/llvm/IR/PassManager.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/PassManager.h?rev=203775&r1=203774&r2=203775&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/PassManager.h (original)
+++ llvm/trunk/include/llvm/IR/PassManager.h Thu Mar 13 04:50:31 2014
@@ -799,14 +799,14 @@ public:
static void *ID() { return (void *)&PassID; }
explicit FunctionAnalysisManagerModuleProxy(FunctionAnalysisManager &FAM)
- : FAM(FAM) {}
+ : FAM(&FAM) {}
// We have to explicitly define all the special member functions because MSVC
// refuses to generate them.
FunctionAnalysisManagerModuleProxy(
const FunctionAnalysisManagerModuleProxy &Arg)
: FAM(Arg.FAM) {}
FunctionAnalysisManagerModuleProxy(FunctionAnalysisManagerModuleProxy &&Arg)
- : FAM(Arg.FAM) {}
+ : FAM(std::move(Arg.FAM)) {}
FunctionAnalysisManagerModuleProxy &
operator=(FunctionAnalysisManagerModuleProxy RHS) {
std::swap(*this, RHS);
@@ -827,7 +827,7 @@ public:
private:
static char PassID;
- FunctionAnalysisManager &FAM;
+ FunctionAnalysisManager *FAM;
};
/// \brief The result proxy object for the
@@ -836,11 +836,11 @@ private:
/// See its documentation for more information.
class FunctionAnalysisManagerModuleProxy::Result {
public:
- explicit Result(FunctionAnalysisManager &FAM) : FAM(FAM) {}
+ explicit Result(FunctionAnalysisManager &FAM) : FAM(&FAM) {}
// We have to explicitly define all the special member functions because MSVC
// refuses to generate them.
Result(const Result &Arg) : FAM(Arg.FAM) {}
- Result(Result &&Arg) : FAM(Arg.FAM) {}
+ Result(Result &&Arg) : FAM(std::move(Arg.FAM)) {}
Result &operator=(Result RHS) {
std::swap(*this, RHS);
return *this;
@@ -848,7 +848,7 @@ public:
~Result();
/// \brief Accessor for the \c FunctionAnalysisManager.
- FunctionAnalysisManager &getManager() { return FAM; }
+ FunctionAnalysisManager &getManager() { return *FAM; }
/// \brief Handler for invalidation of the module.
///
@@ -863,7 +863,7 @@ public:
bool invalidate(Module *M, const PreservedAnalyses &PA);
private:
- FunctionAnalysisManager &FAM;
+ FunctionAnalysisManager *FAM;
};
/// \brief A function analysis which acts as a proxy for a module analysis
@@ -883,36 +883,36 @@ public:
/// \brief Result proxy object for \c ModuleAnalysisManagerFunctionProxy.
class Result {
public:
- explicit Result(const ModuleAnalysisManager &MAM) : MAM(MAM) {}
+ explicit Result(const ModuleAnalysisManager &MAM) : MAM(&MAM) {}
// We have to explicitly define all the special member functions because
// MSVC refuses to generate them.
Result(const Result &Arg) : MAM(Arg.MAM) {}
- Result(Result &&Arg) : MAM(Arg.MAM) {}
+ Result(Result &&Arg) : MAM(std::move(Arg.MAM)) {}
Result &operator=(Result RHS) {
std::swap(*this, RHS);
return *this;
}
- const ModuleAnalysisManager &getManager() const { return MAM; }
+ const ModuleAnalysisManager &getManager() const { return *MAM; }
/// \brief Handle invalidation by ignoring it, this pass is immutable.
bool invalidate(Function *) { return false; }
private:
- const ModuleAnalysisManager &MAM;
+ const ModuleAnalysisManager *MAM;
};
static void *ID() { return (void *)&PassID; }
ModuleAnalysisManagerFunctionProxy(const ModuleAnalysisManager &MAM)
- : MAM(MAM) {}
+ : MAM(&MAM) {}
// We have to explicitly define all the special member functions because MSVC
// refuses to generate them.
ModuleAnalysisManagerFunctionProxy(
const ModuleAnalysisManagerFunctionProxy &Arg)
: MAM(Arg.MAM) {}
ModuleAnalysisManagerFunctionProxy(ModuleAnalysisManagerFunctionProxy &&Arg)
- : MAM(Arg.MAM) {}
+ : MAM(std::move(Arg.MAM)) {}
ModuleAnalysisManagerFunctionProxy &
operator=(ModuleAnalysisManagerFunctionProxy RHS) {
std::swap(*this, RHS);
@@ -922,12 +922,12 @@ public:
/// \brief Run the analysis pass and create our proxy result object.
/// Nothing to see here, it just forwards the \c MAM reference into the
/// result.
- Result run(Function *) { return Result(MAM); }
+ Result run(Function *) { return Result(*MAM); }
private:
static char PassID;
- const ModuleAnalysisManager &MAM;
+ const ModuleAnalysisManager *MAM;
};
/// \brief Trivial adaptor that maps from a module to its functions.
Modified: llvm/trunk/lib/IR/PassManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/PassManager.cpp?rev=203775&r1=203774&r2=203775&view=diff
==============================================================================
--- llvm/trunk/lib/IR/PassManager.cpp (original)
+++ llvm/trunk/lib/IR/PassManager.cpp Thu Mar 13 04:50:31 2014
@@ -171,14 +171,14 @@ char FunctionAnalysisManagerModuleProxy:
FunctionAnalysisManagerModuleProxy::Result
FunctionAnalysisManagerModuleProxy::run(Module *M) {
- assert(FAM.empty() && "Function analyses ran prior to the module proxy!");
- return Result(FAM);
+ assert(FAM->empty() && "Function analyses ran prior to the module proxy!");
+ return Result(*FAM);
}
FunctionAnalysisManagerModuleProxy::Result::~Result() {
// Clear out the analysis manager if we're being destroyed -- it means we
// didn't even see an invalidate call when we got invalidated.
- FAM.clear();
+ FAM->clear();
}
bool FunctionAnalysisManagerModuleProxy::Result::invalidate(
@@ -188,7 +188,7 @@ bool FunctionAnalysisManagerModuleProxy:
// objects in the cache making it impossible to incrementally preserve them.
// Just clear the entire manager.
if (!PA.preserved(ID()))
- FAM.clear();
+ FAM->clear();
// Return false to indicate that this result is still a valid proxy.
return false;
More information about the llvm-commits
mailing list