[PATCH] D11274: Add new constructors for LoopInfo/DominatorTree/BFI/BPI
Duncan P. N. Exon Smith
dexonsmith at apple.com
Thu Jul 16 15:43:23 PDT 2015
> On 2015-Jul-16, at 12:53, Cong Hou <congh at google.com> wrote:
>
> congh created this revision.
> congh added a reviewer: dexonsmith.
> congh added subscribers: llvm-commits, davidxl.
>
> Those new constructors make it more natural to construct an object for a function. For example, previously to build a LoopInfo for a function, we need four statements:
>
> DominatorTree DT;
> LoopInfo LI;
> DT.recalculate(F);
> LI.analyze(DT);
>
> Now we only need one statement:
>
> LoopInfo LI(DominatorTree(F));
>
> http://reviews.llvm.org/D11274
>
> Files:
> include/llvm/Analysis/BlockFrequencyInfo.h
> include/llvm/Analysis/BranchProbabilityInfo.h
> include/llvm/Analysis/LoopInfo.h
> include/llvm/IR/Dominators.h
> lib/Analysis/BlockFrequencyInfo.cpp
> lib/Analysis/LoopInfo.cpp
>
> Index: lib/Analysis/LoopInfo.cpp
> ===================================================================
> --- lib/Analysis/LoopInfo.cpp
> +++ lib/Analysis/LoopInfo.cpp
> @@ -602,6 +602,10 @@
> return NearLoop;
> }
>
> +LoopInfo::LoopInfo(const DominatorTreeBase<BasicBlock> &DomTree) {
> + analyze(DomTree);
> +}
> +
> /// updateUnloop - The last backedge has been removed from a loop--now the
> /// "unloop". Find a new parent for the blocks contained within unloop and
> /// update the loop tree. We don't necessarily have valid dominators at this
> Index: lib/Analysis/BlockFrequencyInfo.cpp
> ===================================================================
> --- lib/Analysis/BlockFrequencyInfo.cpp
> +++ lib/Analysis/BlockFrequencyInfo.cpp
> @@ -105,6 +105,14 @@
> } // end namespace llvm
> #endif
>
> +BlockFrequencyInfo::BlockFrequencyInfo() {}
> +
> +BlockFrequencyInfo::BlockFrequencyInfo(const Function &F,
> + const BranchProbabilityInfo &BPI,
> + const LoopInfo &LI) {
> + calculate(F, BPI, LI);
> +}
> +
> void BlockFrequencyInfo::calculate(const Function &F,
> const BranchProbabilityInfo &BPI,
> const LoopInfo &LI) {
> Index: include/llvm/IR/Dominators.h
> ===================================================================
> --- include/llvm/IR/Dominators.h
> +++ include/llvm/IR/Dominators.h
> @@ -69,6 +69,9 @@
> typedef DominatorTreeBase<BasicBlock> Base;
>
> DominatorTree() : DominatorTreeBase<BasicBlock>(false) {}
> + explicit DominatorTree(Function &F) : DominatorTreeBase<BasicBlock>(false) {
> + recalculate(F);
> + }
>
> DominatorTree(DominatorTree &&Arg)
> : Base(std::move(static_cast<Base &>(Arg))) {}
> Index: include/llvm/Analysis/LoopInfo.h
> ===================================================================
> --- include/llvm/Analysis/LoopInfo.h
> +++ include/llvm/Analysis/LoopInfo.h
> @@ -642,6 +642,7 @@
> LoopInfo(const LoopInfo &) = delete;
> public:
> LoopInfo() {}
> + explicit LoopInfo(const DominatorTreeBase<BasicBlock> &DomTree);
>
> LoopInfo(LoopInfo &&Arg) : BaseT(std::move(static_cast<BaseT &>(Arg))) {}
> LoopInfo &operator=(LoopInfo &&RHS) {
> Index: include/llvm/Analysis/BranchProbabilityInfo.h
> ===================================================================
> --- include/llvm/Analysis/BranchProbabilityInfo.h
> +++ include/llvm/Analysis/BranchProbabilityInfo.h
> @@ -39,6 +39,9 @@
> /// value 10.
> class BranchProbabilityInfo {
> public:
> + BranchProbabilityInfo() {}
> + BranchProbabilityInfo(Function &F, const LoopInfo &LI) { calculate(F, LI); }
> +
> void releaseMemory();
>
> void print(raw_ostream &OS) const;
> Index: include/llvm/Analysis/BlockFrequencyInfo.h
> ===================================================================
> --- include/llvm/Analysis/BlockFrequencyInfo.h
> +++ include/llvm/Analysis/BlockFrequencyInfo.h
> @@ -31,6 +31,10 @@
> std::unique_ptr<ImplType> BFI;
>
> public:
> + BlockFrequencyInfo();
> + BlockFrequencyInfo(const Function &F, const BranchProbabilityInfo &BPI,
> + const LoopInfo &LI);
> +
> const Function *getFunction() const;
> void view() const;
>
>
>
> <D11274.29937.patch>
LGTM.
More information about the llvm-commits
mailing list