[llvm] r225131 - [PM] Split the AssumptionTracker immutable pass into two separate APIs:

Philip Reames listmail at philipreames.com
Mon Jan 5 10:22:56 PST 2015


On 01/04/2015 05:46 PM, Chandler Carruth wrote:
> Replying separately to the actual code review comments, thanks for them.
>
> On Sun, Jan 4, 2015 at 4:56 PM, Philip Reames 
> <listmail at philipreames.com <mailto:listmail at philipreames.com>> wrote:
>
>     A couple of comments inline.
>
>
>         Added:
>              llvm/trunk/include/llvm/Analysis/AssumptionCache.h
>              llvm/trunk/lib/Analysis/AssumptionCache.cpp
>         Removed:
>              llvm/trunk/include/llvm/Analysis/AssumptionTracker.h
>              llvm/trunk/lib/Analysis/AssumptionTracker.cpp
>         Modified:
>              llvm/trunk/include/llvm/Analysis/CodeMetrics.h
>              llvm/trunk/include/llvm/Analysis/InlineCost.h
>              llvm/trunk/include/llvm/Analysis/InstructionSimplify.h
>              llvm/trunk/include/llvm/Analysis/LazyValueInfo.h
>              llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h
>              llvm/trunk/include/llvm/Analysis/PHITransAddr.h
>              llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
>              llvm/trunk/include/llvm/Analysis/ValueTracking.h
>              llvm/trunk/include/llvm/InitializePasses.h
>              llvm/trunk/include/llvm/Transforms/Utils/Cloning.h
>              llvm/trunk/include/llvm/Transforms/Utils/Local.h
>              llvm/trunk/include/llvm/Transforms/Utils/LoopUtils.h
>              llvm/trunk/include/llvm/Transforms/Utils/PromoteMemToReg.h
>              llvm/trunk/include/llvm/Transforms/Utils/UnrollLoop.h
>              llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
>              llvm/trunk/lib/Analysis/CMakeLists.txt
>              llvm/trunk/lib/Analysis/CodeMetrics.cpp
>              llvm/trunk/lib/Analysis/IPA/InlineCost.cpp
>              llvm/trunk/lib/Analysis/InstructionSimplify.cpp
>              llvm/trunk/lib/Analysis/LazyValueInfo.cpp
>              llvm/trunk/lib/Analysis/Lint.cpp
>              llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
>              llvm/trunk/lib/Analysis/PHITransAddr.cpp
>              llvm/trunk/lib/Analysis/ScalarEvolution.cpp
>              llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
>              llvm/trunk/lib/Analysis/ValueTracking.cpp
>              llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp
>              llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp
>              llvm/trunk/lib/Transforms/IPO/Inliner.cpp
>              llvm/trunk/lib/Transforms/InstCombine/InstCombine.h
>              llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp
>              llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
>              llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
>              llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
>            
>          llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
>            
>          llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
>              llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp
>              llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
>              llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp
>            
>          llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
>              llvm/trunk/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
>              llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp
>              llvm/trunk/lib/Transforms/Scalar/GVN.cpp
>              llvm/trunk/lib/Transforms/Scalar/LoopInstSimplify.cpp
>              llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp
>              llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp
>              llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
>              llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp
>              llvm/trunk/lib/Transforms/Scalar/SROA.cpp
>              llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
>              llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp
>              llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
>              llvm/trunk/lib/Transforms/Utils/Local.cpp
>              llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp
>              llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp
>              llvm/trunk/lib/Transforms/Utils/Mem2Reg.cpp
>              llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
>              llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
>              llvm/trunk/lib/Transforms/Utils/SimplifyInstructions.cpp
>              llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
>              llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
>
>         Added: llvm/trunk/include/llvm/Analysis/AssumptionCache.h
>         URL:
>         http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/AssumptionCache.h?rev=225131&view=auto
>         ==============================================================================
>         --- llvm/trunk/include/llvm/Analysis/AssumptionCache.h (added)
>         +++ llvm/trunk/include/llvm/Analysis/AssumptionCache.h Sun
>         Jan  4 06:03:27 2015
>         @@ -0,0 +1,142 @@
>         +//===- llvm/Analysis/AssumptionCache.h - Track @llvm.assume
>         ---*- C++ -*-===//
>         +//
>         +//                     The LLVM Compiler Infrastructure
>         +//
>         +// This file is distributed under the University of Illinois
>         Open Source
>         +// License. See LICENSE.TXT for details.
>         +//
>         +//===----------------------------------------------------------------------===//
>         +//
>         +// This file contains a pass that keeps track of @llvm.assume
>         intrinsics in
>         +// the functions of a module (allowing assumptions within any
>         function to be
>         +// found cheaply by other parts of the optimizer).
>         +//
>         +//===----------------------------------------------------------------------===//
>         +
>         +#ifndef LLVM_ANALYSIS_ASSUMPTIONTRACKER_H
>         +#define LLVM_ANALYSIS_ASSUMPTIONTRACKER_H
>
>     This needs updated.
>
>
> Gah, I knew I had missed something.
>
>
>         +
>         +#include "llvm/ADT/ArrayRef.h"
>         +#include "llvm/ADT/DenseMap.h"
>         +#include "llvm/ADT/SmallSet.h"
>         +#include "llvm/IR/Function.h"
>         +#include "llvm/IR/Instructions.h"
>         +#include "llvm/IR/ValueHandle.h"
>         +#include "llvm/Pass.h"
>         +#include <memory>
>         +
>         +namespace llvm {
>         +
>         +/// \brief A cache of @llvm.assume calls within a function.
>         +///
>         +/// This cache provides fast lookup of assumptions within a
>         function by caching
>         +/// them and amortizing the cost of scanning for them across
>         all queries. The
>         +/// cache is also conservatively self-updating so that it
>         will never return
>         +/// incorrect results about a function even as the function
>         is being mutated.
>         +/// However, flushing the cache and rebuilding it (or
>         explicitly updating it)
>         +/// may allow it to discover new assumptions.
>         +class AssumptionCache {
>         +  /// \brief The function for which this cache is handling
>         assumptions.
>         +  ///
>         +  /// We track this to lazily populate our assumptions.
>         +  Function &F;
>         +
>         +  /// \brief Vector of weak value handles to calls of the
>         @llvm.assume
>         +  /// intrinsic.
>         +  SmallVector<WeakVH, 4> AssumeHandles;
>
>     Why 4?  Given that an assumption cache only exists if a function
>     has assumes, why not make this slightly larger?
>
>
> Primarily because an assumption cache is actually created for most 
> function even if there are no assume intrinsics. See below my comments 
> about why we don't populate the assumption cache eagerly which should 
> clarify this a lot.
Makes sense.
>
> Secondarily, I'm not sure that having more assumes is very common. 
> Introducing an assume intrinsic is a reasonable high-cost thing to the 
> rest of the optimizer, and so I was being relatively conservative in 
> the expected number of them. But this is something that should be 
> tuned based on data if the initial guessed value isn't really suitable.
One data point: I'm using them fairly heavily at the moment.  I don't 
plan on continuing to do so for the current use - which is mostly to get 
a really nasty exception scheme to optimize reasonably - but imagine 
I'll run across something else I need them for in the future.

On point worth thinking about: If we want assumes to be our mechanism 
for rapid experimentation w.r.t. optimizer hints, adding assumes can't 
be too much more expensive than an attribute or metadata.  Otherwise, it 
makes quick experimentation much harder.
>
>
>         +
>         +  /// \brief Flag tracking whether we have scanned the
>         function yet.
>         +  ///
>         +  /// We want to be as lazy about this as possible, and so we
>         scan the function
>         +  /// at the last moment.
>         +  bool Scanned;
>         +
>         +  /// \brief Scan the function for assumptions and add them
>         to the cache.
>         +  void scanFunction();
>         +
>         +public:
>         +  /// \brief Construct an AssumptionCache from a function by
>         scanning all of
>         +  /// its instructions.
>         +  AssumptionCache(Function &F) : F(F), Scanned(false) {}
>         +
>         +  /// \brief Add an @llvm.assume intrinsic to this function's
>         cache.
>         +  ///
>         +  /// The call passed in must be an instruction within this
>         fuction and must
>         +  /// not already be in the cache.
>         +  void registerAssumption(CallInst *CI);
>         +
>         +  /// \brief Clear the cache of @llvm.assume intrinsics for a
>         function.
>         +  ///
>         +  /// It will be re-scanned the next time it is requested.
>         +  void clear() {
>         +    AssumeHandles.clear();
>         +    Scanned = false;
>         +  }
>         +
>         +  /// \brief Access the list of assumption handles currently
>         tracked for this
>         +  /// fuction.
>         +  ///
>         +  /// Note that these produce weak handles that may be null.
>         The caller must
>         +  /// handle that case.
>         +  /// FIXME: We should replace this with
>         pointee_iterator<filter_iterator<...>>
>         +  /// when we can write that to filter out the null values.
>         Then caller code
>         +  /// will become simpler.
>         +  MutableArrayRef<WeakVH> assumptions() {
>         +    if (!Scanned)
>         +      scanFunction();
>         +    return AssumeHandles;
>         +  }
>         +};
>         +
>         +/// \brief An immutable pass that tracks lazily created \c
>         AssumptionCache
>         +/// objects.
>         +///
>         +/// This is essentially a workaround for the legacy pass
>         manager's weaknesses
>         +/// which associates each assumption cache with Function and
>         clears it if the
>         +/// function is deleted. The nature of the AssumptionCache is
>         that it is not
>         +/// invalidated by any changes to the function body and so
>         this is sufficient
>         +/// to be conservatively correct.
>         +class AssumptionCacheTracker : public ImmutablePass {
>         +  /// A callback value handle applied to function objects,
>         which we use to
>         +  /// delete our cache of intrinsics for a function when it
>         is deleted.
>         +  class FunctionCallbackVH : public CallbackVH {
>         +    AssumptionCacheTracker *ACT;
>         +    void deleted() override;
>         +
>         +  public:
>         +    typedef DenseMapInfo<Value *> DMI;
>         +
>         +    FunctionCallbackVH(Value *V, AssumptionCacheTracker *ACT
>         = nullptr)
>         +        : CallbackVH(V), ACT(ACT) {}
>         +  };
>         +
>         +  friend FunctionCallbackVH;
>         +
>         +  typedef DenseMap<FunctionCallbackVH,
>         std::unique_ptr<AssumptionCache>,
>         +                   FunctionCallbackVH::DMI> FunctionCallsMap;
>         +  FunctionCallsMap AssumptionCaches;
>         +
>         +public:
>         +  /// \brief Get the cached assumptions for a function.
>         +  ///
>         +  /// If no assumptions are cached, this will scan the
>         function. Otherwise, the
>         +  /// existing cache will be returned.
>         +  AssumptionCache &getAssumptionCache(Function &F);
>         +
>         +  AssumptionCacheTracker();
>         +  ~AssumptionCacheTracker();
>         +
>         +  void releaseMemory() override {
>         AssumptionCaches.shrink_and_clear(); }
>         +
>         +  void verifyAnalysis() const override;
>         +  bool doFinalization(Module &) override {
>         +    verifyAnalysis();
>         +    return false;
>         +  }
>         +
>         +  static char ID; // Pass identification, replacement for typeid
>         +};
>         +
>         +} // end namespace llvm
>         +
>         +#endif
>
>         Removed: llvm/trunk/include/llvm/Analysis/AssumptionTracker.h
>         URL:
>         http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/AssumptionTracker.h?rev=225130&view=auto
>         ==============================================================================
>         --- llvm/trunk/include/llvm/Analysis/AssumptionTracker.h
>         (original)
>         +++ llvm/trunk/include/llvm/Analysis/AssumptionTracker.h (removed)
>         @@ -1,128 +0,0 @@
>         -//===- llvm/Analysis/AssumptionTracker.h - Track @llvm.assume
>         ---*- C++ -*-===//
>         -//
>         -//                     The LLVM Compiler Infrastructure
>         -//
>         -// This file is distributed under the University of Illinois
>         Open Source
>         -// License. See LICENSE.TXT for details.
>         -//
>         -//===----------------------------------------------------------------------===//
>         -//
>         -// This file contains a pass that keeps track of @llvm.assume
>         intrinsics in
>         -// the functions of a module (allowing assumptions within any
>         function to be
>         -// found cheaply by other parts of the optimizer).
>         -//
>         -//===----------------------------------------------------------------------===//
>         -
>         -#ifndef LLVM_ANALYSIS_ASSUMPTIONTRACKER_H
>         -#define LLVM_ANALYSIS_ASSUMPTIONTRACKER_H
>         -
>         -#include "llvm/ADT/DenseMap.h"
>         -#include "llvm/ADT/DenseSet.h"
>         -#include "llvm/ADT/SmallSet.h"
>         -#include "llvm/IR/Function.h"
>         -#include "llvm/IR/Instructions.h"
>         -#include "llvm/IR/ValueHandle.h"
>         -#include "llvm/Pass.h"
>         -#include <memory>
>         -
>         -namespace llvm {
>         -
>         -/// An immutable pass that tracks @llvm.assume intrinsics in
>         a module.
>         -class AssumptionTracker : public ImmutablePass {
>         -  /// A callback value handle applied to function objects,
>         which we use to
>         -  /// delete our cache of intrinsics for a function when it
>         is deleted.
>         -  class FunctionCallbackVH : public CallbackVH {
>         -    AssumptionTracker *AT;
>         -    void deleted() override;
>         -
>         -    public:
>         -      typedef DenseMapInfo<Value *> DMI;
>         -
>         -      FunctionCallbackVH(Value *V, AssumptionTracker *AT =
>         nullptr)
>         -        : CallbackVH(V), AT(AT) {}
>         -  };
>         -
>         -  /// A callback value handle applied to call instructions,
>         which keeps
>         -  /// track of the call's parent function so that we can remove a
>         -  /// assumption intrinsic call from our cache when the
>         instruction is
>         -  /// deleted.
>         -  class CallCallbackVH : public CallbackVH {
>         -    AssumptionTracker *AT;
>         -    void deleted() override;
>         -
>         -    // We store the function here because we need it to
>         lookup the set
>         -    // containing this handle when the underlying CallInst is
>         being deleted.
>         -    Function *F;
>         -
>         -    public:
>         -      typedef DenseMapInfo<Instruction *> DMI;
>         -
>         -      CallCallbackVH(Instruction *I, AssumptionTracker *AT =
>         nullptr)
>         -        : CallbackVH(I), AT(AT), F(nullptr) {
>         -        if (I != DMI::getEmptyKey() && I !=
>         DMI::getTombstoneKey())
>         -          F = I->getParent()->getParent();
>         -      }
>         -
>         -      operator CallInst*() const {
>         -        Value *V = getValPtr();
>         -        if (V == DMI::getEmptyKey() || V ==
>         DMI::getTombstoneKey())
>         -          return reinterpret_cast<CallInst*>(V);
>         -
>         -        return cast<CallInst>(V);
>         -      }
>         -
>         -      CallInst *operator->() const { return
>         cast<CallInst>(getValPtr()); }
>         -      CallInst &operator*() const { return
>         *cast<CallInst>(getValPtr()); }
>         -  };
>         -
>         -  friend FunctionCallbackVH;
>         -  friend CallCallbackVH;
>         -
>         -  // FIXME: SmallSet might be better here, but it currently
>         has no iterators.
>         -  typedef DenseSet<CallCallbackVH, CallCallbackVH::DMI>
>         CallHandleSet;
>         -  typedef DenseMap<FunctionCallbackVH,
>         std::unique_ptr<CallHandleSet>,
>         -                   FunctionCallbackVH::DMI> FunctionCallsMap;
>         -  FunctionCallsMap CachedAssumeCalls;
>         -
>         -  /// Scan the provided function for @llvm.assume intrinsic
>         calls. Returns an
>         -  /// iterator to the set for this function in the
>         CachedAssumeCalls map.
>         -  FunctionCallsMap::iterator scanFunction(Function *F);
>         -
>         -public:
>         -  /// Remove the cache of @llvm.assume intrinsics for the
>         given function.
>         -  void forgetCachedAssumptions(Function *F);
>         -
>         -  /// Add an @llvm.assume intrinsic to the cache for its
>         parent function.
>         -  void registerAssumption(CallInst *CI);
>         -
>         -  typedef CallHandleSet::iterator assumption_iterator;
>         -  typedef iterator_range<assumption_iterator> assumption_range;
>         -
>         -  inline assumption_range assumptions(Function *F) {
>         -    FunctionCallsMap::iterator I = CachedAssumeCalls.find_as(F);
>         -    if (I == CachedAssumeCalls.end()) {
>         -      I = scanFunction(F);
>         -    }
>         -
>         -    return assumption_range(I->second->begin(),
>         I->second->end());
>         -  }
>         -
>         -  AssumptionTracker();
>         -  ~AssumptionTracker();
>         -
>         -  void releaseMemory() override {
>         -    CachedAssumeCalls.shrink_and_clear();
>         -  }
>         -
>         -  void verifyAnalysis() const override;
>         -  bool doFinalization(Module &) override {
>         -    verifyAnalysis();
>         -    return false;
>         -  }
>         -
>         -  static char ID; // Pass identification, replacement for typeid
>         -};
>         -
>         -} // end namespace llvm
>         -
>         -#endif
>
>         Modified: llvm/trunk/include/llvm/Analysis/CodeMetrics.h
>         URL:
>         http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/CodeMetrics.h?rev=225131&r1=225130&r2=225131&view=diff
>         ==============================================================================
>         --- llvm/trunk/include/llvm/Analysis/CodeMetrics.h (original)
>         +++ llvm/trunk/include/llvm/Analysis/CodeMetrics.h Sun Jan  4
>         06:03:27 2015
>         @@ -20,7 +20,7 @@
>           #include "llvm/IR/CallSite.h"
>             namespace llvm {
>         -class AssumptionTracker;
>         +class AssumptionCache;
>           class BasicBlock;
>           class Loop;
>           class Function;
>         @@ -93,13 +93,13 @@ struct CodeMetrics {
>               /// \brief Collect a loop's ephemeral values (those used
>         only by an assume
>             /// or similar intrinsics in the loop).
>         -  static void collectEphemeralValues(const Loop *L,
>         AssumptionTracker *AT,
>         -  SmallPtrSetImpl<const Value*> &EphValues);
>         +  static void collectEphemeralValues(const Loop *L,
>         AssumptionCache *AC,
>         +  SmallPtrSetImpl<const Value *> &EphValues);
>
>     Formatting changes (and arguably the rename involved in the API
>     split itself) should have been separated.
>
>
> It's nearly impossible to separate these kinds of formatting changes. 
> I didn't reformat anything by hand here, I simply asked clang-format 
> to re-format the lines I had touched in the patch. In several cases 
> this was necessary as the correct formatting was different after the 
> s/AssumptionTracker/AssumptionCache/ change. For better or worse, 
> clang-format will also fix other formatting issues (such as X* vs X *) 
> in the same "unwrapped line". It doesn't really add any noise to the 
> blame though as I was going to touch this code either way.
Honestly, this sounds like a feature request for clang-format to me.  :)

The only reason I commented here is that the first time I saw this line 
(scanning quickly), I didn't see the restructuring change and did see 
the formatting.  It wasn't until I stared at it for a second that I saw 
the other.

>
>
>               /// \brief Collect a functions's ephemeral values (those
>         used only by an
>             /// assume or similar intrinsics in the function).
>         -  static void collectEphemeralValues(const Function *L,
>         AssumptionTracker *AT,
>         -  SmallPtrSetImpl<const Value*> &EphValues);
>         +  static void collectEphemeralValues(const Function *L,
>         AssumptionCache *AC,
>         +  SmallPtrSetImpl<const Value *> &EphValues);
>           };
>             }
>
>         Modified: llvm/trunk/include/llvm/Analysis/InlineCost.h
>         URL:
>         http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/InlineCost.h?rev=225131&r1=225130&r2=225131&view=diff
>         ==============================================================================
>         --- llvm/trunk/include/llvm/Analysis/InlineCost.h (original)
>         +++ llvm/trunk/include/llvm/Analysis/InlineCost.h Sun Jan  4
>         06:03:27 2015
>         @@ -19,7 +19,7 @@
>           #include <climits>
>             namespace llvm {
>         -class AssumptionTracker;
>         +class AssumptionCacheTracker;
>           class CallSite;
>           class DataLayout;
>           class Function;
>         @@ -101,7 +101,7 @@ public:
>           /// \brief Cost analyzer used by inliner.
>           class InlineCostAnalysis : public CallGraphSCCPass {
>             const TargetTransformInfo *TTI;
>         -  AssumptionTracker *AT;
>         +  AssumptionCacheTracker *ACT;
>             public:
>             static char ID;
>
>         Modified: llvm/trunk/include/llvm/Analysis/InstructionSimplify.h
>         URL:
>         http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/InstructionSimplify.h?rev=225131&r1=225130&r2=225131&view=diff
>         ==============================================================================
>         --- llvm/trunk/include/llvm/Analysis/InstructionSimplify.h
>         (original)
>         +++ llvm/trunk/include/llvm/Analysis/InstructionSimplify.h Sun
>         Jan  4 06:03:27 2015
>         @@ -37,7 +37,7 @@
>           namespace llvm {
>             template<typename T>
>             class ArrayRef;
>         -  class AssumptionTracker;
>         +  class AssumptionCache;
>             class DominatorTree;
>             class Instruction;
>             class DataLayout;
>         @@ -52,7 +52,7 @@ namespace llvm {
>                                    const DataLayout *TD = nullptr,
>                                    const TargetLibraryInfo *TLI = nullptr,
>                                    const DominatorTree *DT = nullptr,
>         -                         AssumptionTracker *AT = nullptr,
>         +                         AssumptionCache *AC = nullptr,
>                                    const Instruction *CxtI = nullptr);
>               /// SimplifySubInst - Given operands for a Sub, see if
>         we can
>         @@ -61,35 +61,34 @@ namespace llvm {
>                                    const DataLayout *TD = nullptr,
>                                    const TargetLibraryInfo *TLI = nullptr,
>                                    const DominatorTree *DT = nullptr,
>         -                         AssumptionTracker *AT = nullptr,
>         +                         AssumptionCache *AC = nullptr,
>                                    const Instruction *CxtI = nullptr);
>               /// Given operands for an FAdd, see if we can fold the
>         result.  If not, this
>             /// returns null.
>             Value *SimplifyFAddInst(Value *LHS, Value *RHS,
>         FastMathFlags FMF,
>         -                         const DataLayout *TD = nullptr,
>         -                         const TargetLibraryInfo *TLI = nullptr,
>         -                         const DominatorTree *DT = nullptr,
>         -                         AssumptionTracker *AT = nullptr,
>         -                         const Instruction *CxtI = nullptr);
>         +                          const DataLayout *TD = nullptr,
>         +                          const TargetLibraryInfo *TLI = nullptr,
>         +                          const DominatorTree *DT = nullptr,
>         +                          AssumptionCache *AC = nullptr,
>         +                          const Instruction *CxtI = nullptr);
>               /// Given operands for an FSub, see if we can fold the
>         result.  If not, this
>             /// returns null.
>             Value *SimplifyFSubInst(Value *LHS, Value *RHS,
>         FastMathFlags FMF,
>         -                         const DataLayout *TD = nullptr,
>         -                         const TargetLibraryInfo *TLI = nullptr,
>         -                         const DominatorTree *DT = nullptr,
>         -                         AssumptionTracker *AT = nullptr,
>         -                         const Instruction *CxtI = nullptr);
>         +                          const DataLayout *TD = nullptr,
>         +                          const TargetLibraryInfo *TLI = nullptr,
>         +                          const DominatorTree *DT = nullptr,
>         +                          AssumptionCache *AC = nullptr,
>         +                          const Instruction *CxtI = nullptr);
>               /// Given operands for an FMul, see if we can fold the
>         result.  If not, this
>             /// returns null.
>         -  Value *SimplifyFMulInst(Value *LHS, Value *RHS,
>         -                          FastMathFlags FMF,
>         +  Value *SimplifyFMulInst(Value *LHS, Value *RHS,
>         FastMathFlags FMF,
>                                     const DataLayout *TD = nullptr,
>                                     const TargetLibraryInfo *TLI =
>         nullptr,
>                                     const DominatorTree *DT = nullptr,
>         -                          AssumptionTracker *AT = nullptr,
>         +                          AssumptionCache *AC = nullptr,
>                                     const Instruction *CxtI = nullptr);
>               /// SimplifyMulInst - Given operands for a Mul, see if
>         we can
>         @@ -97,7 +96,7 @@ namespace llvm {
>             Value *SimplifyMulInst(Value *LHS, Value *RHS, const
>         DataLayout *TD = nullptr,
>                                    const TargetLibraryInfo *TLI = nullptr,
>                                    const DominatorTree *DT = nullptr,
>         -                         AssumptionTracker *AT = nullptr,
>         +                         AssumptionCache *AC = nullptr,
>                                    const Instruction *CxtI = nullptr);
>               /// SimplifySDivInst - Given operands for an SDiv, see
>         if we can
>         @@ -106,7 +105,7 @@ namespace llvm {
>                                     const DataLayout *TD = nullptr,
>                                     const TargetLibraryInfo *TLI =
>         nullptr,
>                                     const DominatorTree *DT = nullptr,
>         -                          AssumptionTracker *AT = nullptr,
>         +                          AssumptionCache *AC = nullptr,
>                                     const Instruction *CxtI = nullptr);
>               /// SimplifyUDivInst - Given operands for a UDiv, see if
>         we can
>         @@ -115,7 +114,7 @@ namespace llvm {
>                                     const DataLayout *TD = nullptr,
>                                     const TargetLibraryInfo *TLI =
>         nullptr,
>                                     const DominatorTree *DT = nullptr,
>         -                          AssumptionTracker *AT = nullptr,
>         +                          AssumptionCache *AC = nullptr,
>                                     const Instruction *CxtI = nullptr);
>               /// SimplifyFDivInst - Given operands for an FDiv, see
>         if we can
>         @@ -124,7 +123,7 @@ namespace llvm {
>                                     const DataLayout *TD = nullptr,
>                                     const TargetLibraryInfo *TLI =
>         nullptr,
>                                     const DominatorTree *DT = nullptr,
>         -                          AssumptionTracker *AT = nullptr,
>         +                          AssumptionCache *AC = nullptr,
>                                     const Instruction *CxtI = nullptr);
>               /// SimplifySRemInst - Given operands for an SRem, see
>         if we can
>         @@ -133,7 +132,7 @@ namespace llvm {
>                                     const DataLayout *TD = nullptr,
>                                     const TargetLibraryInfo *TLI =
>         nullptr,
>                                     const DominatorTree *DT = nullptr,
>         -                          AssumptionTracker *AT = nullptr,
>         +                          AssumptionCache *AC = nullptr,
>                                     const Instruction *CxtI = nullptr);
>               /// SimplifyURemInst - Given operands for a URem, see if
>         we can
>         @@ -142,7 +141,7 @@ namespace llvm {
>                                     const DataLayout *TD = nullptr,
>                                     const TargetLibraryInfo *TLI =
>         nullptr,
>                                     const DominatorTree *DT = nullptr,
>         -                          AssumptionTracker *AT = nullptr,
>         +                          AssumptionCache *AC = nullptr,
>                                     const Instruction *CxtI = nullptr);
>               /// SimplifyFRemInst - Given operands for an FRem, see
>         if we can
>         @@ -151,7 +150,7 @@ namespace llvm {
>                                     const DataLayout *TD = nullptr,
>                                     const TargetLibraryInfo *TLI =
>         nullptr,
>                                     const DominatorTree *DT = nullptr,
>         -                          AssumptionTracker *AT = nullptr,
>         +                          AssumptionCache *AC = nullptr,
>                                     const Instruction *CxtI = nullptr);
>               /// SimplifyShlInst - Given operands for a Shl, see if
>         we can
>         @@ -160,7 +159,7 @@ namespace llvm {
>                                    const DataLayout *TD = nullptr,
>                                    const TargetLibraryInfo *TLI = nullptr,
>                                    const DominatorTree *DT = nullptr,
>         -                         AssumptionTracker *AT = nullptr,
>         +                         AssumptionCache *AC = nullptr,
>                                    const Instruction *CxtI = nullptr);
>               /// SimplifyLShrInst - Given operands for a LShr, see if
>         we can
>         @@ -169,7 +168,7 @@ namespace llvm {
>                                     const DataLayout *TD = nullptr,
>                                     const TargetLibraryInfo *TLI =
>         nullptr,
>                                     const DominatorTree *DT = nullptr,
>         -                          AssumptionTracker *AT = nullptr,
>         +                          AssumptionCache *AC = nullptr,
>                                     const Instruction *CxtI = nullptr);
>               /// SimplifyAShrInst - Given operands for a AShr, see if
>         we can
>         @@ -178,7 +177,7 @@ namespace llvm {
>                                     const DataLayout *TD = nullptr,
>                                     const TargetLibraryInfo *TLI =
>         nullptr,
>                                     const DominatorTree *DT = nullptr,
>         -                          AssumptionTracker *AT = nullptr,
>         +                          AssumptionCache *AC = nullptr,
>                                     const Instruction *CxtI = nullptr);
>               /// SimplifyAndInst - Given operands for an And, see if
>         we can
>         @@ -186,7 +185,7 @@ namespace llvm {
>             Value *SimplifyAndInst(Value *LHS, Value *RHS, const
>         DataLayout *TD = nullptr,
>                                    const TargetLibraryInfo *TLI = nullptr,
>                                    const DominatorTree *DT = nullptr,
>         -                         AssumptionTracker *AT = nullptr,
>         +                         AssumptionCache *AC = nullptr,
>                                    const Instruction *CxtI = nullptr);
>               /// SimplifyOrInst - Given operands for an Or, see if we can
>         @@ -194,7 +193,7 @@ namespace llvm {
>             Value *SimplifyOrInst(Value *LHS, Value *RHS, const
>         DataLayout *TD = nullptr,
>                                   const TargetLibraryInfo *TLI = nullptr,
>                                   const DominatorTree *DT = nullptr,
>         -                        AssumptionTracker *AT = nullptr,
>         +                        AssumptionCache *AC = nullptr,
>                                   const Instruction *CxtI = nullptr);
>               /// SimplifyXorInst - Given operands for a Xor, see if
>         we can
>         @@ -202,7 +201,7 @@ namespace llvm {
>             Value *SimplifyXorInst(Value *LHS, Value *RHS, const
>         DataLayout *TD = nullptr,
>                                    const TargetLibraryInfo *TLI = nullptr,
>                                    const DominatorTree *DT = nullptr,
>         -                         AssumptionTracker *AT = nullptr,
>         +                         AssumptionCache *AC = nullptr,
>                                    const Instruction *CxtI = nullptr);
>               /// SimplifyICmpInst - Given operands for an ICmpInst,
>         see if we can
>         @@ -211,7 +210,7 @@ namespace llvm {
>                                     const DataLayout *TD = nullptr,
>                                     const TargetLibraryInfo *TLI =
>         nullptr,
>                                     const DominatorTree *DT = nullptr,
>         -                          AssumptionTracker *AT = nullptr,
>         +                          AssumptionCache *AC = nullptr,
>                                     Instruction *CxtI = nullptr);
>               /// SimplifyFCmpInst - Given operands for an FCmpInst,
>         see if we can
>         @@ -220,7 +219,7 @@ namespace llvm {
>                                     const DataLayout *TD = nullptr,
>                                     const TargetLibraryInfo *TLI =
>         nullptr,
>                                     const DominatorTree *DT = nullptr,
>         -                          AssumptionTracker *AT = nullptr,
>         +                          AssumptionCache *AC = nullptr,
>                                     const Instruction *CxtI = nullptr);
>               /// SimplifySelectInst - Given operands for a
>         SelectInst, see if we can fold
>         @@ -229,7 +228,7 @@ namespace llvm {
>                                       const DataLayout *TD = nullptr,
>                                       const TargetLibraryInfo *TLI =
>         nullptr,
>                                       const DominatorTree *DT = nullptr,
>         -                            AssumptionTracker *AT = nullptr,
>         +                            AssumptionCache *AC = nullptr,
>                                       const Instruction *CxtI = nullptr);
>               /// SimplifyGEPInst - Given operands for an
>         GetElementPtrInst, see if we can
>         @@ -237,7 +236,7 @@ namespace llvm {
>             Value *SimplifyGEPInst(ArrayRef<Value *> Ops, const
>         DataLayout *TD = nullptr,
>                                    const TargetLibraryInfo *TLI = nullptr,
>                                    const DominatorTree *DT = nullptr,
>         -                         AssumptionTracker *AT = nullptr,
>         +                         AssumptionCache *AC = nullptr,
>                                    const Instruction *CxtI = nullptr);
>               /// SimplifyInsertValueInst - Given operands for an
>         InsertValueInst, see if we
>         @@ -247,7 +246,7 @@ namespace llvm {
>                                            const DataLayout *TD = nullptr,
>                                            const TargetLibraryInfo
>         *TLI = nullptr,
>                                            const DominatorTree *DT =
>         nullptr,
>         -  AssumptionTracker *AT = nullptr,
>         +                                 AssumptionCache *AC = nullptr,
>                                            const Instruction *CxtI =
>         nullptr);
>               /// SimplifyTruncInst - Given operands for an TruncInst,
>         see if we can fold
>         @@ -255,7 +254,7 @@ namespace llvm {
>             Value *SimplifyTruncInst(Value *Op, Type *Ty, const
>         DataLayout *TD = nullptr,
>                                      const TargetLibraryInfo *TLI =
>         nullptr,
>                                      const DominatorTree *DT = nullptr,
>         -                           AssumptionTracker *AT = nullptr,
>         +                           AssumptionCache *AC = nullptr,
>                                      const Instruction *CxtI = nullptr);
>               //=== Helper functions for higher up the class hierarchy.
>         @@ -267,7 +266,7 @@ namespace llvm {
>                                    const DataLayout *TD = nullptr,
>                                    const TargetLibraryInfo *TLI = nullptr,
>                                    const DominatorTree *DT = nullptr,
>         -                         AssumptionTracker *AT = nullptr,
>         +                         AssumptionCache *AC = nullptr,
>                                    const Instruction *CxtI = nullptr);
>               /// SimplifyBinOp - Given operands for a BinaryOperator,
>         see if we can
>         @@ -276,7 +275,7 @@ namespace llvm {
>                                  const DataLayout *TD = nullptr,
>                                  const TargetLibraryInfo *TLI = nullptr,
>                                  const DominatorTree *DT = nullptr,
>         -                       AssumptionTracker *AT = nullptr,
>         +                       AssumptionCache *AC = nullptr,
>                                  const Instruction *CxtI = nullptr);
>               /// \brief Given a function and iterators over
>         arguments, see if we can fold
>         @@ -287,7 +286,7 @@ namespace llvm {
>                                 User::op_iterator ArgEnd, const
>         DataLayout *TD = nullptr,
>                                 const TargetLibraryInfo *TLI = nullptr,
>                                 const DominatorTree *DT = nullptr,
>         -                      AssumptionTracker *AT = nullptr,
>         +                      AssumptionCache *AC = nullptr,
>                                 const Instruction *CxtI = nullptr);
>               /// \brief Given a function and set of arguments, see if
>         we can fold the
>         @@ -298,7 +297,7 @@ namespace llvm {
>                                 const DataLayout *TD = nullptr,
>                                 const TargetLibraryInfo *TLI = nullptr,
>                                 const DominatorTree *DT = nullptr,
>         -                      AssumptionTracker *AT = nullptr,
>         +                      AssumptionCache *AC = nullptr,
>                                 const Instruction *CxtI = nullptr);
>               /// SimplifyInstruction - See if we can compute a
>         simplified version of this
>         @@ -306,8 +305,7 @@ namespace llvm {
>             Value *SimplifyInstruction(Instruction *I, const
>         DataLayout *TD = nullptr,
>                                        const TargetLibraryInfo *TLI =
>         nullptr,
>                                        const DominatorTree *DT = nullptr,
>         -                             AssumptionTracker *AT = nullptr);
>         -
>         +                             AssumptionCache *AC = nullptr);
>               /// \brief Replace all uses of 'I' with 'SimpleV' and
>         simplify the uses
>             /// recursively.
>         @@ -321,7 +319,7 @@ namespace llvm {
>                                                const DataLayout *TD =
>         nullptr,
>                                                const TargetLibraryInfo
>         *TLI = nullptr,
>                                                const DominatorTree *DT
>         = nullptr,
>         -  AssumptionTracker *AT = nullptr);
>         +  AssumptionCache *AC = nullptr);
>               /// \brief Recursively attempt to simplify an instruction.
>             ///
>         @@ -333,7 +331,7 @@ namespace llvm {
>                                                 const DataLayout *TD =
>         nullptr,
>                                                 const
>         TargetLibraryInfo *TLI = nullptr,
>                                                 const DominatorTree
>         *DT = nullptr,
>         - AssumptionTracker *AT = nullptr);
>         + AssumptionCache *AC = nullptr);
>           } // end namespace llvm
>             #endif
>
>         Modified: llvm/trunk/include/llvm/Analysis/LazyValueInfo.h
>         URL:
>         http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LazyValueInfo.h?rev=225131&r1=225130&r2=225131&view=diff
>         ==============================================================================
>         --- llvm/trunk/include/llvm/Analysis/LazyValueInfo.h (original)
>         +++ llvm/trunk/include/llvm/Analysis/LazyValueInfo.h Sun Jan 
>         4 06:03:27 2015
>         @@ -18,7 +18,7 @@
>           #include "llvm/Pass.h"
>             namespace llvm {
>         -  class AssumptionTracker;
>         +  class AssumptionCache;
>             class Constant;
>             class DataLayout;
>             class DominatorTree;
>         @@ -29,7 +29,7 @@ namespace llvm {
>           /// LazyValueInfo - This pass computes, caches, and vends
>         lazy value constraint
>           /// information.
>           class LazyValueInfo : public FunctionPass {
>         -  AssumptionTracker *AT;
>         +  AssumptionCache *AC;
>             const DataLayout *DL;
>             class TargetLibraryInfo *TLI;
>             DominatorTree *DT;
>
>         Modified:
>         llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h
>         URL:
>         http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h?rev=225131&r1=225130&r2=225131&view=diff
>         ==============================================================================
>         ---
>         llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h
>         (original)
>         +++
>         llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h
>         Sun Jan  4 06:03:27 2015
>         @@ -28,7 +28,7 @@ namespace llvm {
>             class Instruction;
>             class CallSite;
>             class AliasAnalysis;
>         -  class AssumptionTracker;
>         +  class AssumptionCache;
>             class DataLayout;
>             class MemoryDependenceAnalysis;
>             class PredIteratorCache;
>         @@ -326,7 +326,7 @@ namespace llvm {
>               AliasAnalysis *AA;
>               const DataLayout *DL;
>               DominatorTree *DT;
>         -    AssumptionTracker *AT;
>         +    AssumptionCache *AC;
>               std::unique_ptr<PredIteratorCache> PredCache;
>               public:
>
>         Modified: llvm/trunk/include/llvm/Analysis/PHITransAddr.h
>         URL:
>         http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/PHITransAddr.h?rev=225131&r1=225130&r2=225131&view=diff
>         ==============================================================================
>         --- llvm/trunk/include/llvm/Analysis/PHITransAddr.h (original)
>         +++ llvm/trunk/include/llvm/Analysis/PHITransAddr.h Sun Jan  4
>         06:03:27 2015
>         @@ -18,7 +18,7 @@
>           #include "llvm/IR/Instruction.h"
>             namespace llvm {
>         -  class AssumptionTracker;
>         +  class AssumptionCache;
>             class DominatorTree;
>             class DataLayout;
>             class TargetLibraryInfo;
>         @@ -44,13 +44,13 @@ class PHITransAddr {
>             const TargetLibraryInfo *TLI;
>               /// A cache of @llvm.assume calls used by
>         SimplifyInstruction.
>         -  AssumptionTracker *AT;
>         -
>         +  AssumptionCache *AC;
>         +
>             /// InstInputs - The inputs for our symbolic address.
>             SmallVector<Instruction*, 4> InstInputs;
>           public:
>         -  PHITransAddr(Value *addr, const DataLayout *DL,
>         AssumptionTracker *AT)
>         -      : Addr(addr), DL(DL), TLI(nullptr), AT(AT) {
>         +  PHITransAddr(Value *addr, const DataLayout *DL,
>         AssumptionCache *AC)
>         +      : Addr(addr), DL(DL), TLI(nullptr), AC(AC) {
>               // If the address is an instruction, the whole thing is
>         considered an input.
>               if (Instruction *I = dyn_cast<Instruction>(Addr))
>                 InstInputs.push_back(I);
>
>         Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
>         URL:
>         http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=225131&r1=225130&r2=225131&view=diff
>         ==============================================================================
>         --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original)
>         +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Sun
>         Jan  4 06:03:27 2015
>         @@ -35,7 +35,7 @@
>             namespace llvm {
>             class APInt;
>         -  class AssumptionTracker;
>         +  class AssumptionCache;
>             class Constant;
>             class ConstantInt;
>             class DominatorTree;
>         @@ -225,7 +225,7 @@ namespace llvm {
>               Function *F;
>                 /// The tracker for @llvm.assume intrinsics in this
>         function.
>         -    AssumptionTracker *AT;
>         +    AssumptionCache *AC;
>                 /// LI - The loop information for the function we are
>         currently analyzing.
>               ///
>
>         Modified: llvm/trunk/include/llvm/Analysis/ValueTracking.h
>         URL:
>         http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ValueTracking.h?rev=225131&r1=225130&r2=225131&view=diff
>         ==============================================================================
>         --- llvm/trunk/include/llvm/Analysis/ValueTracking.h (original)
>         +++ llvm/trunk/include/llvm/Analysis/ValueTracking.h Sun Jan 
>         4 06:03:27 2015
>         @@ -25,7 +25,7 @@ namespace llvm {
>             class DataLayout;
>             class StringRef;
>             class MDNode;
>         -  class AssumptionTracker;
>         +  class AssumptionCache;
>             class DominatorTree;
>             class TargetLibraryInfo;
>           @@ -37,9 +37,9 @@ namespace llvm {
>             /// where V is a vector, the known zero and known one
>         values are the
>             /// same width as the vector element, and the bit is set
>         only if it is true
>             /// for all of the elements in the vector.
>         -  void computeKnownBits(Value *V,  APInt &KnownZero, APInt
>         &KnownOne,
>         +  void computeKnownBits(Value *V, APInt &KnownZero, APInt
>         &KnownOne,
>                                   const DataLayout *TD = nullptr,
>         unsigned Depth = 0,
>         -                        AssumptionTracker *AT = nullptr,
>         +                        AssumptionCache *AC = nullptr,
>                                   const Instruction *CxtI = nullptr,
>                                   const DominatorTree *DT = nullptr);
>             /// Compute known bits from the range metadata.
>         @@ -51,7 +51,7 @@ namespace llvm {
>             /// one.  Convenience wrapper around computeKnownBits.
>             void ComputeSignBit(Value *V, bool &KnownZero, bool &KnownOne,
>                                 const DataLayout *TD = nullptr,
>         unsigned Depth = 0,
>         -                      AssumptionTracker *AT = nullptr,
>         +                      AssumptionCache *AC = nullptr,
>                                 const Instruction *CxtI = nullptr,
>                                 const DominatorTree *DT = nullptr);
>           @@ -61,7 +61,7 @@ namespace llvm {
>             /// integer or pointer type and vectors of integers.  If
>         'OrZero' is set then
>             /// returns true if the given value is either a power of
>         two or zero.
>             bool isKnownToBeAPowerOfTwo(Value *V, bool OrZero = false,
>         unsigned Depth = 0,
>         -                              AssumptionTracker *AT = nullptr,
>         +                              AssumptionCache *AC = nullptr,
>                                         const Instruction *CxtI = nullptr,
>                                         const DominatorTree *DT =
>         nullptr);
>           @@ -70,7 +70,7 @@ namespace llvm {
>             /// non-zero when defined.  Supports values with integer
>         or pointer type and
>             /// vectors of integers.
>             bool isKnownNonZero(Value *V, const DataLayout *TD = nullptr,
>         -                      unsigned Depth = 0, AssumptionTracker
>         *AT = nullptr,
>         +                      unsigned Depth = 0, AssumptionCache *AC
>         = nullptr,
>                                 const Instruction *CxtI = nullptr,
>                                 const DominatorTree *DT = nullptr);
>           @@ -83,13 +83,12 @@ namespace llvm {
>             /// where V is a vector, the mask, known zero, and known
>         one values are the
>             /// same width as the vector element, and the bit is set
>         only if it is true
>             /// for all of the elements in the vector.
>         -  bool MaskedValueIsZero(Value *V, const APInt &Mask,
>         +  bool MaskedValueIsZero(Value *V, const APInt &Mask,
>                                    const DataLayout *TD = nullptr,
>         unsigned Depth = 0,
>         -                         AssumptionTracker *AT = nullptr,
>         +                         AssumptionCache *AC = nullptr,
>                                    const Instruction *CxtI = nullptr,
>                                    const DominatorTree *DT = nullptr);
>           -
>             /// ComputeNumSignBits - Return the number of times the
>         sign bit of the
>             /// register is replicated into the other bits.  We know
>         that at least 1 bit
>             /// is always equal to the sign bit (itself), but other
>         cases can give us
>         @@ -99,8 +98,7 @@ namespace llvm {
>             /// 'Op' must have a scalar integer type.
>             ///
>             unsigned ComputeNumSignBits(Value *Op, const DataLayout
>         *TD = nullptr,
>         -                              unsigned Depth = 0,
>         -                              AssumptionTracker *AT = nullptr,
>         +                              unsigned Depth = 0,
>         AssumptionCache *AC = nullptr,
>                                         const Instruction *CxtI = nullptr,
>                                         const DominatorTree *DT =
>         nullptr);
>           @@ -220,7 +218,7 @@ namespace llvm {
>             enum class OverflowResult { AlwaysOverflows, MayOverflow,
>         NeverOverflows };
>             OverflowResult computeOverflowForUnsignedMul(Value *LHS,
>         Value *RHS,
>          const DataLayout *DL,
>         -  AssumptionTracker *AT,
>         +  AssumptionCache *AC,
>          const Instruction *CxtI,
>          const DominatorTree *DT);
>           } // end namespace llvm
>
>         Modified: llvm/trunk/include/llvm/InitializePasses.h
>         URL:
>         http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializePasses.h?rev=225131&r1=225130&r2=225131&view=diff
>         ==============================================================================
>         --- llvm/trunk/include/llvm/InitializePasses.h (original)
>         +++ llvm/trunk/include/llvm/InitializePasses.h Sun Jan  4
>         06:03:27 2015
>         @@ -266,7 +266,7 @@ void initializeTargetTransformInfoAnalys
>           void initializeFunctionTargetTransformInfoPass(PassRegistry &);
>           void initializeNoTTIPass(PassRegistry&);
>           void initializeTargetLibraryInfoPass(PassRegistry&);
>         -void initializeAssumptionTrackerPass(PassRegistry &);
>         +void initializeAssumptionCacheTrackerPass(PassRegistry &);
>           void initializeTwoAddressInstructionPassPass(PassRegistry&);
>           void initializeTypeBasedAliasAnalysisPass(PassRegistry&);
>           void initializeScopedNoAliasAAPass(PassRegistry&);
>
>         Modified: llvm/trunk/include/llvm/Transforms/Utils/Cloning.h
>         URL:
>         http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Cloning.h?rev=225131&r1=225130&r2=225131&view=diff
>         ==============================================================================
>         --- llvm/trunk/include/llvm/Transforms/Utils/Cloning.h (original)
>         +++ llvm/trunk/include/llvm/Transforms/Utils/Cloning.h Sun
>         Jan  4 06:03:27 2015
>         @@ -44,7 +44,7 @@ class Loop;
>           class LoopInfo;
>           class AllocaInst;
>           class AliasAnalysis;
>         -class AssumptionTracker;
>         +class AssumptionCacheTracker;
>             /// CloneModule - Return an exact copy of the specified module
>           ///
>         @@ -162,15 +162,15 @@ public:
>             explicit InlineFunctionInfo(CallGraph *cg = nullptr,
>                                         const DataLayout *DL = nullptr,
>                                         AliasAnalysis *AA = nullptr,
>         -                              AssumptionTracker *AT = nullptr)
>         -    : CG(cg), DL(DL), AA(AA), AT(AT) {}
>         + AssumptionCacheTracker *ACT = nullptr)
>         +      : CG(cg), DL(DL), AA(AA), ACT(ACT) {}
>               /// CG - If non-null, InlineFunction will update the
>         callgraph to reflect the
>             /// changes it makes.
>             CallGraph *CG;
>             const DataLayout *DL;
>             AliasAnalysis *AA;
>         -  AssumptionTracker *AT;
>         +  AssumptionCacheTracker *ACT;
>               /// StaticAllocas - InlineFunction fills this in with
>         all static allocas that
>             /// get copied into the caller.
>
>         Modified: llvm/trunk/include/llvm/Transforms/Utils/Local.h
>         URL:
>         http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Local.h?rev=225131&r1=225130&r2=225131&view=diff
>         ==============================================================================
>         --- llvm/trunk/include/llvm/Transforms/Utils/Local.h (original)
>         +++ llvm/trunk/include/llvm/Transforms/Utils/Local.h Sun Jan 
>         4 06:03:27 2015
>         @@ -34,7 +34,7 @@ class Value;
>           class Pass;
>           class PHINode;
>           class AllocaInst;
>         -class AssumptionTracker;
>         +class AssumptionCache;
>           class ConstantExpr;
>           class DataLayout;
>           class TargetLibraryInfo;
>         @@ -138,9 +138,8 @@ bool EliminateDuplicatePHINodes(BasicBlo
>           /// the basic block that was pointed to.
>           ///
>           bool SimplifyCFG(BasicBlock *BB, const TargetTransformInfo &TTI,
>         -                 unsigned BonusInstThreshold,
>         -                 const DataLayout *TD = nullptr,
>         -                 AssumptionTracker *AT = nullptr);
>         +                 unsigned BonusInstThreshold, const
>         DataLayout *TD = nullptr,
>         +                 AssumptionCache *AC = nullptr);
>             /// FlatternCFG - This function is used to flatten a CFG.  For
>           /// example, it uses parallel-and and parallel-or mode to
>         collapse
>         @@ -176,17 +175,17 @@ AllocaInst *DemotePHIToStack(PHINode *P,
>           /// increase the alignment of the ultimate object, making
>         this check succeed.
>           unsigned getOrEnforceKnownAlignment(Value *V, unsigned
>         PrefAlign,
>                                               const DataLayout *TD =
>         nullptr,
>         - AssumptionTracker *AT = nullptr,
>         + AssumptionCache *AC = nullptr,
>                                               const Instruction *CxtI
>         = nullptr,
>                                               const DominatorTree *DT
>         = nullptr);
>             /// getKnownAlignment - Try to infer an alignment for the
>         specified pointer.
>           static inline unsigned getKnownAlignment(Value *V,
>                                                    const DataLayout
>         *TD = nullptr,
>         -  AssumptionTracker *AT = nullptr,
>         +  AssumptionCache *AC = nullptr,
>                                                    const Instruction
>         *CxtI = nullptr,
>                                                    const DominatorTree
>         *DT = nullptr) {
>         -  return getOrEnforceKnownAlignment(V, 0, TD, AT, CxtI, DT);
>         +  return getOrEnforceKnownAlignment(V, 0, TD, AC, CxtI, DT);
>           }
>             /// EmitGEPOffset - Given a getelementptr
>         instruction/constantexpr, emit the
>
>         Modified: llvm/trunk/include/llvm/Transforms/Utils/LoopUtils.h
>         URL:
>         http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/LoopUtils.h?rev=225131&r1=225130&r2=225131&view=diff
>         ==============================================================================
>         --- llvm/trunk/include/llvm/Transforms/Utils/LoopUtils.h
>         (original)
>         +++ llvm/trunk/include/llvm/Transforms/Utils/LoopUtils.h Sun
>         Jan  4 06:03:27 2015
>         @@ -16,7 +16,7 @@
>             namespace llvm {
>           class AliasAnalysis;
>         -class AssumptionTracker;
>         +class AssumptionCache;
>           class BasicBlock;
>           class DataLayout;
>           class DominatorTree;
>         @@ -36,7 +36,7 @@ BasicBlock *InsertPreheaderForLoop(Loop
>           bool simplifyLoop(Loop *L, DominatorTree *DT, LoopInfo *LI,
>         Pass *PP,
>                             AliasAnalysis *AA = nullptr,
>         ScalarEvolution *SE = nullptr,
>                             const DataLayout *DL = nullptr,
>         -                  AssumptionTracker *AT = nullptr);
>         +                  AssumptionCache *AC = nullptr);
>             /// \brief Put loop into LCSSA form.
>           ///
>
>         Modified:
>         llvm/trunk/include/llvm/Transforms/Utils/PromoteMemToReg.h
>         URL:
>         http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/PromoteMemToReg.h?rev=225131&r1=225130&r2=225131&view=diff
>         ==============================================================================
>         --- llvm/trunk/include/llvm/Transforms/Utils/PromoteMemToReg.h
>         (original)
>         +++ llvm/trunk/include/llvm/Transforms/Utils/PromoteMemToReg.h
>         Sun Jan  4 06:03:27 2015
>         @@ -22,7 +22,7 @@ namespace llvm {
>           class AllocaInst;
>           class DominatorTree;
>           class AliasSetTracker;
>         -class AssumptionTracker;
>         +class AssumptionCache;
>             /// \brief Return true if this alloca is legal for promotion.
>           ///
>         @@ -43,7 +43,7 @@ bool isAllocaPromotable(const AllocaInst
>           /// made to the IR.
>           void PromoteMemToReg(ArrayRef<AllocaInst *> Allocas,
>         DominatorTree &DT,
>                                AliasSetTracker *AST = nullptr,
>         -                     AssumptionTracker *AT = nullptr);
>         +                     AssumptionCache *AC = nullptr);
>             } // End llvm namespace
>
>         Modified: llvm/trunk/include/llvm/Transforms/Utils/UnrollLoop.h
>         URL:
>         http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/UnrollLoop.h?rev=225131&r1=225130&r2=225131&view=diff
>         ==============================================================================
>         --- llvm/trunk/include/llvm/Transforms/Utils/UnrollLoop.h
>         (original)
>         +++ llvm/trunk/include/llvm/Transforms/Utils/UnrollLoop.h Sun
>         Jan  4 06:03:27 2015
>         @@ -18,7 +18,7 @@
>             namespace llvm {
>           -class AssumptionTracker;
>         +class AssumptionCache;
>           class Loop;
>           class LoopInfo;
>           class LPPassManager;
>         @@ -26,7 +26,7 @@ class Pass;
>             bool UnrollLoop(Loop *L, unsigned Count, unsigned
>         TripCount, bool AllowRuntime,
>                           unsigned TripMultiple, LoopInfo *LI, Pass *PP,
>         -                LPPassManager *LPM, AssumptionTracker *AT);
>         +                LPPassManager *LPM, AssumptionCache *AC);
>             bool UnrollRuntimeLoopProlog(Loop *L, unsigned Count,
>         LoopInfo *LI,
>                                        LPPassManager* LPM);
>
>         Added: llvm/trunk/lib/Analysis/AssumptionCache.cpp
>         URL:
>         http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AssumptionCache.cpp?rev=225131&view=auto
>         ==============================================================================
>         --- llvm/trunk/lib/Analysis/AssumptionCache.cpp (added)
>         +++ llvm/trunk/lib/Analysis/AssumptionCache.cpp Sun Jan  4
>         06:03:27 2015
>         @@ -0,0 +1,125 @@
>         +//===- AssumptionCache.cpp - Cache finding @llvm.assume calls
>         -------------===//
>         +//
>         +//                     The LLVM Compiler Infrastructure
>         +//
>         +// This file is distributed under the University of Illinois
>         Open Source
>         +// License. See LICENSE.TXT for details.
>         +//
>         +//===----------------------------------------------------------------------===//
>         +//
>         +// This file contains a pass that keeps track of @llvm.assume
>         intrinsics in
>         +// the functions of a module.
>         +//
>         +//===----------------------------------------------------------------------===//
>         +
>         +#include "llvm/Analysis/AssumptionCache.h"
>         +#include "llvm/IR/CallSite.h"
>         +#include "llvm/IR/Dominators.h"
>         +#include "llvm/IR/Function.h"
>         +#include "llvm/IR/Instructions.h"
>         +#include "llvm/IR/IntrinsicInst.h"
>         +#include "llvm/IR/PatternMatch.h"
>         +#include "llvm/Support/Debug.h"
>         +using namespace llvm;
>         +using namespace llvm::PatternMatch;
>         +
>         +void AssumptionCache::scanFunction() {
>         +  assert(!Scanned && "Tried to scan the function twice!");
>         +  assert(AssumeHandles.empty() && "Already have assumes when
>         scanning!");
>         +
>         +  // Go through all instructions in all blocks, add all calls
>         to @llvm.assume
>         +  // to this cache.
>         +  for (BasicBlock &B : F)
>         +    for (Instruction &II : B)
>
>     Why not use inst_iterator?  (Which we really need a range form of
>     btw.)
>
>
> The original code didn't, and I didn't actually change this loop at 
> all. Sadly, the mailer doesn't show the with-history diff, and the 
> movement of the code probably would have ruined it anyways.
>
> I'd really love to switch a bunch of the double-loops like this to use 
> a range-based InstIterator pattern, completely agree there. But a 
> separate change.
Makes perfect sense.  Yep, the move history got completely lost.
>
>
>         +      if (match(&II, m_Intrinsic<Intrinsic::assume>()))
>         +        AssumeHandles.push_back(&II);
>         +
>         +  // Mark the scan as complete.
>         +  Scanned = true;
>         +}
>         +
>         +void AssumptionCache::registerAssumption(CallInst *CI) {
>         +  assert(match(CI, m_Intrinsic<Intrinsic::assume>()) &&
>         +         "Registered call does not call @llvm.assume");
>         +
>         +  // If we haven't scanned the function yet, just drop this
>         assumption. It will
>         +  // be found when we scan later.
>         +  if (!Scanned)
>         +    return;
>         +
>         +  AssumeHandles.push_back(CI);
>         +
>         +#ifndef NDEBUG
>         +  assert(CI->getParent() &&
>         +         "Cannot register @llvm.assume call not in a basic
>         block");
>         +  assert(&F == CI->getParent()->getParent() &&
>         +         "Cannot register @llvm.assume call not in this
>         function");
>         +
>         +  // We expect the number of assumptions to be small, so in
>         an asserts build
>         +  // check that we don't accumulate duplicates and that all
>         assumptions point
>         +  // to the same function.
>         +  SmallPtrSet<Value *, 16> AssumptionSet;
>         +  for (auto &VH : AssumeHandles) {
>         +    if (!VH)
>         +      continue;
>         +
>         +    assert(&F ==
>         cast<Instruction>(VH)->getParent()->getParent() &&
>         +           "Cached assumption not inside this function!");
>         +    assert(match(cast<CallInst>(VH),
>         m_Intrinsic<Intrinsic::assume>()) &&
>         +           "Cached something other than a call to
>         @llvm.assume!");
>         +    assert(AssumptionSet.insert(VH).second &&
>         +           "Cache contains multiple copies of a call!");
>         +  }
>
>     This seems like an odd place for this logic.  Arguably it should
>     be in the getter?  Or at least called from the scanFunction code too?
>
>         +#endif
>         +}
>         +
>         +void AssumptionCacheTracker::FunctionCallbackVH::deleted() {
>         +  auto I =
>         ACT->AssumptionCaches.find_as(cast<Function>(getValPtr()));
>         +  if (I != ACT->AssumptionCaches.end())
>         +    ACT->AssumptionCaches.erase(I);
>         +  // 'this' now dangles!
>         +}
>         +
>         +AssumptionCache
>         &AssumptionCacheTracker::getAssumptionCache(Function &F) {
>         +  // We probe the function map twice to try and avoid
>         creating a value handle
>         +  // around the function in common cases. This makes
>         insertion a bit slower,
>         +  // but if we have to insert we're going to scan the whole
>         function so that
>         +  // shouldn't matter.
>         +  auto I = AssumptionCaches.find_as(&F);
>         +  if (I != AssumptionCaches.end())
>         +    return *I->second;
>         +
>         +  // Ok, build a new cache by scanning the function, insert
>         it and the value
>         +  // handle into our map, and return the newly populated cache.
>         +  auto IP = AssumptionCaches.insert(std::make_pair(
>         +      FunctionCallbackVH(&F, this),
>         llvm::make_unique<AssumptionCache>(F)));
>
>     Why does creating a new AssumptionCache imply populating it?
>
>
> The original assumption tracker is maximally lazy. Until you try to 
> find an assumption in a function, no work is done. In switching to a 
> separate object, I could have changed that to eagerly scan the 
> function when requesting the separate object, but that actually hurts 
> the performance that the original tracker design was trying to achieve.
This makes sense and is clearly what the code is doing.  I think this 
comment was based on my misreading of the code in question.
>
> One goal of the separate object is to have all of the layers of 
> utility code work (almost) exclusively with the per-function cache. 
> Without this, it won't be possible to use the same cache produced both 
> with the new pass manager and the old pass manager in the shared 
> utility code. The utility code is also where looking at assumptions 
> has the highest cost to compile time because we don't want to scan the 
> entire function every time we reach into value tracking unless an 
> assume would actually be relevant to the particular value tracking 
> taking place.
>
> The end result is that to have comparable performance to the original 
> pass, the per-function cache needs to be lazily populated as well. I'd 
> be really interested if at some point (maybe the new pass manage? 
> unsure) we could switch this to be the simpler, eager form. But again, 
> I actually wanted to change as little in this patch as I could, and so 
> I kept the design very similar.
I'm more than fine with leaving it entirely lazy.  That's actually what 
I was trying to suggest.  (Again, I misread the current code.)



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150105/e8b82753/attachment.html>


More information about the llvm-commits mailing list