[llvm] r242486 - Add new constructors for LoopInfo/DominatorTree/BFI/BPI
Cong Hou
congh at google.com
Thu Jul 16 16:23:36 PDT 2015
Author: conghou
Date: Thu Jul 16 18:23:35 2015
New Revision: 242486
URL: http://llvm.org/viewvc/llvm-project?rev=242486&view=rev
Log:
Add new constructors for LoopInfo/DominatorTree/BFI/BPI
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
Modified:
llvm/trunk/include/llvm/Analysis/BlockFrequencyInfo.h
llvm/trunk/include/llvm/Analysis/BranchProbabilityInfo.h
llvm/trunk/include/llvm/Analysis/LoopInfo.h
llvm/trunk/include/llvm/IR/Dominators.h
llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp
llvm/trunk/lib/Analysis/LoopInfo.cpp
Modified: llvm/trunk/include/llvm/Analysis/BlockFrequencyInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/BlockFrequencyInfo.h?rev=242486&r1=242485&r2=242486&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/BlockFrequencyInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/BlockFrequencyInfo.h Thu Jul 16 18:23:35 2015
@@ -31,6 +31,10 @@ class BlockFrequencyInfo {
std::unique_ptr<ImplType> BFI;
public:
+ BlockFrequencyInfo();
+ BlockFrequencyInfo(const Function &F, const BranchProbabilityInfo &BPI,
+ const LoopInfo &LI);
+
const Function *getFunction() const;
void view() const;
Modified: llvm/trunk/include/llvm/Analysis/BranchProbabilityInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/BranchProbabilityInfo.h?rev=242486&r1=242485&r2=242486&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/BranchProbabilityInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/BranchProbabilityInfo.h Thu Jul 16 18:23:35 2015
@@ -39,6 +39,9 @@ class raw_ostream;
/// value 10.
class BranchProbabilityInfo {
public:
+ BranchProbabilityInfo() {}
+ BranchProbabilityInfo(Function &F, const LoopInfo &LI) { calculate(F, LI); }
+
void releaseMemory();
void print(raw_ostream &OS) const;
Modified: llvm/trunk/include/llvm/Analysis/LoopInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopInfo.h?rev=242486&r1=242485&r2=242486&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LoopInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/LoopInfo.h Thu Jul 16 18:23:35 2015
@@ -642,6 +642,7 @@ class LoopInfo : public LoopInfoBase<Bas
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) {
Modified: llvm/trunk/include/llvm/IR/Dominators.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Dominators.h?rev=242486&r1=242485&r2=242486&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Dominators.h (original)
+++ llvm/trunk/include/llvm/IR/Dominators.h Thu Jul 16 18:23:35 2015
@@ -69,6 +69,9 @@ public:
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))) {}
Modified: llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp?rev=242486&r1=242485&r2=242486&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp Thu Jul 16 18:23:35 2015
@@ -105,6 +105,14 @@ struct DOTGraphTraits<BlockFrequencyInfo
} // 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) {
Modified: llvm/trunk/lib/Analysis/LoopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopInfo.cpp?rev=242486&r1=242485&r2=242486&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LoopInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/LoopInfo.cpp Thu Jul 16 18:23:35 2015
@@ -602,6 +602,10 @@ Loop *UnloopUpdater::getNearestLoop(Basi
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
More information about the llvm-commits
mailing list