From: Chandler Carruth Date: Fri, 14 Aug 2015 02:50:34 +0000 (+0000) Subject: [PM/AA] Hoist the value handle definition for CFLAA into the header to X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=e115abc777851b4615de8c4232698a691b9e7b2c [PM/AA] Hoist the value handle definition for CFLAA into the header to satisfy libc++'s std::forward_list which requires the value type to be complete. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245011 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Analysis/CFLAliasAnalysis.h b/include/llvm/Analysis/CFLAliasAnalysis.h index 4a151d5a965..07e0bdcd4f0 100644 --- a/include/llvm/Analysis/CFLAliasAnalysis.h +++ b/include/llvm/Analysis/CFLAliasAnalysis.h @@ -20,6 +20,7 @@ #include "llvm/ADT/Optional.h" #include "llvm/IR/Function.h" #include "llvm/IR/Module.h" +#include "llvm/IR/ValueHandle.h" #include "llvm/Pass.h" #include @@ -27,7 +28,27 @@ namespace llvm { class CFLAliasAnalysis : public ImmutablePass, public AliasAnalysis { struct FunctionInfo; - struct FunctionHandle; + + struct FunctionHandle final : public CallbackVH { + FunctionHandle(Function *Fn, CFLAliasAnalysis *CFLAA) + : CallbackVH(Fn), CFLAA(CFLAA) { + assert(Fn != nullptr); + assert(CFLAA != nullptr); + } + + void deleted() override { removeSelfFromCache(); } + void allUsesReplacedWith(Value *) override { removeSelfFromCache(); } + + private: + CFLAliasAnalysis *CFLAA; + + void removeSelfFromCache() { + assert(CFLAA != nullptr); + auto *Val = getValPtr(); + CFLAA->evict(cast(Val)); + setValPtr(nullptr); + } + }; /// \brief Cached mapping of Functions to their StratifiedSets. /// If a function's sets are currently being built, it is marked diff --git a/lib/Analysis/CFLAliasAnalysis.cpp b/lib/Analysis/CFLAliasAnalysis.cpp index 958ba95b3e6..ea624aee4fb 100644 --- a/lib/Analysis/CFLAliasAnalysis.cpp +++ b/lib/Analysis/CFLAliasAnalysis.cpp @@ -38,7 +38,6 @@ #include "llvm/IR/Function.h" #include "llvm/IR/InstVisitor.h" #include "llvm/IR/Instructions.h" -#include "llvm/IR/ValueHandle.h" #include "llvm/Pass.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Compiler.h" @@ -74,27 +73,6 @@ struct CFLAliasAnalysis::FunctionInfo { : Sets(std::move(S)), ReturnedValues(std::move(RV)) {} }; -struct CFLAliasAnalysis::FunctionHandle final : public CallbackVH { - FunctionHandle(Function *Fn, CFLAliasAnalysis *CFLAA) - : CallbackVH(Fn), CFLAA(CFLAA) { - assert(Fn != nullptr); - assert(CFLAA != nullptr); - } - - void deleted() override { removeSelfFromCache(); } - void allUsesReplacedWith(Value *) override { removeSelfFromCache(); } - -private: - CFLAliasAnalysis *CFLAA; - - void removeSelfFromCache() { - assert(CFLAA != nullptr); - auto *Val = getValPtr(); - CFLAA->evict(cast(Val)); - setValPtr(nullptr); - } -}; - CFLAliasAnalysis::CFLAliasAnalysis() : ImmutablePass(ID) { initializeCFLAliasAnalysisPass(*PassRegistry::getPassRegistry()); }